FINDLOC - Fortran 2008 intrinsic - when in Intel compiler?

FINDLOC - Fortran 2008 intrinsic - when in Intel compiler?


From what I can gather, there is no schedule yet to implement in Intel compiler the FINDLOC function, a Fortran 2008 intrinsic to find the location in array of an element with a particular value.  Is this true?  If yes, is it possible to encourage the decision makers in any way to take another look at this function, reinvestigate the user interest (if that would help), and add this to the development stack?

On a project I'm working on, there is a home-grown function (VALLOC) that is used extensively.  But it has some performance limitations.  Compared to test functions that are written in the same fashion as this home-grown VALLOC, MINLOC and MAXLOC intrinsics are about 10% faster on array sizes on the order of 1E6.  So I'm thinking FINDLOC may be similarly faster than VALLOC.  Hence our interest in getting the FINDLOC intrinsic added to an Intel compiler version in the near future.  Now, due to company policy, I'm unable to post any of the code.  However, I was hoping other users would also have a similar interest in FINDLOC.

For those of you who may not be familiar with the FINDLOC definition in Fortran 2008 standard, here is an excerpt from N1828 document at the WG5 link

9.11 Find location in an array

The following transformational function has been added

findloc(array,value[,mask,kind,back]) or


finds the location in array of an element with value value.

array is an array of intrinsic type.

value is a scalar of a type that may be used for intrinsic comparisons.

dim is a scalar integer.

mask conforms with array and is of type logical.

kind is a scalar constant expression.

back is a scalar logical.

This function is modelled on the transformational function maxloc, replacing the search for a maximum value with a search for the value value. The result has the type and kind of array and the shape is determined from the shape of mask and the value of dim or its absence, just as for maxloc. The search is applied to all the elements of array to yield a scalar or to the elements of each rank-one section that spans dimension dim to yield a result of rank reduced by one.



4 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

I submitted premier feature request 628822 on this issue nearly 2 years ago.  As ifort already supports auto-vectorization of linear search, this should be a valuable feature. ifort even supports an f95 work-around of the nature:

index = maxloc(merge(1.,0.,array == value),dim=1)

which does much the same thing in a more inscrutable way.  As the AVX ISA doesn't have suitable integer instructions, it's better to use default real for the implicit array.  For portability (this is a compiler breaker), you may wish to make an explicit temporary array, in which case ifort is able to fuse the loops so that it doesn't cost much.

I suppose in order to support any such f2008 intrinsics, the kind and mask arguments will have to be added to the f2003 ones, so it looks to me like a logical inclusion in an f2008 array intrinsics project.

With some compilers, the back feature can be achieved in f95 by specifying reversal of the array:

index = maxloc(merge(1.,0.,array(size(array):1:-1) == value),dim=1)

I don't think ifort could optimize this, but back might pose the same problem.

In principle, findloc should be more efficient than maxloc, as it would allow for early exit without the compiler recognizing such a specialized use of maxloc.

imagem de Steve Lionel (Intel)

We don't in general talk in public about timeframes for features, except for those which are almost certain to appear in the near future. FINDLOC is not among those, but it will get done eventually. We have decided to focus on finishing F2003, with some F2008 work around the edges. I will add your request to the list of those asking for FINDLOC.


TimP, Steve:

Thanks for your feedback and suggestions.

As you indicate, FINDLOC can be worked around with a specific use of MAXLOC/MINLOC.  And as can be seen, there are a lot of similarities amongst these functions and their parameters.

That is why I'm surprised FINDLOC is not already available in ifort when several other Fortran 2008 features have already been added.  I'd have thought FINDLOC was a "quickie", a low-hanging fruit, so to speak.  That is, a good developer could take the compiler code for MAXLOC/MINLOC and extend it fairly easily, relatively speaking of course, to achieve the FINDLOC functionality.  Anyways, thanks Steve, for adding one more user to list of folks asking for this function.



Faça login para deixar um comentário.