This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: how to enable vector intrinsic functions in fortran frontend
- From: Sa Liu <SALIU at de dot ibm dot com>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: fortran at gcc dot gnu dot org, Ulrich Weigand <Ulrich dot Weigand at de dot ibm dot com>, Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>, Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- Date: Wed, 17 Oct 2007 19:02:02 +0200
- Subject: Re: how to enable vector intrinsic functions in fortran frontend
Tobias Burnus <burnus@net-b.de> wrote on 15.10.2007 21:05:17:
> I also would like that the vector types compile on (almost) any system.
> The advantage of Fortran is that it is essentially system independent;
> there are only very few parts in Fortran programs which are system
> dependent (such as the arguments to the "SYSTEM" call).
>
> VECTOR sounds like a concept very much suited to number crunching in
> general and thus it makes sense - in terms of portability - that a
> program targeted for a vector-supporting system also runs on systems
> which do not; and even if the generated code on non-PowerPC is clumsy
> and slow, having it supported there makes the feature more appealing to
> scientific users (which rarely target one system only).
Generally I think that the VECTOR type should be kept behind a flag, so
that it only gets enabled on the systems supporting vector without
bothering the other. As the scalar types of vector vary from system to
system, idealy the checking routines should be kept in each backend. But
the fortran parse should be manipulated to recognize the VECTOR syntax. In
general we'd like to have a Fortran extension to support VECTOR and allow
Fortran applications to benefit from vectorizable platforms.
> > I think an intrinsic module would be the best place for these to go.
> The advantage of an intrinsic module would be that it keeps the
> namespace clean; the disadvantage is that it is not directly compatible
> with the XL Fortran compiler.
Concretely why is it not compatible with XL Fortran compiler? Sorry I'm
not quite familar with intrinsic module.
> One could combine these: A flag to enable the VECTOR(...) declaration
> and an intrinsic module to provide VEC_*. However, as VEC_* only takes
> vectors, one could directly enable it with the -fvector-type flag. I
> also do not see the problem name clashes for this reasons.
>
I actually prefer the former option. As we try to enable vector intrinsics
on more than one systems, the -fvector-type should only switch on data
declaration VECTOR(...), and different intrinsic sets should be kept
separately, say in different intrinsic modules (if the compatibility
problem getting resolved). And each intrinsic module should only be
activated on the target system.
To take PowerPC and SPU as an example, there are a couple of steps to go:
- allow declaration VECTOR(...) with -fvector-type
- check types/kinds on PowerPC
VECTOR(INTEGER(1)) vector signed char
VECTOR(INTEGER(2)) vector signed short
VECTOR(INTEGER(4)) vector signed int, vector signed
long
VECTOR(PIXEL) vector pixel
VECTOR(REAL(4)) vector float
VECTOR(UNSIGNED(1)) vector unsigned char
VECTOR(UNSIGNED(2)) vector unsigned short
VECTOR(UNSIGNED(4)) vector unsigned int, vector
unsigned long
- check types/kinds on SPU
VECTOR(INTEGER(1)) vector signed char
VECTOR(INTEGER(2)) vector signed short
VECTOR(INTEGER(4)) vector signed int
VECTOR(INTEGER(8)) vector signed long long
VECTOR(REAL(4)) vector float
VECTOR(REAL(8)) vector double
VECTOR(UNSIGNED(1)) vector unsigned char
VECTOR(UNSIGNED(2)) vector unsigned short
VECTOR(UNSIGNED(4)) vector unsigned int
VECTOR(UNSIGNED(8)) vector unsigned long long
- add intrinsic module ppc-altivec-intrinsics.def for PowerPC
- add intrinsic module spu-vector-intrinsics.def for SPU
I will think of detailed solutions when I dig a bit more in the code.
Further suggestions/comments/criticism are alway welcome!
Thanks!
Sa