Global array operations: a performance hit?
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
Global array operations: a performance hit?         


Author: deltaquattro
Date: Jun 17, 2008 08:41

Hi,

I was wondering whether global array operations, introduced in f90,
can have a negative impact on performance. Compare:

do i=1, ntheta
r(0,i) = rhub
r(nr+1,i) = rmax
dt(0,i) = 0.0
dft(0,i) = 0.0
dfr(0,i) = 0.0
dt(nr+1,i) = 0.0
dft(nr+1,i) = 0.0
dfr(nr+1,i) = 0.0
end do

with:
Show full article (0.73Kb)
19 Comments
Re: Global array operations: a performance hit?         


Author: Dennis Wassel
Date: Jun 17, 2008 10:21

On 17 Jun., 17:41, deltaquattro gmail.com> wrote:
> Hi,
>
> I was wondering whether global array operations, introduced in f90,
> can have a negative impact on performance.
>
> [snip]
>
> I found the execution time of the latter to be higher than the former,
> as if many DO loops were executed instead than just one. Why use
> global array operations then? Isn't better to stick to old plain DO
> loops? Thanks,
>
> regards,
>
> deltaquattro

This is quite a strange observation and raises some questions:

1) What optimisation options did you use?
Show full article (2.39Kb)
no comments
Re: Global array operations: a performance hit?         


Author: James Van Buskirk
Date: Jun 17, 2008 10:55

"deltaquattro" gmail.com> wrote in message
news:9c706700-2861-4d17-a3b8-7e2291fa0b5f@2g2000hsn.googlegroups.com...
> do i=1, ntheta
> r(0,i) = rhub
> r(nr+1,i) = rmax
> dt(0,i) = 0.0
> dft(0,i) = 0.0
> dfr(0,i) = 0.0
> dt(nr+1,i) = 0.0
> dft(nr+1,i) = 0.0
> dfr(nr+1,i) = 0.0
> end do
Show full article (1.72Kb)
no comments
Re: Global array operations: a performance hit?         


Author: nospam
Date: Jun 17, 2008 11:31

deltaquattro gmail.com> wrote:
> I was wondering whether global array operations, introduced in f90,
> can have a negative impact on performance. Compare:
>
[elided initialization with DO loops and whole array operations]
> I found the execution time of the latter to be higher than the former,
> as if many DO loops were executed instead than just one. Why use
> global array operations then? Isn't better to stick to old plain DO
> loops? Thanks,

Note that the usual terminology is something more like "whole array
operations" or even just an unmodified "array operations" instead of
"global".

The main reasons are clarity and conciseness. If it doesn't help clarity
and conciseness, don't do it. That is, no doubt, an oversimplification;
there are exceptions, etc. But its a good first approximation. Every
once in a while they might also get you faster execution, but if that is
your primary reason for using them, and you don't have specific
knowledge of exactly why to expect faster execution from your paticular
case, then your efforts are probably misplaced.
Show full article (3.45Kb)
no comments
Re: Global array operations: a performance hit?         


Author: Dennis Wassel
Date: Jun 17, 2008 13:05

On 17 Jun., 20:31, nos...@see.signature (Richard Maine) wrote:
>
> [snipety-snip]
>
> In answer to Dennis, by the way, it is *VERY* common for whole array
> operations to be slower than DO loops. No, it is not all all strange. It
> is much closer to the usual state of afairs. There are a whole host of
> reasons.

Beats me.
After all, when using array operations you have additional information
either readily available, or you are able to extract it fairly easy,
which is not always the case in DO loops. Talk about aliasing,
strides, contingent memory locations etc. But then again, "See point
1".
I actually find this hard to believe, but given that I'm rather new to
the delightful post-77 Fortran world and haven't really done any
serious benchmarking on array operations vs DO loops, I'll gladly
trust your judgement on this. Thanks for enlightening us!
Show full article (2.84Kb)
no comments
Re: Global array operations: a performance hit?         


Author: Steven G. Kargl
Date: Jun 17, 2008 13:41

In article <9e1269be-de8c-4971-857d-e95bf639d7d8@i76g2000hsf.googlegroups.com>,
Dennis Wassel googlemail.com> writes:
> On 17 Jun., 20:31, nos...@see.signature (Richard Maine) wrote:
>
>> 1. Compilers have had over 5 decades of time to develop techniques of
>> optimizing loops. Progress has been made in that time. There has only
>> been about a decade or two (some work preceeded the f90 standard; other
>> compilers didn't really start until later) of significant work on
>> optimizing array expressions. Things have improved and are still
>> improving, but it just is not at the level of experience of DO-loop
>> optimization.
>
> OK, here's my newfound corner of gcc development that I feel like
> doing, as soon as I have more time on my hands than right now. After
> all, despite...
Show full article (2.19Kb)
no comments
Re: Global array operations: a performance hit?         


Author: Dennis Wassel
Date: Jun 17, 2008 14:21

On 17 Jun., 22:41, ka...@troutmask.apl.washington.edu (Steven G.
Kargl) wrote:
> In article <9e1269be-de8c-4971-857d-e95bf639d...@i76g2000hsf.googlegroups.com>,
>
> For starters, you can see what gfortran does by using the
> -fdump-tree-original option. Try it with
>
> subroutine po(x,y)
> real x(3,3), y(3,3)
> x = 1.
> y = 0.
> x = matmul(x,y)
> end subroutine po
>
> If you're really curious about the internal goop, use -fdump-tree-all.

This sounds dangerously like "don't do this, unless you *really* want
to".
Right'o, gimme something to fill my umpteen MBs of terminal buffer :)
Show full article (1.08Kb)
no comments
Re: Global array operations: a performance hit?         


Author: glen herrmannsfeldt
Date: Jun 17, 2008 17:15

James Van Buskirk wrote:
(snip of example with DO loops)
>>r(0,:) = rhub
>>r(nr+1,:) = rmax
>>dt(0,:) = 0.0
>>dft(0,:) = 0.0
>>dfr(0,:) = 0.0
>>dt(nr+1,:) = 0.0
>>dft(nr+1,:) = 0.0
>>dfr(nr+1,:) = 0.0
>>I found the execution time of the latter to be higher than the former,
>>as if many DO loops were executed instead than just one. Why use
>>global array operations then? Isn't better to stick to old plain DO
>>loops? Thanks,
Show full article (2.05Kb)
no comments
Re: Global array operations: a performance hit?         


Author: glen herrmannsfeldt
Date: Jun 17, 2008 17:36

Dennis Wassel wrote:
(snip, and previously snipped DO vs. array expressions)
> I'm not a compiler specialist but AFAIK, array operations should not
> usually be slower than explicit loop constructs.

To make a fair comparison, it should be separate DO loops
vs. array operations, and separate DO loops vs.
a single DO loop. Then you can separate the difference
due to memory access patterns and actual instructions.

My usual rule is that simple array operations are better than
(or at least as good as) DO loops, but more complicated ones
are slower. (Especially if temporary arrays are used.)

-- glen
no comments
Re: Global array operations: a performance hit?         


Author: Craig Powers
Date: Jun 17, 2008 16:40

glen herrmannsfeldt wrote:
>
> If speed is that important, you might try reversing the
> subscript order (in the whole program).

I suspect, given the context, that outside of this initialization, the
subscripts are accessed in the correct order.
no comments
1 2