Adjust Your makefile [tips:openMP]

Adjust Your makefile [tips:openMP]

I didn't find any guidelines to state how to add the openMP libraries to your makefile, so here it is:
Add the openMP libraries to theLDLIBS in your makefile as follows: LDLIBS = -fopenmpAlso,don't forget to put your TeamID in the variable called "TEAM_ID" in your makefile.And also remember to put the makefile at the root in your zip file, with two folders, src folder [containing your source.cpp file], and obj folder.

17 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

When I do this, I get the following warning:

src/main.cpp:71:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]

Does anyone have the same problem or know what to do about it?

Are you sure you added the -fopenmp flag during the compilation process ?

I added -fopenmp to LDLIBS as described by amorabi and compiled by calling make. I didn't change anything else in the Makefile (except for the TEAM_ID).

-fopenmp (or just -openmp for the Intel compiler) doesn't really work as a library, let's say tbb.
Understand that on the current Makefile, LDFLAGS and LDLIBS only insert themselves on the Linker command, ie when compining the .o files into the executable.
But that means that the .o (object) files themselves never get to be compiled with openMP.

So what you need to do is insert -fopenmp into at least the FLAGS variable for the compiler, and perhaps LDFLAGS for the linker.

What I did was introduce a new variable MYFLAGS that gets inserted into all steps of the building process.

Hope it helps,

I've added -fopenmp now to both FLAGS and LDLIBS and now it works. Thanks a lot for your help!

what are the flags needed to use SSE instruction set please

if you are using gcc, SSE flags are:-msse-msse2-msse3-mssse3-msse4.1-msse4.2-msse4you can activate everything the compiling machine handle by using the flag -march=nativesource:

I have added it to FLAGS and LDLIBS and i ve gt thisIn file included from /usr/include/c++/4.6/bits/stl_algobase.h:65:0, from /usr/include/c++/4.6/bits/char_traits.h:41, from /usr/include/c++/4.6/ios:41, from /usr/include/c++/4.6/ostream:40, from /usr/include/c++/4.6/iostream:40, from src/main.cpp:1:...Where did you add -fopenmp exactly?Something like this:FLAGS ?= -std=c++0x -O3 -Wall $(GCC_SUPPFLAGS) -fopenmpLDFLAGS ?= -g -fopenmp (if i dont put here, i get i lot of warnings)LDLIBS = -fopenmp#example if using Intel Threading Building Blocks :LDLIBS = -ltbb -ltbbmalloc

Hi,I added -fopenmp only to the FLAGS and LDFLAGS, and it works fine. Something like this:FLAGS ?= -std=c++0x -O3 -Wall $(GCC_SUPPFLAGS) -fopenmpLDFLAGS ?= -g -fopenmpHope this helps!

there is another thread on this:

try this:
# using gcc :
FLAGS ?= -std=c++0x -O3 -fopenmp -Wall $(GCC_SUPPFLAGS)
LDLIBS = -fopenmp

I've tested it already, and it worked on their machine(in that other thread i've mentioned, i explain how i tested it)

does anyone know type of the error when using intel compiler icpc? when i use gcc machine can run my program, but when i comment gcc and uncoment icpc in Makefile, benschmark returns me an e-mail in which says that i have error during compilation. Has anyone encountered this problem? i also use tbb


atol and atoi are undefined in your main.cpp file.

Quoting Xavier Hallade (Intel)

atol and atoi are undefined in your main.cpp file.

I don't quite get this. They are in header stdlib or stdio.

have you simply include ?

If you have include that you only need to add -fopenmp when you compiled.
something like that : g++ -o run main.cpp -O3 -fopenmp -Wall
and if it work you can write in your Makefile

I use tbb :)

i didn't knew about atoi, but look at portability section on this link, about itoa: apparently it actually ain't c or c++ standard.

Accedere per lasciare un commento.