Home > Archive > Fortran > March 2004 > Re: Fortran 2003 and F
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Fortran 2003 and F
|
|
| David Jones 2004-03-27, 12:16 am |
| beliavsky@aol.com wrote:
> "David Jones" <dajxxx@ceh.ac.uk> wrote in message
> news:<40582947@news.nwl.ac.uk>...
>
unless[color=darkred]
>
> A compiler can choose not to evaluate (x-y) in the code
>
> z = max(x-y,0.0)
>
> if it 'knows' that x is less than y (for example if the previous
line
> were 'x = y - 1.0'). I think the same optimizations can be done for
'z
> = dim(x,y)' and the corresponding code with MAX, so the cited speed
> consideration does not make sense to me.
Certain processors were/are able to do comparisons faster directly,
compared with forming the difference and testing against zero. Thus
the code for DIM can (sometimes) just do the simple comparison and set
the final result to zero, avoiding more costly operations. Remember
that we are thinking of a function introduced early on in Fortan's
history, when there was possibly less emphasis on optimisation at the
'compilation of source code' level, and more on ensuring fast
implementation of common procedures at the machine code level within
the standard set of Fortran intrinsic functions.
| |
| beliavsky@aol.com 2004-03-27, 12:17 am |
| "David Jones" <dajxxx@ceh.ac.uk> wrote in message news:<40582947@news.nwl.ac.uk>...
> Also, there are/were computation speed considerations, since the
> underlying code for DIM can choose not to form the difference unless
> actually needed.
>
> David Jones
A compiler can choose not to evaluate (x-y) in the code
z = max(x-y,0.0)
if it 'knows' that x is less than y (for example if the previous line
were 'x = y - 1.0'). I think the same optimizations can be done for 'z
= dim(x,y)' and the corresponding code with MAX, so the cited speed
consideration does not make sense to me.
|
|
|
|
|