Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error w/ open_mp backend #332

Open
bgranzow opened this issue Nov 20, 2019 · 4 comments
Open

Compilation error w/ open_mp backend #332

bgranzow opened this issue Nov 20, 2019 · 4 comments

Comments

@bgranzow
Copy link
Contributor

Many errors of the form:

In file included from /scratch/bngranz/nightly/jughead-openmp/src/omega_h/src/Omega_h_adj.cpp:7:0:
/scratch/bngranz/nightly/jughead-openmp/src/omega_h/src/Omega_h_for.hpp:42:0: error: ignoring #pragma omp parallel [-Werror=unknown-pragmas]
 #pragma omp parallel for

pop up with gcc/7.2.0 with the cmake command

/projects/sems/install/rhel6-x86_64/sems/utility/cmake/3.12.2/bin/cmake /scratch
/bngranz/nightly/jughead-openmp/src/omega_h -DCMAKE_INSTALL_PREFIX=/scratch/bngr
anz/nightly/jughead-openmp/install/omega_h -DCMAKE_PREFIX_PATH=";/projects/sems/
install/rhel6-x86_64/sems/utility/cmake/3.12.2" -DBUILD_SHARED_LIBS:BOOL=ON -DBU
ILD_TESTING:BOOL=ON -DOmega_h_USE_MPI:BOOL=ON -DOmega_h_USE_OpenMP:BOOL=ON

Here is the output from a file with make VERBOSE=1. Presumably -fopenmp was stripped out of the compile flags during one of the recent CMake changes?

[  1%] Building CXX object src/CMakeFiles/omega_h.dir/Omega_h_adj.cpp.o
cd /scratch/bngranz/nightly/jughead-openmp/build/omega_h/src && /projects/sems/install/rhel6-x86_64/sems/compiler/gcc/7.2.0/openmpi/1.10.1/bin/mpicxx  -Domega_h_EXPORTS -I/scratch/bngranz/nightly/jughead-openmp/src/omega_h/src -I/scratch/bngranz/nightly/jughead-openmp/build/omega_h/src -I/scratch/bngranz/nightly/jughead-openmp/src/omega_h/tpl  -fPIC   -W -Wall -Wextra -Werror -std=c++11 -o CMakeFiles/omega_h.dir/Omega_h_adj.cpp.o -c /scratch/bngranz/nightly/jughead-openmp/src/omega_h/src/Omega_h_adj.cpp
@bgranzow
Copy link
Contributor Author

This 7547cb2 commit fixed the issue.

@bgranzow
Copy link
Contributor Author

bgranzow commented Dec 3, 2019

At 44ed745

with gcc/7.2.0

linking of tests fails with the error:

[ 55%] Building CXX object src/CMakeFiles/hypercube_test.dir/hypercube_test.cpp.o
cd /scratch/bngranz/nightly/jughead-openmp/build/omega_h/src && /projects/sems/install/rhel6-x86_64/sems/compiler/gcc/7.2.0/openmpi/1.10.1/bin/mpicxx   -I/scratch/bngranz/nightly/jughead-openmp/src/omega_h/src -I/scratch/bngranz/nightly/jughead-openmp/build/omega_h/src  -fopenmp -W -Wall -Wextra -Werror -std=c++11 -o CMakeFiles/hypercube_test.dir/hypercube_test.cpp.o -c /scratch/bngranz/nightly/jughead-openmp/src/omega_h/src/hypercube_test.cpp
[ 56%] Linking CXX executable hypercube_test
cd /scratch/bngranz/nightly/jughead-openmp/build/omega_h/src && /projects/sems/install/rhel6-x86_64/sems/utility/cmake/3.12.2/bin/cmake -E cmake_link_script CMakeFiles/hypercube_test.dir/link.txt --verbose=1
/projects/sems/install/rhel6-x86_64/sems/compiler/gcc/7.2.0/openmpi/1.10.1/bin/mpicxx     CMakeFiles/hypercube_test.dir/hypercube_test.cpp.o  -o hypercube_test -Wl,-rpath,/scratch/bngranz/nightly/jughead-openmp/build/omega_h/src libomega_h.so /usr/lib64/libz.so 
libomega_h.so: undefined reference to `omp_get_thread_num'
libomega_h.so: undefined reference to `omp_get_num_threads'
libomega_h.so: undefined reference to `GOMP_atomic_end'
libomega_h.so: undefined reference to `GOMP_parallel'
libomega_h.so: undefined reference to `omp_get_max_threads'
libomega_h.so: undefined reference to `GOMP_task'
libomega_h.so: undefined reference to `GOMP_atomic_start'
libomega_h.so: undefined reference to `GOMP_taskwait'
libomega_h.so: undefined reference to `GOMP_barrier'
collect2: error: ld returned 1 exit status

I've tried adding a line like:

target_compile_options(${EXE_NAME} PUBLIC -fopenmp)

here but that didn't fix the issue. make VERBOSE=1 shows omega_h is built with -fopenmp, I think the command just doesn't get carried through to the link line, even though from reading the CMake documentation I think it is supposed to

@bgranzow bgranzow reopened this Dec 3, 2019
@a-jp
Copy link

a-jp commented Dec 10, 2019

Hi,

Seem to have a similar issue compiling with OpenMP support on OSX using llvm8 compilers (from macports, not stock compilers, so do include openmp support). If I add '-fopenmp' to 'CMAKE_CXX_FLAGS' all my linking errors go away. Not sure if this is related?

@penguinpee
Copy link

Apologies for replying to an old issue. Since I ran into this trying to build with Omega_h_USE_OpenMP, I thought I add to it here since it inspired my workaround.

If I add '-fopenmp' to 'CMAKE_CXX_FLAGS' all my linking errors go away. Not sure if this is related?

Since CMAKE_CXX_FLAGS is preset in our build environment, I didn't want to mess with that, instead I added

target_link_options(omega_h PUBLIC -fopenmp)

just below

target_compile_options(omega_h PUBLIC -fopenmp)

to pass the flag to the linker as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants