Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
946b536
Add HPX backend to cmake
K-ballo Feb 20, 2025
003c157
Add HPX to cmake presets
K-ballo Feb 20, 2025
82db3f1
Implement basic backend
K-ballo Feb 27, 2025
17ab8a7
Add HPX to docs
K-ballo Feb 27, 2025
35b9881
Merge pull request #1 from STEllAR-GROUP/add-dummy-backend
hkaiser Feb 27, 2025
5876e7e
Impl reduce
K-ballo Mar 20, 2025
5b5e932
Comment on hpx_main usage
K-ballo Mar 20, 2025
37c1347
Merge pull request #2 from STEllAR-GROUP/impl-reduce
hkaiser Mar 24, 2025
e6c0d9e
Impl to_hpx_execution_policy helper detail
K-ballo Apr 4, 2025
429e184
Test rebinding hpx execution policies
K-ballo Apr 6, 2025
1efbd2a
Add remaining execution policies
K-ballo Apr 13, 2025
a406f14
Add and use test sync executor for rebinding tests
K-ballo May 2, 2025
b9af41a
Merge pull request #3 from STEllAR-GROUP/shadow-execution-policies
hkaiser May 2, 2025
ee3e190
Fix typo
K-ballo May 23, 2025
8d07266
Start HPX runtime globally
K-ballo Apr 14, 2025
55fb45c
Store command line arguments
K-ballo May 15, 2025
408e5b9
Merge pull request #4 from STEllAR-GROUP/runtime-start
hkaiser Jun 9, 2025
7da4f56
Impl transform/transform_reduce
K-ballo Apr 28, 2025
6998296
Use transparent function wrapper
K-ballo May 8, 2025
6e4932d
Test transform/transform_reduce with HPX policies
K-ballo May 8, 2025
e80ab22
Merge pull request #5 from STEllAR-GROUP/impl-transform
hkaiser Jun 10, 2025
cae21ea
Run HPX algorithms as HPX thread
K-ballo Jun 10, 2025
4033b60
Merge pull request #7 from STEllAR-GROUP/run-as-hpx-thread
hkaiser Jun 18, 2025
6c5483f
impl find for hpx backend
weilewei Jul 27, 2025
e4d2d23
use thrust type traits
weilewei Jul 27, 2025
05eb401
add other hpx exec policies for testing
weilewei Jul 28, 2025
6f0dc93
wrap pred
weilewei Jul 29, 2025
01e0cbe
attemp to impl scan
weilewei Jul 31, 2025
f1f3bd7
WIP impl scan
weilewei Aug 6, 2025
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
2 changes: 2 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"THRUST_MULTICONFIG_ENABLE_DIALECT_CPP20": true,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_CPP": true,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_CUDA": true,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_HPX": true,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_OMP": true,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_TBB": true,
"cudax_ENABLE_HEADER_TESTING": true,
Expand Down Expand Up @@ -212,6 +213,7 @@
"THRUST_ENABLE_MULTICONFIG": true,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_CPP": true,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_CUDA": true,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_HPX": false,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_OMP": true,
"THRUST_MULTICONFIG_ENABLE_SYSTEM_TBB": true,
"THRUST_MULTICONFIG_ENABLE_DIALECT_CPP17": false,
Expand Down
4 changes: 2 additions & 2 deletions docs/cpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ be better served by unifying them into a single repository.
parallel algorithms to the C++ Standard Library. Thrust's high-level
interface greatly enhances programmer productivity while enabling performance
portability between GPUs and multicore CPUs via configurable backends that
allow using multiple parallel programming frameworks (such as CUDA, TBB, and
OpenMP).
allow using multiple parallel programming frameworks (such as CUDA, TBB, HPX
and OpenMP).

- `Cuda Experimental <https://nvidia.github.io/cccl/cudax/>`__
is a library of experimental features that are still in the design process.
Expand Down
2 changes: 1 addition & 1 deletion docs/cub/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ CUB and `Thrust <https://nvidia.github.io/cccl/thrust/>`_ share some
similarities in that they both provide similar device-wide primitives for CUDA.
However, they target different abstraction layers for parallel computing.
Thrust abstractions are agnostic of any particular parallel framework (e.g.,
CUDA, TBB, OpenMP, sequential CPU, etc.). While Thrust has a "backend"
CUDA, TBB, OpenMP, HPX, sequential CPU, etc.). While Thrust has a "backend"
for CUDA devices, Thrust interfaces themselves are not CUDA-specific and
do not explicitly expose CUDA-specific details (e.g., ``cudaStream_t`` parameters).

Expand Down
1 change: 1 addition & 0 deletions docs/repo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ doxygen_input = [
"../../thrust/thrust/random/*.h",
"../../thrust/thrust/system/*.h",
"../../thrust/thrust/system/cpp/pointer.h",
"../../thrust/thrust/system/hpx/pointer.h",
"../../thrust/thrust/system/omp/pointer.h",
"../../thrust/thrust/system/tbb/pointer.h",
"../../thrust/thrust/type_traits/*.h",
Expand Down
11 changes: 8 additions & 3 deletions docs/thrust/cmake_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ The CMake options are divided into these categories:
5. `TBB Specific CMake Options <#tbb-specific-cmake-options>`__ Options
that control TBB compilation. Only available when one or more
configurations targets the TBB system.
5. `HPX Specific CMake Options <#hpx-specific-cmake-options>`__ Options
that control HPX compilation. Only available when one or more
configurations targets the HPX system.

Generic CMake Options
---------------------
Expand Down Expand Up @@ -85,11 +88,11 @@ Generic CMake Options
Single Config CMake Options
---------------------------

- ``THRUST_HOST_SYSTEM={CPP, TBB, OMP}``
- ``THRUST_HOST_SYSTEM={CPP, TBB, OMP, HPX}``

- Selects the host system. Default: ``CPP``

- ``THRUST_DEVICE_SYSTEM={CUDA, TBB, OMP, CPP}``
- ``THRUST_DEVICE_SYSTEM={CUDA, TBB, OMP, HPX, CPP}``

- Selects the device system. Default: ``CUDA``

Expand All @@ -112,7 +115,7 @@ Multi Config CMake Options
- ``THRUST_MULTICONFIG_ENABLE_SYSTEM_XXXX={ON, OFF}``

- Toggle whether a specific system will be targeted.
- Possible values of ``XXXX`` are ``{CPP, CUDA, TBB, OMP}``
- Possible values of ``XXXX`` are ``{CPP, CUDA, TBB, HPX, OMP}``
- By default, only ``CPP`` and ``CUDA`` are enabled.

- ``THRUST_MULTICONFIG_WORKLOAD={SMALL, MEDIUM, LARGE, FULL}``
Expand All @@ -134,9 +137,11 @@ Multi Config CMake Options
Config Workloads Value Expense Note
======== =========== ========== ========= ============================
CPP/CUDA ``F L M S`` Essential Expensive Validates CUDA against CPP
CPP/HPX ``F L M S`` Essential Cheap Validates HPX against CPP
CPP/OMP ``F L M S`` Essential Cheap Validates OMP against CPP
CPP/TBB ``F L M S`` Essential Cheap Validates TBB against CPP
CPP/CPP ``F L M`` Important Cheap Tests CPP as device
HPX/HPX ``F L M`` Important Cheap Tests HPX as host
OMP/OMP ``F L M`` Important Cheap Tests OMP as host
TBB/TBB ``F L M`` Important Cheap Tests TBB as host
TBB/CUDA ``F L`` Important Expensive Validates TBB/CUDA interop
Expand Down
4 changes: 2 additions & 2 deletions lib/cmake/thrust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ on-demand by calls to `create_thrust_target`, or when explicitly requested via
As mentioned, the basic Thrust interface is described by the `Thrust::Thrust`
target.

Each backend system (`CPP`, `CUDA`, `TBB`, `OMP`) is described by multiple
targets:
Each backend system (`CPP`, `CUDA`, `TBB`, `OMP`, `HPX`) is described by
multiple targets:

- `Thrust::${system}`
- Specifies an interface configured to build against all
Expand Down
60 changes: 57 additions & 3 deletions lib/cmake/thrust/thrust-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@
# [GLOBAL] # Optionally mark the target as GLOBAL
# )
#
# # Use a custom TBB, CUB, and/or OMP
# # Use a custom TBB, CUB, OMP, and/or HPX
# # (Note that once set, these cannot be changed. This includes COMPONENT
# # preloading and lazy lookups in thrust_create_target)
# find_package(Thrust REQUIRED)
# thrust_set_CUB_target(MyCUBTarget) # MyXXXTarget contains an existing
# thrust_set_TBB_target(MyTBBTarget) # interface to XXX for Thrust to use.
# thrust_set_OMP_target(MyOMPTarget)
# thrust_set_HPX_target(MyHPXTarget)
# thrust_create_target(ThrustWithMyCUB DEVICE CUDA)
# thrust_create_target(ThrustWithMyTBB DEVICE TBB)
# thrust_create_target(ThrustWithMyOMP DEVICE OMP)
# thrust_create_target(ThrustWithMyHPX DEVICE HPX)
#
# # Create target with HOST=CPP DEVICE=CUDA and some advanced flags set
# thrust_create_target(TargetName
Expand All @@ -71,6 +73,7 @@
# thrust_is_cuda_system_found(<var_name>)
# thrust_is_tbb_system_found(<var_name>)
# thrust_is_omp_system_found(<var_name>)
# thrust_is_hpx_system_found(<var_name>)
# thrust_is_cpp_system_found(<var_name>)
#
# # Define / update THRUST_${system}_FOUND flags in current scope
Expand All @@ -97,12 +100,12 @@ set(thrust_libcudacxx_version "${Thrust_VERSION}")

# Advertise system options:
set(THRUST_HOST_SYSTEM_OPTIONS
CPP OMP TBB
CPP HPX OMP TBB
CACHE INTERNAL "Valid Thrust host systems."
FORCE
)
set(THRUST_DEVICE_SYSTEM_OPTIONS
CUDA CPP OMP TBB
CUDA CPP HPX OMP TBB
CACHE INTERNAL "Valid Thrust device systems"
FORCE
)
Expand Down Expand Up @@ -290,6 +293,11 @@ function(thrust_is_omp_system_found var_name)
set(${var_name} ${${var_name}} PARENT_SCOPE)
endfunction()

function(thrust_is_hpx_system_found var_name)
thrust_is_system_found(HPX ${var_name})
set(${var_name} ${${var_name}} PARENT_SCOPE)
endfunction()

# Since components are loaded lazily, this will refresh the
# THRUST_${component}_FOUND flags in the current scope.
# Alternatively, check system states individually using the
Expand All @@ -300,6 +308,7 @@ macro(thrust_update_system_found_flags)
thrust_is_system_found(CUDA THRUST_CUDA_FOUND)
thrust_is_system_found(TBB THRUST_TBB_FOUND)
thrust_is_system_found(OMP THRUST_OMP_FOUND)
thrust_is_system_found(HPX THRUST_HPX_FOUND)
endmacro()

function(thrust_debug msg)
Expand Down Expand Up @@ -390,6 +399,9 @@ function(thrust_debug_internal_targets)
_thrust_debug_backend_targets(CUDA "CUB ${THRUST_CUB_VERSION}")
thrust_debug_target(CUB::CUB "${THRUST_CUB_VERSION}")
thrust_debug_target(libcudacxx::libcudacxx "${THRUST_libcudacxx_VERSION}")

_thrust_debug_backend_targets(HPX "${THRUST_HPX_VERSION}")
thrust_debug_target(HPX::hpx "${THRUST_HPX_VERSION}")
endfunction()

################################################################################
Expand Down Expand Up @@ -544,6 +556,24 @@ function(thrust_set_OMP_target omp_target)
endif()
endfunction()

# Use the provided hpx_target for the HPX backend. If Thrust::HPX already
# exists, this call has no effect.
function(thrust_set_HPX_target hpx_target)
if (NOT TARGET Thrust::HPX)
thrust_debug("Setting HPX target to ${hpx_target}" internal)
# Workaround cmake issue #20670 https://gitlab.kitware.com/cmake/cmake/-/issues/20670
set(THRUST_HPX_VERSION ${HPX_VERSION} CACHE INTERNAL
"HPX version used by Thrust"
FORCE
)
_thrust_declare_interface_alias(Thrust::HPX _Thrust_HPX)
target_link_libraries(_Thrust_HPX INTERFACE Thrust::Thrust ${hpx_target})
thrust_debug_target(${hpx_target} "${THRUST_HPX_VERSION}" internal)
thrust_debug_target(Thrust::HPX "${THRUST_HPX_VERSION}" internal)
_thrust_setup_system(HPX)
endif()
endfunction()

function(_thrust_find_CPP required)
if (NOT TARGET Thrust::CPP)
thrust_debug("Generating CPP targets." internal)
Expand Down Expand Up @@ -667,6 +697,28 @@ macro(_thrust_find_OMP required)
endif()
endmacro()

# This must be a macro instead of a function to ensure that backends passed to
# find_package(Thrust COMPONENTS [...]) have their full configuration loaded
# into the current scope. This provides at least some remedy for CMake issue
# #20670 -- otherwise variables like HPX_VERSION, etc won't be in the caller's
# scope.
macro(_thrust_find_HPX required)
if(NOT TARGET Thrust::HPX)
thrust_debug("Searching for HPX ${required}" internal)

# Try to find the CMake package that newer versions of HPX install themselves:
if (NOT TARGET HPX::hpx)
find_package(HPX CONFIG ${_THRUST_QUIET_FLAG})
endif()

if (TARGET HPX::hpx)
thrust_set_HPX_target(HPX::hpx)
else()
thrust_debug("HPX not found!" internal)
endif()
endif()
endmacro()

# This must be a macro instead of a function to ensure that backends passed to
# find_package(Thrust COMPONENTS [...]) have their full configuration loaded
# into the current scope. This provides at least some remedy for CMake issue
Expand All @@ -683,6 +735,8 @@ macro(_thrust_find_backend backend required)
_thrust_find_TBB("${required}")
elseif ("${backend}" STREQUAL "OMP")
_thrust_find_OMP("${required}")
elseif ("${backend}" STREQUAL "HPX")
_thrust_find_HPX("${required}")
else()
message(FATAL_ERROR "_thrust_find_backend: Invalid system: ${backend}")
endif()
Expand Down
1 change: 1 addition & 0 deletions thrust/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ message(STATUS "CPP system found? ${THRUST_CPP_FOUND}")
message(STATUS "CUDA system found? ${THRUST_CUDA_FOUND}")
message(STATUS "TBB system found? ${THRUST_TBB_FOUND}")
message(STATUS "OMP system found? ${THRUST_OMP_FOUND}")
message(STATUS "HPX system found? ${THRUST_HPX_FOUND}")

if (THRUST_ENABLE_HEADER_TESTING)
include(cmake/ThrustHeaderTesting.cmake)
Expand Down
12 changes: 6 additions & 6 deletions thrust/cmake/ThrustBuildTargetList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# - <prop_var> is any valid cmake identifier.
# - <target_name> is the name of a thrust target.
# - <prop> is one of the following:
# - HOST: The host system. Valid values: CPP, OMP, TBB.
# - DEVICE: The device system. Valid values: CUDA, CPP, OMP, TBB.
# - HOST: The host system. Valid values: CPP, HPX, OMP, TBB.
# - DEVICE: The device system. Valid values: CUDA, CPP, HPX, OMP, TBB.
# - DIALECT: The C++ dialect. Valid values: 11, 14, 17, 20.
# - PREFIX: A unique prefix that should be used to name all
# targets/tests/examples that use this configuration.
Expand All @@ -35,12 +35,12 @@
# `thrust_clone_target_properties(${my_thrust_test} ${some_thrust_target})`

define_property(TARGET PROPERTY _THRUST_HOST
BRIEF_DOCS "A target's host system: CPP, TBB, or OMP."
FULL_DOCS "A target's host system: CPP, TBB, or OMP."
BRIEF_DOCS "A target's host system: CPP, TBB, OMP, or HPX."
FULL_DOCS "A target's host system: CPP, TBB, OMP, or HPX."
)
define_property(TARGET PROPERTY _THRUST_DEVICE
BRIEF_DOCS "A target's device system: CUDA, CPP, TBB, or OMP."
FULL_DOCS "A target's device system: CUDA, CPP, TBB, or OMP."
BRIEF_DOCS "A target's device system: CUDA, CPP, TBB, OMP, or HPX."
FULL_DOCS "A target's device system: CUDA, CPP, TBB, OMP, or HPX."
)
define_property(TARGET PROPERTY _THRUST_DIALECT
BRIEF_DOCS "A target's C++ dialect: 11, 14, or 17."
Expand Down
3 changes: 3 additions & 0 deletions thrust/cmake/ThrustFindThrust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ function(_thrust_find_thrust_multiconfig)
if (THRUST_MULTICONFIG_ENABLE_SYSTEM_OMP)
list(APPEND req_systems OMP)
endif()
if (THRUST_MULTICONFIG_ENABLE_SYSTEM_HPX)
list(APPEND req_systems HPX)
endif()

find_package(Thrust REQUIRED CONFIG
NO_DEFAULT_PATH # Only check the explicit path in HINTS:
Expand Down
7 changes: 5 additions & 2 deletions thrust/cmake/ThrustMultiConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function(thrust_configure_multiconfig)
# Systems:
option(THRUST_MULTICONFIG_ENABLE_SYSTEM_CPP "Generate build configurations that use CPP." ON)
option(THRUST_MULTICONFIG_ENABLE_SYSTEM_CUDA "Generate build configurations that use CUDA." ON)
option(THRUST_MULTICONFIG_ENABLE_SYSTEM_HPX "Generate build configurations that use HPX." OFF)
option(THRUST_MULTICONFIG_ENABLE_SYSTEM_OMP "Generate build configurations that use OpenMP." OFF)
option(THRUST_MULTICONFIG_ENABLE_SYSTEM_TBB "Generate build configurations that use TBB." OFF)

Expand All @@ -57,9 +58,11 @@ function(thrust_configure_multiconfig)
# Config | Workloads | Value | Expense | Note
# ---------|-----------|------------|-----------|-----------------------------
# CPP/CUDA | F L M S | Essential | Expensive | Validates CUDA against CPP
# CPP/HPX | F L M S | Essential | Cheap | Validates HPX against CPP
# CPP/OMP | F L M S | Essential | Cheap | Validates OMP against CPP
# CPP/TBB | F L M S | Essential | Cheap | Validates TBB against CPP
# CPP/CPP | F L M | Important | Cheap | Tests CPP as device
# HPX/HPX | F L M | Important | Cheap | Tests HPX as host
# OMP/OMP | F L M | Important | Cheap | Tests OMP as host
# TBB/TBB | F L M | Important | Cheap | Tests TBB as host
# TBB/CUDA | F L | Important | Expensive | Validates TBB/CUDA interop
Expand All @@ -76,12 +79,12 @@ function(thrust_configure_multiconfig)
SMALL MEDIUM LARGE FULL
)
set(THRUST_MULTICONFIG_WORKLOAD_SMALL_CONFIGS
CPP_OMP CPP_TBB CPP_CUDA
CPP_OMP CPP_TBB CPP_CUDA CPP_HPX
CACHE INTERNAL "Host/device combos enabled for SMALL workloads." FORCE
)
set(THRUST_MULTICONFIG_WORKLOAD_MEDIUM_CONFIGS
${THRUST_MULTICONFIG_WORKLOAD_SMALL_CONFIGS}
CPP_CPP TBB_TBB OMP_OMP
CPP_CPP TBB_TBB OMP_OMP HPX_HPX
CACHE INTERNAL "Host/device combos enabled for MEDIUM workloads." FORCE
)
set(THRUST_MULTICONFIG_WORKLOAD_LARGE_CONFIGS
Expand Down
1 change: 1 addition & 0 deletions thrust/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,5 @@ endforeach()
add_subdirectory(cmake)
add_subdirectory(cpp)
add_subdirectory(cuda)
add_subdirectory(hpx)
add_subdirectory(omp)
18 changes: 18 additions & 0 deletions thrust/testing/hpx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
file(GLOB test_srcs
RELATIVE "${CMAKE_CURRENT_LIST_DIR}}"
CONFIGURE_DEPENDS
*.cu *.cpp
)

foreach(thrust_target IN LISTS THRUST_TARGETS)
thrust_get_target_property(config_device ${thrust_target} DEVICE)
if (NOT config_device STREQUAL "HPX")
continue()
endif()

foreach(test_src IN LISTS test_srcs)
get_filename_component(test_name "${test_src}" NAME_WLE)
string(PREPEND test_name "hpx.")
thrust_add_test(test_target ${test_name} "${test_src}" ${thrust_target})
endforeach()
endforeach()
Loading