openmp overhead

General OpenMP discussion

openmp overhead

Postby ariesli » Wed Apr 30, 2008 4:21 pm

Hi, I am new to OpenMP and have two questions:
1.
# pragma omp parallel for
for(...){ ...}

In this case, a parallel construct will be created, right? What is the overhead of creating this parallel construct? Does it depend on the size of the loop body?

2.

for() {
# pragma omp parallel for
for(...){ ...}
}

It is common that nested loops exist. In the example above, parallel construct will be created again and again while the loop is running. How can I minimize this overhead? Thank you.

Aries
ariesli
 
Posts: 1
Joined: Wed Apr 30, 2008 4:09 pm

Re: openmp overhead

Postby ejd » Wed Apr 30, 2008 5:00 pm

ariesli wrote:1.
# pragma omp parallel for
for(...){ ...}

In this case, a parallel construct will be created, right? What is the overhead of creating this parallel construct? Does it depend on the size of the loop body?

Yes - a parallel construct will be created. The overhead depends on the implementation. It shouldn't have anything to do with the size of the loop - other than you might not want to parallelize a loop if the amount of work being done is small. Otherwise, the parallel overhead may be more than just doing the work in the loop serially. There are some benchmarks around (like the epcc set) that try and measure the overhead of the various OpenMP constructs.

2.
for() {
# pragma omp parallel for
for(...){ ...}
}

It is common that nested loops exist. In the example above, parallel construct will be created again and again while the loop is running. How can I minimize this overhead? Thank you.

You are correct that there are numerous examples of nested loops. You usually want to try and parallelize the outer loop. However, there are times when the inner loop is the more beneficial to parallelize. There are techniques like loop interchange (where the loops are reordered) and loop collapse (where two or more loops are collapsed into one) that can be used. This is common enough that in the next OpenMP specification (Version 3.0), a collapse clause has been added.

Hope that helps. If you have a more specific example in mind, post it and maybe we can help.
ejd
 
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am


Return to Using OpenMP

Who is online

Users browsing this forum: Exabot [Bot] and 8 guests