OpenMP + ACLIC

Dear all,
I use ROOT 5.26 on a Ubuntu machine with g++ 4.4.5
I’m trying to use also the OpenMP library to speed up my calculations. I encountered problems.
I saw that on
root.cern.ch/root/roottalk/roottalk10/1126.html
someone had similar problems

I tried to do the same on my machine. See the simple files in attachment

I changed the variables
root [0] TString cmd(gSystem->GetMakeSharedLib())
root [1] cmd.ReplaceAll(“g++”,“g++ -fopenmp”)
(class TString)“cd $BuildDir ; g++ -fopenmp -c $Opt -pipe -m64 -Wall -W -Woverloaded-virtual -fPIC -DR__HAVE_CONFIG -pthread $IncludePath $SourceFiles ; g++ -fopenmp $ObjectFiles -shared -Wl,-soname,$LibName.so -m64 -O2 -Wl,-rpath,/usr/local/lib/root $DepLibs -o $SharedLib”
root [2] cmd.ReplaceAll(“g++”,“g++ -fopenmp”)
root [3] gSystem->SetMakeSharedLib(cmd)

When I tried to compile it, I got:
root [3] .L PiOMP.C++
Info in TUnixSystem::ACLiC: creating shared library /home/flavio/Test/./PiOMP_C.so
Error: Function aligned(4) is not defined in current scope /usr/lib/gcc/x86_64-linux-gnu/4.4.5/include/omp.h:40:
Error: Symbol attribute is not defined in current scope /usr/lib/gcc/x86_64-linux-gnu/4.4.5/include/omp.h:40:
Error: Function aligned(sizeof(void*)) is not defined in current scope /usr/lib/gcc/x86_64-linux-gnu/4.4.5/include/omp.h:46:
Error: Symbol attribute is not defined in current scope /usr/lib/gcc/x86_64-linux-gnu/4.4.5/include/omp.h:46:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing /home/flavio/Test/./PiOMP_C_ACLiC_dict.cxx /home/flavio/Test/./PiOMP_C_ACLiC_dict.h !!!
Error: /usr/local/bin/rootcint: error loading headers…
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity
Info in : The compiler has not found any problem with your macro.
Probably your macro uses something rootcint can’t parse.
Check root.cern.ch/root/Cint.phtml?limitations for Cint’s limitations.

Please note that if I compile it outside ROOT everything works (!) with:
g++ -fopenmp main.cxx
./a.out

I get (8 core machine):
Hello, OpenMP!
Hello, OpenMP!
Hello, OpenMP!
Hello, OpenMP!
Hello, OpenMP!
Hello, OpenMP!
Hello, OpenMP!
Hello, OpenMP!
pi = 3.141592653589793

Many thanks for your help and time.
Flavio
PiOMP.C (728 Bytes)
main.cxx (52 Bytes)

Hi,

CINT cannto parse omp.h. Can you simply surround it by
#ifndef CINT
#include “omp.h”
#endif
such that CINT doesn’t see it?

Cheers, Axel.

Hi Axel,
it works!

Thank you again,
Flavio