## some problem with my first parallel loop (OpenMP)

General OpenMP discussion

### some problem with my first parallel loop (OpenMP)

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

dimension diag(19,il,jl), km2(0:il1,0:jl1),
* v(len), dz(-1:ilp,-1:jlp)
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

do j=1,jl
do i=1,il
if( km2(i,j) .GT. 0) then
* 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
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

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

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)

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

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

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

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.4531002398580319.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.9902775199152537.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)

Thank you for your answer! The problem was that used only one process.
In .bashrc was next line:
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

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

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)

Everything's OK. I understand.

p.s: This post could be close
centrinog1s