Skip to content

Commit

Permalink
Overriding -fiopenmp and -Qiopenmp with -fopenmp and -Qopenmp (#978)
Browse files Browse the repository at this point in the history
Overriding  -fiopenmp with -fopenmp in cmake

The same with /Qiopenmp and /Qopenmp.  Due to minor correctness issues, reverting back to using -fopenmp and /Qopenmp for current versions of the icx/icpx compiler.

Signed-off-by: Dan Hoeflinger <[email protected]>
  • Loading branch information
danhoeflinger authored Jun 6, 2023
1 parent 7846339 commit c697fac
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,20 @@ elseif(ONEDPL_BACKEND MATCHES "^(omp)$")
find_package(OpenMP)
if (OpenMP_CXX_FOUND)
message(STATUS "Compilation for the host due to OpenMP backend.")
target_link_libraries(oneDPL INTERFACE OpenMP::OpenMP_CXX)
# Due to minor correctness issues with -fiopenmp / -Qiopenmp, we are using -fopenmp / -Qopenmp until they are corrected.
# Once correctness issues are resolved, we will limit this workaround to affected versions of specific compilers.
if (OpenMP_CXX_FLAGS MATCHES ".*-fiopenmp.*")
set(_openmp_flag -fopenmp)
elseif (OpenMP_CXX_FLAGS MATCHES ".*[-/]Qiopenmp.*")
set(_openmp_flag /Qopenmp)
endif()
if (_openmp_flag)
message(STATUS "Using ${_openmp_flag} for openMP")
target_compile_options(oneDPL INTERFACE ${_openmp_flag})
target_link_libraries(oneDPL INTERFACE ${_openmp_flag})
else()
target_link_libraries(oneDPL INTERFACE OpenMP::OpenMP_CXX)
endif()
target_compile_definitions(oneDPL INTERFACE
ONEDPL_USE_TBB_BACKEND=0
ONEDPL_USE_DPCPP_BACKEND=0
Expand Down
15 changes: 14 additions & 1 deletion cmake/templates/oneDPLConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,20 @@ if (EXISTS "${_onedpl_headers}")
elseif (OpenMP_CXX_FOUND)
set(ONEDPL_PAR_BACKEND openmp)
message(STATUS "oneDPL: ONEDPL_PAR_BACKEND=${ONEDPL_PAR_BACKEND}, disable oneTBB backend")
set_target_properties(oneDPL PROPERTIES INTERFACE_LINK_LIBRARIES OpenMP::OpenMP_CXX)
# Due to minor correctness issues with -fiopenmp / -Qiopenmp, we are using -fopenmp / -Qopenmp until they are corrected.
# Once correctness issues are resolved, we will limit this workaround to affected versions of specific compilers.
if (OpenMP_CXX_FLAGS MATCHES ".*-fiopenmp.*")
set(_openmp_flag -fopenmp)
elseif (OpenMP_CXX_FLAGS MATCHES ".*[-/]Qiopenmp.*")
set(_openmp_flag /Qopenmp)
endif()
if (_openmp_flag)
message(STATUS "oneDPL: Using ${_openmp_flag} for openMP")
set_target_properties(oneDPL PROPERTIES INTERFACE_COMPILE_OPTIONS ${_openmp_flag})
set_target_properties(oneDPL PROPERTIES INTERFACE_LINK_LIBRARIES ${_openmp_flag})
else()
set_target_properties(oneDPL PROPERTIES INTERFACE_LINK_LIBRARIES OpenMP::OpenMP_CXX)
endif()
set_property(TARGET oneDPL APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS ONEDPL_USE_TBB_BACKEND=0 ONEDPL_USE_OPENMP_BACKEND=1)
endif()
endif()
Expand Down

0 comments on commit c697fac

Please sign in to comment.