default (private|firstprivate) and C/C++

General OpenMP discussion

default (private|firstprivate) and C/C++

Postby Leo » Tue Mar 11, 2008 5:31 pm

I noticed that there is a difference between C/C++ and Fortran when specifying default() clause:

C/C++: default(shared | none)
Fortran: default(private | firstprivate | shared | none)

Any reason for the difference? :?

Posts: 4
Joined: Tue Mar 11, 2008 5:25 pm

Re: default (private|firstprivate) and C/C++

Postby jakub » Wed Mar 12, 2008 2:33 am

At least for private the reason is probably because in C/C++ you can avoid many private clauses by making the variables block scoped within the parallel construct.
#pragma omp parallel
int i, j, k;
is the most obvious way to write that the variables are private, no need to use private clauses. Fortran doesn't have block scope variables, and default(private) helps
if the majority of variables needs to be private.
Posts: 74
Joined: Fri Oct 26, 2007 3:19 am

Re: default (private|firstprivate) and C/C++

Postby ejd » Wed Mar 12, 2008 5:48 am

This question comes up quite often and we have had to try and go back and understand the reasoning for the decision. One reason for it Jakub has outlined - it is not needed as much in C/C++. Another reason, is because of globals like errno.
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Return to Using OpenMP

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests