You are not logged in.
Program using OpenMP will spawn multiple processes (seen in htop) but only utilizes one logical core. Not sure what is going on here, this works fine on a couple Debian based systems.
Using CMake, some relevant lines from CMakeLists:
set(CMAKE_CXX_FLAGS "-O3 -DBOOST_LOG_DYN_LINK -fopenmp")
find_package(OpenMP)
if(Open_MP_CXX_FOUND)
target_link_libraries(MyTarget PUBLIC OpenMP::OpenMP_CXX)
endif()The OpenMP usage is dead simple, just a single
#pragma omp parallel forover a vector.
I tried setting some environmental variables based on others' suggestions, here is what I've tried:
$ echo $GOMP_CPU_AFFINITY
0 1 2 3 4 5 6 7
$ echo $OMP_NUM_THREADS
8
$ echo $OMP_PROC_BIND
trueOffline
This belongs more to stackoverflow, but hey, let us try. I am surprised about the syntax in C++. In fortran you need to declare private and shared variables (after all openMP is for share memory) as well as the number of threads you want to use. It would go something like this:
$OMP PARALLEL PRIVATE(private variables), SHARED(shared variables), NUM_THREADS(number of threads)
$OMP DO SCHEDULE (static or dynamic)
DO
whatever
ENDDO
$OMP END PARALLELOffline
Yeah, it's a little different with C++ but similar, and quite easy to use. To be honest I would prefer not to use it, but I was pushed to use it by a professor in the group, although it may get rewritten at some point.
The reason I posted here is because my issue is Arch specific. Everything works as expected on other distros. I suspect that I am missing something quite simple here.
Offline
I see. Well I am running arch and openMP with fortran90 and it can use all of my cpus, so I am not sure about being arch specific ... just out of curiosity: is the loop you are trying to parallelize nested within a loop that is already parallelized ? In that case you should do:
setenv OMP_NESTED trueOtherwise it will not run in parallel even if your C++ syntax is flawless.
Offline