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

OPENMP not working #4

Closed
htot opened this issue May 5, 2022 · 2 comments
Closed

OPENMP not working #4

htot opened this issue May 5, 2022 · 2 comments

Comments

@htot
Copy link

htot commented May 5, 2022

BASE64_WITH_OPENMP seems to do nothing, I think because in here is written BASE64_WITH_OpenMP.

You can easily see that with BASE64_WITH_OPENMP=1 there is no change in encoding speed. Also running OMP_DISPLAY_ENV=VERBOSE bin/benchmark displays no info on the #threads used.

However, when I try to fix the line and rebuild, I get

[ 83%] Linking C executable ../bin/benchmark
/usr/bin/ld: ../libbase64.a(lib.c.o): in function `base64_encode_openmp._omp_fn.0':
lib.c:(.text+0x3e): undefined reference to `GOMP_single_start'
/usr/bin/ld: lib.c:(.text+0x46): undefined reference to `omp_get_num_threads'
/usr/bin/ld: lib.c:(.text+0x58): undefined reference to `GOMP_barrier'
/usr/bin/ld: lib.c:(.text+0x73): undefined reference to `omp_get_thread_num'
/usr/bin/ld: lib.c:(.text+0x125): undefined reference to `GOMP_barrier'
/usr/bin/ld: ../libbase64.a(lib.c.o): in function `base64_decode_openmp._omp_fn.0':
lib.c:(.text+0x21e): undefined reference to `GOMP_single_start'
/usr/bin/ld: lib.c:(.text+0x226): undefined reference to `omp_get_num_threads'
/usr/bin/ld: lib.c:(.text+0x238): undefined reference to `GOMP_barrier'
/usr/bin/ld: lib.c:(.text+0x252): undefined reference to `omp_get_thread_num'
/usr/bin/ld: lib.c:(.text+0x2d4): undefined reference to `GOMP_atomic_start'
/usr/bin/ld: lib.c:(.text+0x2e1): undefined reference to `GOMP_atomic_end'
/usr/bin/ld: lib.c:(.text+0x2e6): undefined reference to `GOMP_barrier'
/usr/bin/ld: ../libbase64.a(lib.c.o): in function `base64_encode':
lib.c:(.text+0x626): undefined reference to `GOMP_parallel'
/usr/bin/ld: ../libbase64.a(lib.c.o): in function `base64_decode':
lib.c:(.text+0x886): undefined reference to `GOMP_parallel'

Could it be libbase64 is being linked without openmp?

@htot
Copy link
Author

htot commented May 5, 2022

This fixes it:

CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 68d2ef2..454640b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -219,11 +219,12 @@ configure_file("${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in" "${CMAKE_CURRENT_BI
 
 ########################################################################
 # OpenMP Settings
-if (BASE64_WITH_OpenMP)
+if (BASE64_WITH_OPENMP)
     target_compile_options(base64
         PRIVATE
             ${OpenMP_C_FLAGS}
     )
+    target_link_libraries(base64 OpenMP::OpenMP_C)
 endif()
 
 ########################################################################

@BurningEnlightenment
Copy link
Owner

Good catch, thanks!

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

2 participants