[clang-tools-extra] Adding Separate OpenMP Offloading Backend to `libcxx/include/__algorithm/pstl_backends` (PR #66968)

Louis Dionne via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 4 10:28:39 PDT 2023


================
@@ -807,6 +815,11 @@ else()
                        Valid backends are: serial, std_thread and libdispatch")
 endif()
 
+config_define_if(LIBCXX_ENABLE_GPU_OFFLOAD _LIBCPP_PSTL_GPU_OFFLOAD)
----------------
ldionne wrote:

I think we should do something like this instead:

```
if (LIBCXX_PSTL_BACKEND STREQUAL "serial")
  config_define(1 _LIBCPP_PSTL_CPU_BACKEND_SERIAL)
elseif (LIBCXX_PSTL_BACKEND STREQUAL "std-thread")
  config_define(1 _LIBCPP_PSTL_CPU_BACKEND_THREAD)
elseif (LIBCXX_PSTL_BACKEND STREQUAL "libdispatch")
  config_define(1 _LIBCPP_PSTL_CPU_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, libdispatch, and openmp.")
endif()
```

Then, the `LIBCXX_ENABLE_GPU_OFFLOAD` variable doesn't have a purpose anymore. If you want, you could do the refactoring for existing pstl backends as a separate patch, but I don't mind doing it as part of this patch since it's simple. Your choice.

https://github.com/llvm/llvm-project/pull/66968


More information about the cfe-commits mailing list