Hi abc,
First, your question does not seem very relevant to the
LAM/MPI list !
Well, I feel you must think a bit more about the overall
design of the code.
Your two loops are very quick, with complexity of order n,
and present
no dependencies between different values of the index i.
This means
they can be easily parallelized, but as they are so quick,
the price of
moving the data across processors may be larger than the
price of the
calculation itself. This implies that the data must be
distributed and
stay distributed over your mpi processes for the
parallelization to be
efficient.
So far so good, but then you have to understand what other
dependencies
lie between the distributed data.
In particular I suspect complex dependencies are hidden
within the
routine force. Also, I suspect that the real cpu time is
used in force.
A good starting point might be to understand where the cpu
is used in
the sequential code, using some profiling tool, in order to
get some
input for the overall design of the parallelisation scheme.
Hoping this adds more understanding than confusion in your
mind.
Pierre V.
abc abc wrote:
> hi everybody,
> can u pls help me parallelize the following code by
inserting MPI
> calls. There are 2 DO loops that I am trying to
parallelize but I am
> confused a bit. thanks for your time.
> ballo.
>
------------------------------------------------------------
-------------------------------------------
> subroutine mpi_code_f77
> integer step,deltim,dmptim,iseed
> parameter (n=4096)
> parameter (nlayer=128)
> common /control/
seth,setl,dt,yxrat,yxrat2,rnd,delr,
> &
nsp1,nstep,mcstep,ndump,deltim,dmptim,step,iseed
> common /posvel/ isp(n),rx(n),ry(n),rz(n),
> & vx(n),vy(n),vz(n),ax(n),ay(n),az(n)
> common /potential/ s11,s12,s22,
> & rc11,rc11sq,rc12,rc12sq,rc22,rc22sq,
> & ep11,ep12,ep22,xm(2),grav
>
> dt2=dt/2.0d0
>
> do 1000 i=1,n
>
> if (rx(i).gt.0.5) then
> ax(i)=ax(i)-grav
> else
> ax(i)=ax(i)+grav
> endif
>
> vx(i)=vx(i)+ax(i)*dt2
> vy(i)=vy(i)+ay(i)*dt2
> vz(i)=vz(i)+az(i)*dt2
> rx(i)=rx(i)+vx(i)*dt
> if (rx(i).ge.1.0d0) rx(i)=rx(i)-1.0d0
> if (rx(i).lt.0.0d0) rx(i)=rx(i)+1.0d0
> ry(i)=ry(i)+vy(i)*dt
> if (ry(i).ge.yxrat) ry(i)=ry(i)-yxrat
> if (ry(i).lt.0.0d0) ry(i)=ry(i)+yxrat
> rz(i)=rz(i)+vz(i)*dt
> if (rz(i).ge.yxrat) rz(i)=rz(i)-yxrat
> if (rz(i).lt.0.0d0) rz(i)=rz(i)+yxrat
>
> 1000 continue
>
> call force
>
> do 1100 i=1,n
> vx(i)=vx(i)+ax(i)*dt2
> vy(i)=vy(i)+ay(i)*dt2
> vz(i)=vz(i)+az(i)*dt2
> 1100 continue
> return
> end
>
------------------------------------------------------------
---------------------------------------------
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection
around
> http://mail.yahoo.com
>
>
------------------------------------------------------------
------------
>
> _______________________________________________
> This list is archived at http://www.l
am-mpi.org/MailArchives/lam/
--
Soutenez le mouvement SAUVONS LA RECHERCHE :
http://recherch
e-en-danger.apinc.org/
_/_/_/_/ _/ _/ Dr. Pierre VALIRON
_/ _/ _/ _/ Laboratoire d'Astrophysique
_/ _/ _/ _/ Observatoire de Grenoble / UJF
_/_/_/_/ _/ _/ BP 53 F-38041 Grenoble Cedex 9
(France)
_/ _/ _/ http://
www-laog.obs.ujf-grenoble.fr/~valiron/
_/ _/ _/ Mail: Pierre.Valiron obs.ujf-grenoble.fr
_/ _/ _/ Phone: +33 4 7651 4787 Fax: +33 4
7644 8821
_/ _/_/
_______________________________________________
This list is archived at http://www.l
am-mpi.org/MailArchives/lam/
|