General OpenMP discussion


Postby peter » Tue Apr 15, 2008 1:28 am


i want to parralelize a time-intensive loop in a very big program.
does openmp not support the default(private)-function?
because i read that it only supports default(shared|none) in c\c++.
the problem is that i access alot of global variables in the loop.
this variables i want to make private because i want that every thread has his own copy because i dont want some read-write-problems.
but its to many variables to write in a private(var, var, var,...).
how can i do?
does anyone know a possible solution?

greetings, peter

Re: default(private)

Postby ejd » Tue Apr 15, 2008 6:53 am

Unfortunately because C/C++ have globals such as errno, default(private) is not allowed. The only way to do what you want to do is to list each variable in the private clause.
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: default(private)

Postby ejd » Tue Apr 15, 2008 2:28 pm

I have another answer that I feel requires full disclosure. I have been trying to answer the forum questions as vendor non-specific as possible. That is because this forum is for OpenMP questions and not to try and sell people anything. However, in this case, there is a vendor specific addition to OpenMP that could help you. That is not to say that other vendors don't have something as well - I just don't know it if they do. I happen to work for the vendor that I am going to "promote" in this case.

That said, Sun Microsystems made an addition to the default clause. With the newer Sun compilers, you can say default(__auto) and it will try and figure out how the various variables in the construct should be scoped. If you also specify compiler commentary, the appropriate clauses (shared, private, etc) will appear with the list of variables. This can be cut out of the commentary and pasted into your code and then you can use any compiler that supports OpenMP. I don't know how well it would do with your code. With Fortran code we have seen cases where the user would have had to scope 100's of variables reduced down to where they only had to scope 6 variables. With C and C++ it is harder, because of pointer aliasing.

We had discussed adding this to the OpenMP spec, but it is not a feature that all compilers could support, because it requires dependency analysis (used for autoparallelizing). Features like this are tried by the various vendors to see if they are useful and should be something to consider adding to the OpenMP spec. At the time Sun added this feature a couple of years ago, no other vendor had it. There was a university that put it into their research compiler as well. Other vendors may now have a similar feature (and they are free to respond to your query as well).

The Sun compilers are free (support costs money) and run on Solaris and Linux. If you do try this, let me know how it works. We are always looking for ways to improve it.
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Re: default(private)

Postby peter » Tue Aug 05, 2008 1:40 am


thanks for ur fast answer.
hmmmmmmmmmm. i would like to try this but i am writung my thesis about multicore and 64-bit on windows vista.
so i cant use solaris or linux. i should use sth that i can plug in VS2005.
but i think that i will try to find all variables i use in the loop and put it in a private or lastprivate-clause.
thanks for ur help.



Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 9 guests