can DIY functions be faster than intrinsic functions??

can DIY functions be faster than intrinsic functions??

Hi: I was a bit surprised that the code

max=0
do i=1,100000
if (a(i) > maxi) then
maxi = a(i)
end if
end do

is faster than

maxi = maxval(a)

where maxval is an intrinsic function (is 10% slower).
Is it possible and there is a meaningful reason for such unexpected behavior?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Running Visual Fortran v6.1 on windows I find that the example you gave ran slower than the intrinsic maxval. (Running in Release Configuration with speed optimisation throughout.) Typical results for an array of dimension 10,000,000 were:

0.453 sec for your example,
0.375 sec for the intrinsic maxval,

--or, a speed-up of 17% by use of the intrinsic maxval.

HOWEVER, for smaller length arrays, there is no significant difference in execution times.

In my experience, g77 SSE/SSE2 code performs these operations faster than Intel supported compilers, although prof_gen/prof_use do help IFL/ifc. If you actually tested with that typo included, your compiler may have been able to eliminate basic operations as dead code.

Leave a Comment

Please sign in to add a comment. Not a member? Join today