Alberto Fasso' <[log in to unmask]> wrote:
>On Mon, 18 Sep 2000, Aleksandar Donev wrote:
...
>> and the Fortran 90 compiler fully informed that the function Erf is a
>> harmless PURE procedure, I am afraid a smart compiler would optimize
>> "too" well the above code and make the timings invalid.
>
>My solution:
>declare an array y of dimension 1000, fill all its elements
>with the same value x, and write:
>
>CALL SYSTEM_CLOCK(CLOCK=c1)
>DO k=1,1000...
> erf=Erf(y(k))
... presumably you actually use a different variable
... than the function name
>END DO
>CALL SYSTEM_CLOCK(CLOCK=c2)
>counts=c2-c1
>
>Do you think that the compiler would be smart enough to see
>that all elements are identical?
Since ERF is PURE, the compiler needs only notice that
the scalar result can be defined with the result of the
last function invocation and the rest or the loop can be
skipped.
--
J. Giles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|