Skip to content

Commit 5c8fefb

Browse files
AntonRydahlxevor11
authored andcommitted
Adding OpenMP Offloading Backend for C++ Parallel Algorithms Rebased
1 parent bb3f5e1 commit 5c8fefb

31 files changed

+4143
-2928
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ jobs:
158158
'generic-no-wide-characters',
159159
'generic-no-rtti',
160160
'generic-optimized-speed',
161+
'generic-pstl-openmp',
161162
'generic-static',
162163
'bootstrapping-build'
163164
]

libcxx/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,11 @@ option(LIBCXX_HAS_EXTERNAL_THREAD_API
300300
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
301301

302302
if (LIBCXX_ENABLE_THREADS)
303-
set(LIBCXX_PSTL_BACKEND "std_thread" CACHE STRING "Which PSTL backend to use")
303+
set(LIBCXX_PSTL_BACKEND_DEFAULT "std_thread")
304304
else()
305-
set(LIBCXX_PSTL_BACKEND "serial" CACHE STRING "Which PSTL backend to use")
305+
set(LIBCXX_PSTL_BACKEND_DEFAULT "serial")
306306
endif()
307+
set(LIBCXX_PSTL_BACKEND "${LIBCXX_PSTL_BACKEND_DEFAULT}" CACHE STRING "Select the PSTL backend to use. Valid values are serial, std-thread, libdispatch, openmp. Default: ${LIBCXX_PSTL_BACKEND_DEFAULT}")
307308

308309
# Misc options ----------------------------------------------------------------
309310
# FIXME: Turn -pedantic back ON. It is currently off because it warns
@@ -552,6 +553,11 @@ function(cxx_add_basic_build_flags target)
552553
endif()
553554
endif()
554555
target_compile_options(${target} PUBLIC "${LIBCXX_ADDITIONAL_COMPILE_FLAGS}")
556+
557+
# If the PSTL backend depends on OpenMP, we must enable the OpenMP tool chain
558+
if (LIBCXX_PSTL_BACKEND STREQUAL "openmp")
559+
target_add_compile_flags_if_supported(${target} PUBLIC -fopenmp)
560+
endif()
555561
endfunction()
556562

557563
# Exception flags =============================================================
@@ -784,6 +790,8 @@ elseif(LIBCXX_PSTL_BACKEND STREQUAL "std_thread")
784790
config_define(1 _LIBCPP_PSTL_BACKEND_STD_THREAD)
785791
elseif(LIBCXX_PSTL_BACKEND STREQUAL "libdispatch")
786792
config_define(1 _LIBCPP_PSTL_BACKEND_LIBDISPATCH)
793+
elseif (LIBCXX_PSTL_BACKEND STREQUAL "openmp")
794+
config_define(1 _LIBCPP_PSTL_BACKEND_OPENMP)
787795
else()
788796
message(FATAL_ERROR "LIBCXX_PSTL_BACKEND is set to ${LIBCXX_PSTL_BACKEND}, which is not a valid backend.
789797
Valid backends are: serial, std_thread and libdispatch")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(LIBCXX_PSTL_BACKEND openmp CACHE STRING "")

0 commit comments

Comments
 (0)