Problem with an openMP and pthread program compiled with gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everybody!

Here is my problem : I wrote a c++ program on Linux which uses the pthread
library to handle several requests of several clients. Each request executes
an algo in which some parts, some loops, are parallelized with openmp (on 2
processors). I compile my program with gcc 4.3.
With one request, so with one tread created by pthread lib, there is no
problem, the execution is ok, and I have no problem with the openmp
directives. But, when I execute my code with several requests, a deadlock,
or a segmentation fault, occurs at execution, in the openmp part.
I have already searched for a solution on the web, and on this forum too, I
found some answers saying that there is a problem with gcc 4.2 and 4.3 and
openmp with multithreading, so I try with gcc 4.5 but it doesn't correct the
problem.
There is no error in my code, in the declarations of my variables, in the
openmp directives,... and I really think it is due to gcc because the code
works when I compile it with the intel c compiler.

More precisions on the problem :
I have simplified my code as far as possible (sorry if it is still too big)
to keep only the part where the problem occurs. Consequently, the program
does nothing so don't try to understand its goal :-D (normally it's an algo
to make some operations on images). I have put some comments in the code to
help, and I have precised where the problem occurs in Classe2.cpp.
I work on Linux (version debian 2.6.26 amd64) and compile with the lines at
the beginning of main.cpp. Other packages are necessary to make the code
works : 
-libmagick++,
-libgraphicsmagick++,
-graphicsmagick,
-CImg (http://cimg.sourceforge.net/download.shtml) : copy the CImg.h
downloaded file in the directory with my source files.

The source files:
http://old.nabble.com/file/p29173546/main.cpp main.cpp 
http://old.nabble.com/file/p29173546/Classe1.cpp Classe1.cpp 
http://old.nabble.com/file/p29173546/Classe1.h Classe1.h 
http://old.nabble.com/file/p29173546/Classe2.cpp Classe2.cpp 
http://old.nabble.com/file/p29173546/Classe2.h Classe2.h 
http://old.nabble.com/file/p29173546/Classe3.cpp Classe3.cpp 
http://old.nabble.com/file/p29173546/Classe3.h Classe3.h 

And the two images used:
http://old.nabble.com/file/p29173546/image1.jpg 

http://old.nabble.com/file/p29173546/image2.jpg 


Normally, with all of that, it would compile with no problem and you will be
able to test it :-).

I know there is a lot of things (big code, packages to install,... in
addition maybe I am not clear in my explanations %-|) but I would greatly
appreciate some help :-).
Thanks
-- 
View this message in context: http://old.nabble.com/Problem-with-an-openMP-and-pthread-program-compiled-with-gcc-tp29173546p29173546.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux