From 123c4857c1b8ac7a38af65f5a2b1edace5a5fb2e Mon Sep 17 00:00:00 2001 From: Jacob Lambert Date: Mon, 27 Jul 2026 08:57:35 -0700 Subject: [PATCH 1/2] fix(monte_carlo_pi): migrate off hipcub iterators removed in CUB 3.0 hipCUB's CCCL 3.0 update (ROCm/rocm-libraries#9931) removed the CUB-style iterator headers (counting/constant/transform/discard) that Applications/monte_carlo_pi included, breaking its build against current hipCUB. Switch to the portable Thrust iterators, which is the replacement CUB 3.0 itself points to. Changes: - main.hip: replace hipcub::CountingInputIterator / TransformInputIterator with thrust::counting_iterator / thrust::make_transform_iterator; drop the unused discard_output_iterator include. hipcub::DeviceReduce::Sum is unchanged and accepts Thrust iterators. - CMakeLists.txt: find + link rocThrust on the AMD path (roc::rocthrust); NVIDIA gets the Thrust headers from the already-required CUDA Toolkit. --- Applications/monte_carlo_pi/CMakeLists.txt | 4 +++- Applications/monte_carlo_pi/main.hip | 13 ++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Applications/monte_carlo_pi/CMakeLists.txt b/Applications/monte_carlo_pi/CMakeLists.txt index 029b274913..7547764346 100644 --- a/Applications/monte_carlo_pi/CMakeLists.txt +++ b/Applications/monte_carlo_pi/CMakeLists.txt @@ -39,10 +39,12 @@ include("${CMAKE_CURRENT_LIST_DIR}/../../Common/ROCmPath.cmake") find_package(hipcub REQUIRED) find_package(hiprand REQUIRED) # Workaround for hipRAND, requires manual linking with backend. +# rocThrust provides the iterators on AMD; NVIDIA gets Thrust from CUDAToolkit. if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") find_package(CUDAToolkit REQUIRED) else() find_package(rocrand REQUIRED) + find_package(rocthrust REQUIRED) endif() add_executable(${example_name} main.hip) @@ -53,7 +55,7 @@ target_link_libraries(${example_name} PRIVATE hip::hipcub hip::hiprand) if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia") target_link_libraries(${example_name} PRIVATE CUDA::curand) else() - target_link_libraries(${example_name} PRIVATE roc::rocrand) + target_link_libraries(${example_name} PRIVATE roc::rocrand roc::rocthrust) endif() target_include_directories( ${example_name} diff --git a/Applications/monte_carlo_pi/main.hip b/Applications/monte_carlo_pi/main.hip index 8ea49de2ab..1b64dfd4fc 100644 --- a/Applications/monte_carlo_pi/main.hip +++ b/Applications/monte_carlo_pi/main.hip @@ -25,11 +25,12 @@ #include "hiprand_utils.hpp" #include -#include -#include -#include #include +// CUB 3.0 removed hipcub's CUB-style iterators; use portable Thrust ones. +#include +#include + #include #include @@ -66,13 +67,11 @@ float calculate_pi(int sample_count, float* d_data) // 4. Set up the input and output iterator for hipCUB's Sum. // Represents the samples' index. - auto input_counting = hipcub::CountingInputIterator(0); + auto input_counting = thrust::counting_iterator(0); // Converts the sample's index to a 0 or 1, indicating whether the sample lies within the disk. conversion_op convert_op(sample_count, d_data); - auto input = hipcub::TransformInputIterator( - input_counting, - convert_op); + auto input = thrust::make_transform_iterator(input_counting, convert_op); int* d_output{}; HIP_CHECK(hipMalloc(&d_output, sizeof(int))); From e79dcb0cb5f7ff21556900632d9df4325080d258 Mon Sep 17 00:00:00 2001 From: Jacob Lambert Date: Mon, 27 Jul 2026 10:09:00 -0700 Subject: [PATCH 2/2] Apply suggestion from @idubinov Co-authored-by: idubinov --- Applications/monte_carlo_pi/main.hip | 1 - 1 file changed, 1 deletion(-) diff --git a/Applications/monte_carlo_pi/main.hip b/Applications/monte_carlo_pi/main.hip index 1b64dfd4fc..e7d95c36c5 100644 --- a/Applications/monte_carlo_pi/main.hip +++ b/Applications/monte_carlo_pi/main.hip @@ -27,7 +27,6 @@ #include #include -// CUB 3.0 removed hipcub's CUB-style iterators; use portable Thrust ones. #include #include