C++ dll and OpenMP

General OpenMP discussion

C++ dll and OpenMP

Postby jeulogio » Fri Feb 15, 2013 10:09 am

Dear all,

I am a complete begginer working with OpenMP, so maybe I am going to ask a dumb question :D . I am developing a project based on an evolutionary algorithm, which calculate its fitness function value by means of a C++ .dll. Due to the calculation of the fitness function takes too much time, I thought I could use OpenMP to call the .dll as many times as CPU the machine has (8 cores) and make the calculation faster.

It seems to be possible using OpenMP, because the .dll is called from a for loop, and it is possible to use a #pragma for. My question is about the (static and dynamic allocated) variables used inside the .dll, I do not find information about if each thread calling the .dll has its own variables or they are shared and it could cause memory problems.

Thank you very much in advanced.

PS: If anyone knows a good tutorial/book/manual to learn OpenMP I will be really grateful if you could tell me which one. Thank you very much.
jeulogio
 
Posts: 2
Joined: Fri Feb 15, 2013 9:17 am

Re: C++ dll and OpenMP

Postby MarkB » Tue Feb 19, 2013 3:29 am

jeulogio wrote:
It seems to be possible using OpenMP, because the .dll is called from a for loop, and it is possible to use a #pragma for. My question is about the (static and dynamic allocated) variables used inside the .dll, I do not find information about if each thread calling the .dll has its own variables or they are shared and it could cause memory problems.


This depends entirely on whether the code in the .dll has been implemented in a way which is safe to call from multiple threads. Local variables inside called routines are private, but if there is any global state inside the .dll this could cause problems. You could simply just try it, but otherwise you would need to consult documentation or contact the developers.

jeulogio wrote:PS: If anyone knows a good tutorial/book/manual to learn OpenMP I will be really grateful if you could tell me which one. Thank you very much.


There are some links to book and tutorials here http://openmp.org/wp/resources
The Chapman, Jost, and Van Der Pas book is probably the best one, though it does not cover OpenMP 3.0 or 3.1 features.

Hope that helps,
Mark.
MarkB
 
Posts: 427
Joined: Thu Jan 08, 2009 10:12 am

Re: C++ dll and OpenMP

Postby jeulogio » Tue Feb 26, 2013 9:10 am

Thank you very much for the advices and the recommended book, MarkB.
jeulogio
 
Posts: 2
Joined: Fri Feb 15, 2013 9:17 am

Re: C++ dll and OpenMP

Postby MarkB » Tue Feb 26, 2013 9:39 am

You're very welcome!

Mark.
MarkB
 
Posts: 427
Joined: Thu Jan 08, 2009 10:12 am


Return to Using OpenMP

Who is online

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