PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

-Mconcur with -shared

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Christopher Hulbert



Joined: 01 Dec 2005
Posts: 76

PostPosted: Fri Dec 02, 2005 1:52 pm    Post subject: -Mconcur with -shared Reply with quote

If a shared library is created with -Mconcur at compile and link time, will the resulting shared object code run in multiple threads. For example a Matlab MEX function which is a shared library with exported function mexFunction. If I compile the code with -Mconcur will it use multiple threads, or will this only work when creating a program also linked as -Mconcur.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Mon Dec 05, 2005 5:55 pm    Post subject: Reply with quote

Hi Christopher,

This should work when compiling a shared library using -Mconcur will execute in parallel even if an application is not compiled or linked with -Mconcur (or even with the PGI compilers). You do have to remember to set the environment variable NCPUS. Though, I have not tried it myself and am not 100% positive. I'll try and get an example together to see if I can convince myself this does work as stated.

- Mat
Back to top
View user's profile
Christopher Hulbert



Joined: 01 Dec 2005
Posts: 76

PostPosted: Tue Dec 06, 2005 3:18 am    Post subject: Reply with quote

Yes, I too have verified this works.

Related to this is using -mp/-Mconcur in matlab. Matlab crashes when "unloading" the library. This only happens when NCPUS > 1. I've tried digging through the assembly output from objdump -d, but compiler generated PIC code was not covered in any of my assembly classes! I think this is a matlab problem as programs exhibit no behavior of this sort. I've reported this to the mathworks, but there response is that matlab is single-threaded and trying to use multi-threaded code produces undefined behavior. I can send the assembly code if desired. I'm sure the portland group doesn't really feel like looking into it either, but any thoughts on the matter would be appreciated. I've seen tremendous improvement with the parallel code in stand-alone programs, but we use a lot of matlab here and so I've been testing whether we can use openMP on our libraries. I've used the pthread library for parallelizing large loops, but openMP is much cleaner :)! Really impressed with PGI thus fard and will be recommending it despite the matlab problem.

Chris
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Wed Dec 07, 2005 4:28 pm    Post subject: Reply with quote

Hi Chris,

We don't have Matlab here so we wouldn't be able to recreate problem and just looking at the disassembly from objdump probably wouldn't help in this case. However, one thing you can try is to use the core file, if it exists, to determine what caused the crash and where it occurred.

Using pgdbg run: "pgdbg -core <core file> <exe name>"

Once loaded, type "where" in the command window to get a stack trace.

Also, thank you for the compliment!

- Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group