Skip to content

Commit a9c923b

Browse files
authored
Replace thrust::min/max with cuda::std::min/max (#4871)
cuda::std::min/max is a more C++ standard conformant way of computing min/max of two values than thrust::min/max. We are using cuda::std::min/max in the src directory but thrust::min/max is still used in some files under the test directory. This PR replaces thrust::min/max calls in the test directory with cuda::std::min/max. Authors: - Seunghwa Kang (https://github.com/seunghwak) Approvers: - Chuck Hastings (https://github.com/ChuckHastings) - Joseph Nke (https://github.com/jnke2016) URL: #4871
1 parent 8126990 commit a9c923b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cpp/tests/sampling/detail/nbr_sampling_validate.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <rmm/device_scalar.hpp>
2929
#include <rmm/device_uvector.hpp>
3030

31+
#include <cuda/std/functional>
3132
#include <thrust/count.h>
3233
#include <thrust/distance.h>
3334
#include <thrust/equal.h>
@@ -275,7 +276,7 @@ bool validate_sampling_depth(raft::handle_t const& handle,
275276
tuple_iter + d_distances.size(),
276277
d_distances.begin(),
277278
[] __device__(auto tuple) {
278-
return thrust::min(thrust::get<0>(tuple), thrust::get<1>(tuple));
279+
return cuda::std::min(thrust::get<0>(tuple), thrust::get<1>(tuple));
279280
});
280281
}
281282
}

cpp/tests/utilities/check_utilities.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2024, NVIDIA CORPORATION.
2+
* Copyright (c) 2019-2025, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
2020
#include <raft/core/handle.hpp>
2121
#include <raft/core/span.hpp>
2222

23+
#include <cuda/std/functional>
24+
2325
#include <numeric>
2426
#include <type_traits>
2527
#include <vector>
@@ -95,7 +97,7 @@ struct device_nearly_equal {
9597
bool __device__ operator()(type_t lhs, type_t rhs) const
9698
{
9799
return std::abs(lhs - rhs) <
98-
thrust::max(thrust::max(lhs, rhs) * threshold_ratio, threshold_magnitude);
100+
cuda::std::max(thrust::max(lhs, rhs) * threshold_ratio, threshold_magnitude);
99101
}
100102
};
101103

0 commit comments

Comments
 (0)