some problem with my first parallel loop (OpenMP)

General OpenMP discussion

some problem with my first parallel loop (OpenMP)

Postby centrinog1s » Wed Sep 17, 2008 6:34 am

I try to apply OpenMP for subroutine "multmatrix" with loop. What am I doing wrong?

SUBROUTINE multmatrix(diag,km2,V,dz,adz,il,jl,il1,jl1,ilp,jlp,len)
dimension diag(19,il,jl), km2(0:il1,0:jl1),
* v(len), dz(-1:ilp,-1:jlp)
dimension adz(-1:ilp,-1:jlp)
real*8 diag, v, dz, adz
m= 0
do j=1,jl
do i=1,il
if( km2(i,j) .GT. 0) then
m= m+1
dz(i,j)= v(m)
end if
end do
end do

!$OMP PARALLEL DO SHARED(adz,diag,dz,km2) PRIVATE(j,i)
do j=1,jl
do i=1,il
if( km2(i,j) .GT. 0) then
adz(i,j)=
* diag(1 ,i,j)*dz(i ,j-2) + diag(2 ,i,j)*dz(i+1,j-2)+
* diag(3 ,i,j)*dz(i+2,j-2) + diag(4 ,i,j)*dz(i-1,j-1)+
* diag(5 ,i,j)*dz(i ,j-1) + diag(6 ,i,j)*dz(i+1,j-1)+
* diag(7 ,i,j)*dz(i+2,j-1) + diag(8 ,i,j)*dz(i-2,j )+
* diag(9 ,i,j)*dz(i-1,j ) + diag(10,i,j)*dz(i ,j )+
* diag(11,i,j)*dz(i+1,j ) + diag(12,i,j)*dz(i+2,j )+
* diag(13,i,j)*dz(i-2,j+1) + diag(14,i,j)*dz(i-1,j+1)+
* diag(15,i,j)*dz(i ,j+1) + diag(16,i,j)*dz(i+1,j+1)+
* diag(17,i,j)*dz(i-2,j+2) + diag(18,i,j)*dz(i-1,j+2)+
* diag(19,i,j)*dz(i ,j+2)
else
adz(i,j)= 0.d0
end if
end do
end do
!$OMP END PARALLEL DO


I use 1 node with 4 Procs. Using OpenMP times greater than without OpenMP.
centrinog1s
 
Posts: 4
Joined: Wed Sep 17, 2008 5:52 am

Re: some problem with my first parallel loop (OpenMP)

Postby ejd » Thu Sep 18, 2008 7:39 am

You aren't giving me a lot to work with. What are the sizes of the arrays? What compiler (vendor and version number) are you using? What hardware are you running on? You say "1 node with 4 procs". Do you mean that you are using 1 chip with 4 processors that share cache?
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: some problem with my first parallel loop (OpenMP)

Postby centrinog1s » Thu Sep 18, 2008 11:05 am

this is some size of array: il~400, jl~500, kl~50. This subroutine be called very often(~200) and total time is about 10 second. I would like to improve total time in at least 2 times
cluster: 1 headnode Node 16 computational node

Headnode Node AltixXE240.
8 procs (two 4-procs Intel Xeon X5355@2.66ГГц).
operating system: SUSE Linux Enterprise Server 10 (x86_64).
software:
Intel Fortran Compiler 9.0 for Linux
Intel Fortran Compiler 10.1 for Linux
Intel MPI Library 3.1 for Linux
centrinog1s
 
Posts: 4
Joined: Wed Sep 17, 2008 5:52 am

Re: some problem with my first parallel loop (OpenMP)

Postby ejd » Fri Sep 19, 2008 11:56 am

I unfortunately do not have the environment you are using to try this out. All I can do is try it on another system and see if there is anything wrong with the OpenMP part. When I ran it on a Solaris system using the Sun Stdio C compiler I saw the following:
Code: Select all
% f90 -xO3 a.f90
% time a.out
time:  9.453100239858031
9.0u 0.0s 0:09 90% 0+0k 0+0io 0pf+0w

% f90 -xopenmp -xO3 a.f90
% setenv OMP_DYNAMIC FALSE
% setenv OMP_NUM_THREADS 4
% time a.out
time:  2.990277519915253
7.0u 0.0s 0:03 199% 0+0k 0+0io 0pf+0w

This is using your subroutine and calling it in a loop 200 time. The time measurement is being done around the loop for the value I am printing out and being done for the entire program for time (the only difference being that I printed the entire adz array when I was done). From this you can see that the elapsed time took about 9.5 seconds for the serial run and about 3 seconds for the OpenMP run using 4 threads. So I don't see the same problem that you do.

This would lead me to think that it has something to do with your environment. I would try a performance analysis tool on the code to see what the bottle neck is. Sorry that I can not be of more help.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: some problem with my first parallel loop (OpenMP)

Postby centrinog1s » Sat Sep 20, 2008 8:54 pm

Thank you for your answer! The problem was that used only one process.
In .bashrc was next line:
export OMP_NUM_THREADS=1.
I have to fix it and parallel part of program worked fine. But I encountered the following problems, when i try to use OpenMP to other region of the program? the execution time of LOOP already with OpenMP Increases. this problem can be corrected? Or this is normal?
centrinog1s
 
Posts: 4
Joined: Wed Sep 17, 2008 5:52 am

Re: some problem with my first parallel loop (OpenMP)

Postby ejd » Sun Sep 21, 2008 6:18 am

What other sort OpenMP did you add? How are you measuring the increase? How much did it increase? It is possible that this could happen - but I would not say that it is normal.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: some problem with my first parallel loop (OpenMP)

Postby centrinog1s » Sun Sep 21, 2008 7:56 pm

Everything's OK. I understand.

p.s: This post could be close :)
centrinog1s
 
Posts: 4
Joined: Wed Sep 17, 2008 5:52 am


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 9 guests