Improving performance

General OpenMP discussion

Improving performance

Postby Gio » Thu Feb 16, 2012 8:10 am


I am currently working on parallelizing a pretty large code (fortran 95). So far, it's all working fine, the only problem is that, while running on 100% on one CPU, on four CPU's the program only runs on 340%.

I am totally new to parallel programming, so I was hoping you could give me tips on how to improve the performance.
(Of course, I'm also thankful for hints on what to read about this)

The general structure of the code is:

Code: Select all
DO a=a_start,a_end
   DO b=b_start,b_end
      DO c=ci_start,c_end

!$OMP PARALLEL DO FIRSTPRIVATE(bunch of data for iteration) LASTPRIVATE(more variables)&
         DO d=d_start,d_end
            //iteration that takes up most of computing time
            //write obtained data into files


Since there sometimes are only 1-2 values of a, b and c, but always lots of (~100) loop cycles for d, I chose
to use OMP on the innerest DO loop - was this a stupid idea? Would it bring much of an improvement to
only or also parallelize the outer loops?

Could the critical section be the problem? I could move that one into the serial section...

Thanks for any help!


Re: Improving performance

Postby MarkB » Fri Feb 17, 2012 3:08 am

I think the problem may be that you are doing lots of fairly small I/O operations inside the parallel loop: it may indeed be better just to store the data and write it all out after the parallel region.

Are you sure that there is no significant amount of time spent in sequential code? It might be useful to use omp_get_wtime() to measure the execution time of the whole code and just the parallel region. This will also give you some idea as to whether you need to increase the granularity by parallelising additional loops.
Posts: 746
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 4 guests