Skip to content

Commit

Permalink
Streamline OpenMP linkage.
Browse files Browse the repository at this point in the history
  • Loading branch information
breyerml committed Dec 5, 2024
1 parent ace2d49 commit a41c895
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ find_package(OpenMP 4.0 QUIET)
if (OpenMP_FOUND)
message(STATUS "Found OpenMP ${OpenMP_CXX_VERSION} to speed-up library utilities (like file parsing).")
set(PLSSVM_FOUND_OPENMP_FOR_UTILITY ON)
if (${CMAKE_CXX_COMPILER_ID} MATCHES "IntelLLVM")
target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC -fopenmp)
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
if (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
target_compile_options(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC -openmp:llvm -openmp:experimental)
else ()
target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC OpenMP::OpenMP_CXX)
Expand Down
15 changes: 10 additions & 5 deletions src/plssvm/backends/OpenMP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ set(PLSSVM_OPENMP_SOURCES
# set target properties
set_local_and_parent(PLSSVM_OPENMP_BACKEND_LIBRARY_NAME plssvm-OpenMP)
add_library(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} SHARED ${PLSSVM_OPENMP_SOURCES})
target_link_libraries(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} PRIVATE $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:OpenMP::OpenMP_CXX>)
# special command line options for MSVC:
# -openmp:llvm -> enables unsigned loop indexes in OpenMP parallel for loops
# -openmp:experimental -> enables OpenMP's SIMD instructions
target_compile_options(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-openmp:llvm -openmp:experimental>)

# link against OpenMP
if (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
# special command line options for MSVC:
# -openmp:llvm -> enables unsigned loop indexes in OpenMP parallel for loops
# -openmp:experimental -> enables OpenMP's SIMD instructions
target_compile_options(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} PRIVATE -openmp:llvm -openmp:experimental)
else ()
target_link_libraries(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} PRIVATE OpenMP::OpenMP_CXX)
endif ()

# additional compilation flags
target_compile_options(${PLSSVM_OPENMP_BACKEND_LIBRARY_NAME} PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Wconversion>)
Expand Down

0 comments on commit a41c895

Please sign in to comment.