Re: forall and do loop



aeroguy <sukhbinder.singh@xxxxxxxxx> writes:

REAL :: DS(100),UTA(100),STA(100),ONE
ONE = 1.0000

! First case
DO I=1,NE
UTA(I)=DS(I)
STA(I)=ONE
END DO

! second case
FORALL(I=1:NE) UTA(I)=DS(I)
STA=ONE


In this two follwoing code which will be more efficient? Efficent in
execution time and in parallel processing?

Execution time will probably depend on the quality of your compiler
(program both and do measurements - and keep in mind that your results
are just for this compiler/CPU ...).

If parallelisation means the usage of compiler features like OpenMP, you
should test it like stated above; if you are parallelising manually
(e.g. MPI), you would be advised to keep the initial code clean and
state as clearly as possible dependencies.

Depending on the value of NE (is it a loop over the whole array?), the
most clean way in my opinion would be

UTA = DS (or: UTA(1:NE) = DS(1:NE) )
STA = ONE

so the interdependencies (or lack of) are obvious. Do measurements if
you have a performance-critical section at hand and *then* try
optimising (see Hoare/Knuth: premature optimisation ...).


Sebastian
.



Relevant Pages

  • Re: Programming languages
    ... >> execution time, ... That's not a good candidate for optimization. ... if there is comething the compiler ... António> programmers and those can't cope with anything else than ...
    (sci.lang)
  • Re: Comp-5 Type storage
    ... > I have been trying to figure out what the storage repn. ... for comp-5 ... 5-digit number in that field at execution time, ... There are compiler directives that manipulate these rules. ...
    (comp.lang.cobol)
  • Re: computing time of execution
    ... > interested in the execution time of the whole program but often this is ... > not the case (you want to compare execution times for a particular part ... We have at least one compiler that returns cpu ... the rest, using the Fortran compiler. ...
    (comp.lang.fortran)
  • Re: Alternate to switch case statement
    ... My question is iam using a switch case statement in which i ... alternative method present so that execution time and code size can be ... which do you want to reduce, execution time or code ... the compiler might use a binary search approach ...
    (comp.lang.c)
  • forall and do loop
    ... In this two follwoing code which will be more efficient? ... execution time and in parallel processing? ...
    (comp.lang.fortran)