How to HPC and OMP this Fortran code?

General OpenMP discussion

How to HPC and OMP this Fortran code?

Postby loveislonely » Tue Oct 18, 2011 2:15 am

Hi there,

I had run into some fortran code to modify. Obviously, it was written without thinking of high performance computing and not parallelized... Now I would like to make the code "on track" and parallel. After a whole afternoon thinking, I still cannot find where to start. Can any one help me on how to HPC and parallel the code? Thank you very much. Sharp

Code: Select all
       DO I=1,N
         DO J=1,N
            XXX = 0.0D+00
            DO K=1,N
              DO L=1,N
                XXX = XXX + C(K,I)*CABM(K,L)*C(L,J)
              ENDDO
             ENDDO
             IF(I.eq.J) XXX=XXX-1.0d0
         ENDDO
       ENDDO
loveislonely
 
Posts: 31
Joined: Wed Aug 20, 2008 11:32 am

Re: How to HPC and OMP this Fortran code?

Postby ftinetti » Wed Oct 19, 2011 4:12 am

Hi,

What about

Code: Select all
$OMP PARALLEL DO SHARED(C, ...) PRIVATE(XXX, ...)
DO I=1,N
   ...
ENDDO

?

Just curious:
1) What computer and OS are you using?
2) What do you mean by "how to HPC..."?
ftinetti
 
Posts: 582
Joined: Wed Feb 10, 2010 2:44 pm

Re: How to HPC and OMP this Fortran code?

Postby loveislonely » Wed Oct 19, 2011 6:05 pm

Hi, HPC means high performance computing. Obviously, the above code wasn't built in that manner, because the incore dot product involves three matrices. At this level, we don't need to think about parallel yet. But any way, I have solve the problem and now the code can perform 10-12 times faster than before without parallelization. Also, I have parallelized the code and it can perform even faster when parallelized. Thank you all the same.
loveislonely
 
Posts: 31
Joined: Wed Aug 20, 2008 11:32 am

Re: How to HPC and OMP this Fortran code?

Postby ftinetti » Wed Oct 19, 2011 6:18 pm

Hi,

HPC means high performance computing.

Yes, but I did not see it as a verb, "to HPC", what would that be?

I have parallelized the code and it can perform even faster when parallelized

Would you tell how?

Thanks in advance.
ftinetti
 
Posts: 582
Joined: Wed Feb 10, 2010 2:44 pm

Re: How to HPC and OMP this Fortran code?

Postby loveislonely » Wed Oct 19, 2011 6:30 pm

alright, I agree that HPC is not a verb, to HPC means to make the code HPC... I am sorry for the confusion.

I have modified the above code in the way below:
Code: Select all
C$OMP PARALLEL DO Default(Shared) Schedule(Dynamic,1)
C$OMP+ Private(iidx,jidx,Vectmp,XXX)
       Do 360 iidx = 1,N
         Do 370 jidx = 1,iidx-1
           Call DGEMV('N',N,N,One,CABM,N,C(1,jidx),1,Zero,Vectmp,1)
           XXX = SProd(N,C(1,iidx),Vectmp)
370     Continue
         Call DGEMV('N',N,N,One,CABM,N,C(1,iidx),1,Zero,Vectmp,1)
         XXX=SProd(N,C(1,iidx),Vectmp)-One
         DO 380 jidx = iidx+1,N
           Call DGEMV('N',N,N,One,CABM,N,C(1,jidx),1,Zero,Vectmp,1)
           XXX=SProd(N,C(1,iidx),Vectmp)
380     Continue
360   Continue


where DGEMV is a typical BLAS Level 2 subroutine and function sprod carries out
Code: Select all
XXX = XXX + C(n,iidx)*Vectmp(n)
loveislonely
 
Posts: 31
Joined: Wed Aug 20, 2008 11:32 am


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 14 guests