Skip to content

Adding Support for Offloading C++ standard algorithms #116869

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ jobs:
'generic-no-wide-characters',
'generic-no-rtti',
'generic-optimized-speed',
'generic-pstl-openmp',
'generic-static',
'bootstrapping-build'
]
Expand Down
12 changes: 10 additions & 2 deletions libcxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,11 @@ option(LIBCXX_HAS_EXTERNAL_THREAD_API
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)

if (LIBCXX_ENABLE_THREADS)
set(LIBCXX_PSTL_BACKEND "std_thread" CACHE STRING "Which PSTL backend to use")
set(LIBCXX_PSTL_BACKEND_DEFAULT "std_thread")
else()
set(LIBCXX_PSTL_BACKEND "serial" CACHE STRING "Which PSTL backend to use")
set(LIBCXX_PSTL_BACKEND_DEFAULT "serial")
endif()
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}")

# Misc options ----------------------------------------------------------------
# FIXME: Turn -pedantic back ON. It is currently off because it warns
Expand Down Expand Up @@ -552,6 +553,11 @@ function(cxx_add_basic_build_flags target)
endif()
endif()
target_compile_options(${target} PUBLIC "${LIBCXX_ADDITIONAL_COMPILE_FLAGS}")

# If the PSTL backend depends on OpenMP, we must enable the OpenMP tool chain
if (LIBCXX_PSTL_BACKEND STREQUAL "openmp")
target_add_compile_flags_if_supported(${target} PUBLIC -fopenmp)
endif()
endfunction()

# Exception flags =============================================================
Expand Down Expand Up @@ -784,6 +790,8 @@ elseif(LIBCXX_PSTL_BACKEND STREQUAL "std_thread")
config_define(1 _LIBCPP_PSTL_BACKEND_STD_THREAD)
elseif(LIBCXX_PSTL_BACKEND STREQUAL "libdispatch")
config_define(1 _LIBCPP_PSTL_BACKEND_LIBDISPATCH)
elseif (LIBCXX_PSTL_BACKEND STREQUAL "openmp")
config_define(1 _LIBCPP_PSTL_BACKEND_OPENMP)
else()
message(FATAL_ERROR "LIBCXX_PSTL_BACKEND is set to ${LIBCXX_PSTL_BACKEND}, which is not a valid backend.
Valid backends are: serial, std_thread and libdispatch")
Expand Down
1 change: 1 addition & 0 deletions libcxx/cmake/caches/Generic-pstl-openmp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(LIBCXX_PSTL_BACKEND openmp CACHE STRING "")
Loading
Loading