Re: forall and do loop
- From: Sebastian Hanigk <hanigk@xxxxxxxxx>
- Date: Fri, 27 Jul 2007 07:50:41 +0200
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
.
- Follow-Ups:
- Re: forall and do loop
- From: aeroguy
- Re: forall and do loop
- References:
- forall and do loop
- From: aeroguy
- forall and do loop
- Prev by Date: forall and do loop
- Next by Date: Re: forall and do loop
- Previous by thread: forall and do loop
- Next by thread: Re: forall and do loop
- Index(es):
Relevant Pages
|