diff --git a/Applications/monte_carlo_pi/CMakeLists.txt b/Applications/monte_carlo_pi/CMakeLists.txt index 029b27491..754776434 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 8ea49de2a..e7d95c36c 100644 --- a/Applications/monte_carlo_pi/main.hip +++ b/Applications/monte_carlo_pi/main.hip @@ -25,11 +25,11 @@ #include "hiprand_utils.hpp" #include -#include -#include -#include #include +#include +#include + #include #include @@ -66,13 +66,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)));