Skip to content

Commit

Permalink
Add missing Thrust includes (#678)
Browse files Browse the repository at this point in the history
## Description

This PR cleans up some `#include`s for Thrust. This is meant to help ease the transition to Thrust 1.17 when that is updated in rapids-cmake.

## Context

Version 1.16 of Thrust reduced the number of internal header inclusions:
> [#1572](NVIDIA/thrust#1572) Removed several unnecessary header includes. Downstream projects may need to update their includes if they were relying on this behavior.

I am making similar changes across all RAPIDS libraries to clean up includes ("include what we use," in essence) to make sure we have compatibility with future versions of Thrust.

Authors:
  - Bradley Dice (https://github.com/bdice)
  - Corey J. Nolet (https://github.com/cjnolet)

Approvers:
  - Robert Maynard (https://github.com/robertmaynard)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #678
  • Loading branch information
bdice committed Jun 17, 2022
1 parent abf11be commit 5a7cf44
Show file tree
Hide file tree
Showing 34 changed files with 115 additions and 5 deletions.
7 changes: 7 additions & 0 deletions cpp/include/raft/cluster/detail/kmeans.cuh
Expand Up @@ -22,12 +22,19 @@

#include <cuda.h>
#include <thrust/binary_search.h>
#include <thrust/device_ptr.h>
#include <thrust/fill.h>
#include <thrust/find.h>
#include <thrust/functional.h>
#include <thrust/gather.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/memory.h>
#include <thrust/random.h>
#include <thrust/reduce.h>
#include <thrust/scan.h>
#include <thrust/sequence.h>
#include <thrust/sort.h>
#include <thrust/transform.h>

#include <raft/cuda_utils.cuh>
#include <raft/cudart_utils.h>
Expand Down
1 change: 1 addition & 0 deletions cpp/include/raft/core/span.hpp
Expand Up @@ -19,6 +19,7 @@
#include <cinttypes> // size_t
#include <cstddef> // std::byte
#include <raft/detail/span.hpp>
#include <thrust/distance.h>
#include <thrust/functional.h>
#include <thrust/host_vector.h> // __host__ __device__
#include <thrust/iterator/reverse_iterator.h>
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/raft/lap/detail/lap_functions.cuh
Expand Up @@ -32,6 +32,8 @@
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>

#include <thrust/execution_policy.h>
#include <thrust/fill.h>
#include <thrust/reduce.h>
#include <thrust/scan.h>

Expand Down
1 change: 1 addition & 0 deletions cpp/include/raft/lap/detail/lap_kernels.cuh
Expand Up @@ -29,6 +29,7 @@
#include <raft/cudart_utils.h>
#include <raft/handle.hpp>

#include <thrust/execution_policy.h>
#include <thrust/for_each.h>

#include <cstddef>
Expand Down
3 changes: 3 additions & 0 deletions cpp/include/raft/lap/lap.cuh
Expand Up @@ -31,6 +31,9 @@
#include <raft/handle.hpp>
#include <rmm/device_uvector.hpp>

#include <thrust/execution_policy.h>
#include <thrust/fill.h>

#include "detail/d_structs.h"
#include "detail/lap_functions.cuh"

Expand Down
3 changes: 3 additions & 0 deletions cpp/include/raft/lap/lap.hpp
Expand Up @@ -36,6 +36,9 @@
#include <raft/handle.hpp>
#include <rmm/device_uvector.hpp>

#include <thrust/execution_policy.h>
#include <thrust/fill.h>

#include "detail/d_structs.h"
#include "detail/lap_functions.cuh"

Expand Down
2 changes: 2 additions & 0 deletions cpp/include/raft/linalg/detail/add.cuh
Expand Up @@ -22,6 +22,8 @@
#include <raft/linalg/binary_op.cuh>
#include <raft/linalg/unary_op.cuh>

#include <thrust/functional.h>

namespace raft {
namespace linalg {
namespace detail {
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/raft/linalg/detail/eltwise.cuh
Expand Up @@ -21,6 +21,8 @@
#include <raft/linalg/binary_op.cuh>
#include <raft/linalg/unary_op.cuh>

#include <thrust/functional.h>

namespace raft {
namespace linalg {
namespace detail {
Expand Down
1 change: 1 addition & 0 deletions cpp/include/raft/matrix/detail/matrix.cuh
Expand Up @@ -22,6 +22,7 @@
#include <rmm/exec_policy.hpp>

#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>

#include <algorithm>
#include <cstddef>
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, NVIDIA CORPORATION.
* Copyright (c) 2021-2022, 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 @@ -21,6 +21,9 @@

#include <rmm/device_uvector.hpp>

#include <thrust/scan.h>
#include <thrust/transform.h>

namespace raft {
namespace sparse {
namespace distance {
Expand Down
Expand Up @@ -20,6 +20,9 @@

#include <cuco/static_map.cuh>

#include <thrust/copy.h>
#include <thrust/iterator/counting_iterator.h>

// this is needed by cuco as key, value must be bitwise comparable.
// compilers don't declare float/double as bitwise comparable
// but that is too strict
Expand Down
3 changes: 3 additions & 0 deletions cpp/include/raft/sparse/distance/detail/l2_distance.cuh
Expand Up @@ -31,6 +31,9 @@

#include <nvfunctional>

#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>

#include <algorithm>

namespace raft {
Expand Down
7 changes: 7 additions & 0 deletions cpp/include/raft/sparse/hierarchy/detail/agglomerative.cuh
Expand Up @@ -24,7 +24,14 @@

#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/extrema.h>
#include <thrust/fill.h>
#include <thrust/for_each.h>
#include <thrust/functional.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/sort.h>
#include <thrust/tuple.h>

#include <cstddef>

Expand Down
4 changes: 4 additions & 0 deletions cpp/include/raft/sparse/hierarchy/detail/connectivities.cuh
Expand Up @@ -29,6 +29,10 @@
#include <raft/sparse/hierarchy/common.h>
#include <raft/sparse/selection/knn_graph.cuh>

#include <thrust/iterator/zip_iterator.h>
#include <thrust/transform.h>
#include <thrust/tuple.h>

#include <limits>

namespace raft {
Expand Down
12 changes: 11 additions & 1 deletion cpp/include/raft/sparse/mst/detail/mst_solver_inl.cuh
Expand Up @@ -22,16 +22,26 @@
#include "utils.cuh"

#include <raft/cudart_utils.h>

#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>

#include <iostream>
#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/fill.h>
#include <thrust/functional.h>
#include <thrust/host_vector.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/reduce.h>
#include <thrust/sequence.h>
#include <thrust/sort.h>
#include <thrust/transform.h>
#include <thrust/transform_reduce.h>
#include <thrust/tuple.h>
#include <thrust/unique.h>

#include <iostream>

namespace raft {
namespace mst {
Expand Down
1 change: 1 addition & 0 deletions cpp/include/raft/sparse/op/detail/filter.cuh
Expand Up @@ -25,6 +25,7 @@
#include <rmm/exec_policy.hpp>

#include <thrust/device_ptr.h>
#include <thrust/reduce.h>
#include <thrust/scan.h>

#include <cuda_runtime.h>
Expand Down
3 changes: 3 additions & 0 deletions cpp/include/raft/sparse/op/detail/sort.h
Expand Up @@ -24,7 +24,10 @@
#include <rmm/exec_policy.hpp>

#include <thrust/device_ptr.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/scan.h>
#include <thrust/sort.h>
#include <thrust/tuple.h>

#include <cusparse_v2.h>

Expand Down
Expand Up @@ -28,8 +28,15 @@

#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>

#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/scan.h>
#include <thrust/sort.h>
#include <thrust/transform.h>
#include <thrust/tuple.h>

#include <cub/cub.cuh>

Expand Down
5 changes: 5 additions & 0 deletions cpp/include/raft/spatial/knn/detail/ball_cover.cuh
Expand Up @@ -42,10 +42,15 @@
#include <faiss/gpu/utils/Select.cuh>
#include <faiss/utils/Heap.h>

#include <thrust/fill.h>
#include <thrust/for_each.h>
#include <thrust/functional.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/reduce.h>
#include <thrust/sequence.h>
#include <thrust/sort.h>
#include <thrust/tuple.h>

namespace raft {
namespace spatial {
Expand Down
3 changes: 2 additions & 1 deletion cpp/include/raft/spatial/knn/detail/ball_cover/common.cuh
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, NVIDIA CORPORATION.
* Copyright (c) 2021-2022, 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 @@ -19,6 +19,7 @@
#include "../haversine_distance.cuh"
#include <cstdint>
#include <thrust/functional.h>
#include <thrust/tuple.h>

namespace raft {
namespace spatial {
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/raft/spatial/knn/detail/ball_cover/registers.cuh
Expand Up @@ -32,6 +32,8 @@
#include <faiss/gpu/utils/Select.cuh>
#include <faiss/utils/Heap.h>

#include <thrust/fill.h>

namespace raft {
namespace spatial {
namespace knn {
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/raft/spectral/detail/matrix_wrappers.hpp
Expand Up @@ -21,8 +21,10 @@
#include <raft/sparse/detail/cusparse_wrappers.h>
#include <rmm/device_uvector.hpp>

#include <thrust/execution_policy.h>
#include <thrust/fill.h>
#include <thrust/reduce.h>
#include <thrust/system/cuda/execution_policy.h>

#include <algorithm>

Expand Down
6 changes: 6 additions & 0 deletions cpp/include/raft/spectral/detail/spectral_util.cuh
Expand Up @@ -21,9 +21,15 @@
#include <raft/linalg/detail/cublas_wrappers.hpp>
#include <raft/spectral/matrix_wrappers.hpp>

#include <thrust/device_ptr.h>
#include <thrust/fill.h>
#include <thrust/for_each.h>
#include <thrust/functional.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/reduce.h>
#include <thrust/transform.h>
#include <thrust/tuple.h>

#include <algorithm>

Expand Down
4 changes: 4 additions & 0 deletions cpp/include/raft/stats/detail/adjusted_rand_index.cuh
Expand Up @@ -33,6 +33,10 @@
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>

#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/extrema.h>

namespace raft {
namespace stats {
namespace detail {
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/raft/stats/detail/batched/silhouette_score.cuh
Expand Up @@ -22,6 +22,8 @@
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/device_vector.h>
#include <thrust/fill.h>
#include <thrust/reduce.h>

namespace raft {
namespace stats {
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/raft/stats/detail/contingencyMatrix.cuh
Expand Up @@ -20,6 +20,8 @@
#include <raft/cudart_utils.h>

#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/extrema.h>
#include <thrust/reduce.h>

#include <cub/cub.cuh>
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/raft/stats/detail/scores.cuh
Expand Up @@ -26,7 +26,9 @@
#include <raft/stats/mean.cuh>
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>
#include <thrust/count.h>
#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/reduce.h>

#define N_THREADS 512
Expand Down
1 change: 1 addition & 0 deletions cpp/test/linalg/reduce.cuh
Expand Up @@ -23,6 +23,7 @@
#include <rmm/device_uvector.hpp>

#include <thrust/device_ptr.h>
#include <thrust/memory.h>

namespace raft {
namespace linalg {
Expand Down
4 changes: 4 additions & 0 deletions cpp/test/matrix/matrix.cu
Expand Up @@ -21,6 +21,10 @@
#include <raft/random/rng.cuh>
#include <rmm/device_uvector.hpp>

#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/iterator/counting_iterator.h>

namespace raft {
namespace matrix {

Expand Down
2 changes: 2 additions & 0 deletions cpp/test/mdarray.cu
Expand Up @@ -23,8 +23,10 @@
#include <rmm/device_vector.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/sequence.h>

namespace {
namespace stdex = std::experimental;
Expand Down
6 changes: 5 additions & 1 deletion cpp/test/mst.cu
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, 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 Down Expand Up @@ -32,6 +32,10 @@

#include <bits/stdc++.h>

#include <thrust/execution_policy.h>
#include <thrust/memory.h>
#include <thrust/reduce.h>

#include <cstddef>
#include <vector>

Expand Down
3 changes: 2 additions & 1 deletion cpp/test/random/make_regression.cu
Expand Up @@ -16,6 +16,7 @@

#include <gtest/gtest.h>
#include <thrust/count.h>
#include <thrust/device_ptr.h>
#include <thrust/device_vector.h>

#include "../test_utils.h"
Expand Down Expand Up @@ -160,4 +161,4 @@ TEST_P(MakeRegressionTestD, Result)
}
INSTANTIATE_TEST_CASE_P(MakeRegressionTests, MakeRegressionTestD, ::testing::ValuesIn(inputsd_t));

} // end namespace raft::random
} // end namespace raft::random

0 comments on commit 5a7cf44

Please sign in to comment.