Skip to content

Commit

Permalink
Replace thrust::min/max with cuda::std::min/max (#4871)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
seunghwak authored Jan 21, 2025
1 parent 8126990 commit a9c923b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cpp/tests/sampling/detail/nbr_sampling_validate.cu
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>

#include <cuda/std/functional>
#include <thrust/count.h>
#include <thrust/distance.h>
#include <thrust/equal.h>
Expand Down Expand Up @@ -275,7 +276,7 @@ bool validate_sampling_depth(raft::handle_t const& handle,
tuple_iter + d_distances.size(),
d_distances.begin(),
[] __device__(auto tuple) {
return thrust::min(thrust::get<0>(tuple), thrust::get<1>(tuple));
return cuda::std::min(thrust::get<0>(tuple), thrust::get<1>(tuple));
});
}
}
Expand Down
6 changes: 4 additions & 2 deletions cpp/tests/utilities/check_utilities.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024, NVIDIA CORPORATION.
* Copyright (c) 2019-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,8 @@
#include <raft/core/handle.hpp>
#include <raft/core/span.hpp>

#include <cuda/std/functional>

#include <numeric>
#include <type_traits>
#include <vector>
Expand Down Expand Up @@ -95,7 +97,7 @@ struct device_nearly_equal {
bool __device__ operator()(type_t lhs, type_t rhs) const
{
return std::abs(lhs - rhs) <
thrust::max(thrust::max(lhs, rhs) * threshold_ratio, threshold_magnitude);
cuda::std::max(thrust::max(lhs, rhs) * threshold_ratio, threshold_magnitude);
}
};

Expand Down

0 comments on commit a9c923b

Please sign in to comment.