From: mckenney@CIMS.NYU.EDU (Alan McKenney)
Newsgroups: comp.sys.super
Subject: Re: Compiler directives to enforce scalar (non-vector) mode
Summary: What are the compiler directives for scalar mode on
         various vector machines?
Date: 29 Sep 92 14:04:49 GMT
Followup-To: comp.sys.super
Organization: Courant Institute, NYU, NY, NY, USA

A while back I posted:

>     I am currently writing (well, updating) a code which is
> supposed to be (a) portable and (b) have one loop which will be
> vectorized (on vector machines) and another, very similar, which will
> not be.  (The scalar version is for the case when the loop will
> only iterate a very few times.)
> 
>     My first attempt had the first loop be written in a typical
> vectorizable form, the second I put enough scalars into to make
> it scalar on one machine I used.  I later found that other
> compilers were smarter, and *both* loops vectorized.  I suspect
> that as compiler technology improves, any code which foils the
> vectorizer now will either (a) soon be vectorizable or (b)
> be so obfuscated that it will be slower than vector mode
> with vector length one anyway.
> 
>     So, I am now going to try just putting in compiler directives,
> enough so that most any vector machine should recognize one.  CONVEX
> machines require "C$DIR SCALAR" just before the DO, while CRI machines
> want "CDIR$ NOVECTOR" in the same place, so my scalar loop currently
> starts out:
> 
> C$DIR SCALAR
> CDIR$ NOVECTOR
>       DO ....
>  
> 
> Any other compiler directives that I should add to the list?

The summary:

CRI:		CDIR$ NEXTSCALAR	(I was informed that "NOVECTOR"
					turns off vectorization until
					the next "VECTOR" directive.)
Convex:		C$DIR SCALAR
KAI:		CDIR$ NEXT SCALAR	(note possible problem w/ CRI)
PSR:		CVD$L NOVECTOR
DEC:		CDEC$ NOVECTOR
Alliant:	CVD$  NOVECTOR
NEC SX-3:	*VDIR NOVECTOR          (unclear whether "*" could be "C")
Fujitsu		*VOCL LOOP,SCALAR	(unclear whether "*" could be "C")
IBM		Cxxx  PREFER SCALAR	(where "xxx" is specified to the
					 compiler by a command argument.)

Livermore loops brackets scalar loops w/ "CDIR$ NOVECTOR" (start) and
"CDIR$ VECTOR" (end)


One poster said that many compilers accept the CRI directives, even if
they don't document it.  Anybody have more concrete info?


Most of the mail showed the directives in lower case, I assumed that
they are case-insensitive and have reported them in upper.  Some
showed directives beginning with * instead of C, I didn't know
whether compilers consider them interchangeable, so I didn't
report them all as C.


    One problem that seems to have come up: there are often
separate directives to specify scalar mode for the next loop
only and for the rest of the program unit/file, e.g.,
for Cray, "NOVECTOR" turns off vectorization until a "VECTOR"
directive, while "NEXTSCALAR" turns off vectorization only
for the next loop.  Thus, my table should really have 4 columns:

Machine.   Vectorization off   Vectorization on   Next loop only scalar:
-------    -----------------   ----------------   ---------------------
Convex       ???                  ???             C$DIR SCALAR
CRI        CDIR$ NOVECTOR      CDIR$ VECTOR       CDIR$ NEXTSCALAR
...


--
Alan McKenney        E-mail:  mckenney@cims.nyu.edu         (INTERNET)
Courant Institute,NYU,USA     ...!cmcl2!cims.nyu.edu!mckenney   (UUCP)