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 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Steve Lionel (Intel)

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

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.

Bild des Benutzers Steve Lionel (Intel)

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

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.

Melden Sie sich an, um einen Kommentar zu hinterlassen.