No way to vectorize the implicit loop in an elemental subroutine?

No way to vectorize the implicit loop in an elemental subroutine?

It seems to me that the implicit loop in Fortran elemental functions is never vectorized unless declared as a vector function, like so:

!dec$ attributes vector :: foo

elemental function foo(x)

But this doesn't work for subroutines (and it puts inconvenient restrictions on functions). I'd be interested to know if there's any way to vectorize an elemental subroutine (other than inlining it).

5 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

There is no implicit loop in the elemental procedure - the procedure is scalar. The loop happens in the caller.

Vector functions may indeed be what you want.Otherwise, as you say, inlining,

Steve - Intel Developer Support

Hmm, unfortunate, since it's impossible have multiple outputs in this case, and Fortran does not provide any meaningful support for implementation of rank-generic functions except via elemental routines.

Fortran, the language, will have something for you in the next standard, with "assumed-rank" dummy arguments, but that's a future (and probably would not help with optimization.)

Steve - Intel Developer Support

Hmm, true. I suppose assumed rank *would* still help if it was worth it to simply rewrite the function in C/C++ (e.g. if it's big and expensive and you can still write with vectorizable loops in the other language); then at least you don't have to write some very large number of Fortran interfaces in order to give an explicit interface to every array rank. Which I gather is roughly why assumed rank was important for MPI interfaces in the first place.

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi