views:

121

answers:

2

I am building a large project with a makefile that was originally built with icpc, and now I need to get it running with g++.

When it compiles the file that uses openmp, it uses the -c flag, and doesn't use any libraries, so it ends up being serial instead of openmp. All of the examples I am seeing aren't using this -c flag.

Is there some way to compile without linking, but using openmp?

edit:

I've been using the -lgomp flag(and the library is on the library path):

g++ -lgomp -c -w -O4 mainS.cpp
g++: -lgomp: linker input file unused because linking not done

Edit: my boss made several mistakes in the code, the makefile, and the documentation. Sorry to have wasted your time, at least it was less than the 5 hours I spend on it =/

A: 

Are you passing the flag to enable OpenMP (IIRC it's something like -fopenmp? If you don't chances are the compiler will ignore the OpenMP-related primitives and just produce serial code.

I don't think that -c (ie, compile only, don't like) has anything to do with your problem.

Timo Geusch
Adding the -fopenmp flag doesn't seem to have worked.
Jeremy
@Jeremy, I assume that you have checked that your version of g++ is built with OpenMP support?
Timo Geusch
it has the lgomp library on the path, if that is what you mean. Beyond that I am not sure how to check.
Jeremy
@Jeremy, IIRC OpenMP support consists of both support in the compiler for the openmp primitives and some library support, so you need both in order to be able to successfully use OpenMP.
Timo Geusch
Thanks for the help, the -fopenmp ended up doing the trick once the source and the makefile were altered.
Jeremy
A: 

Perhaps the documentation helps...

rubenvb
This doesn't seem to have worked, is there some way to tell if it is compiled with openmp support other than looking at top?
Jeremy
You can probably tell from the generated assembly, but I don't know anything about that. Someone else may be able to help you there. There's also the sanity check: http://stackoverflow.com/questions/1302368/how-to-tell-if-openmp-works-in-my-c-program
rubenvb