Skip to content

Commit

Permalink
Clean up Thrust includes. (#4675)
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

I opened a PR rapidsai/cudf#10489 that updates cuDF to Thrust 1.16. Notably, 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 spoke with @robertmaynard and he recommended making similar changes to clean up includes ("include what we use," in essence) to make sure we have compatibility with future versions of Thrust across all RAPIDS libraries.

This changeset also removes dependence on `thrust/detail` headers.

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - William Hicks (https://github.com/wphicks)

URL: #4675
  • Loading branch information
bdice authored Jul 7, 2022
1 parent d1bc755 commit 892558b
Show file tree
Hide file tree
Showing 53 changed files with 193 additions and 26 deletions.
1 change: 1 addition & 0 deletions cpp/src/arima/batched_arima.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <vector>

#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/fill.h>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
Expand Down
1 change: 1 addition & 0 deletions cpp/src/arima/batched_kalman.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <cuml/tsa/batched_kalman.hpp>

#include <cub/cub.cuh>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>

Expand Down
5 changes: 4 additions & 1 deletion cpp/src/dbscan/corepoints/compute.cuh
Original file line number Diff line number Diff line change
@@ -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 @@ -18,6 +18,9 @@

#include <raft/handle.hpp>

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

namespace ML {
namespace Dbscan {
namespace CorePoints {
Expand Down
5 changes: 5 additions & 0 deletions cpp/src/dbscan/runner.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@

#include <label/classlabels.cuh>

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

#include <cstddef>

namespace ML {
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/decisiontree/batched-levelalgo/kernels/quantiles.cu
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
#include "../quantiles.cuh"

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

namespace ML {
namespace DT {

Expand Down
5 changes: 5 additions & 0 deletions cpp/src/explainer/tree_shap.cu
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
#include <raft/span.hpp>
#include <rmm/device_uvector.hpp>
#include <thrust/device_ptr.h>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/memory.h>
#include <treelite/tree.h>
#include <type_traits>
#include <variant>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/fil/fil.cu
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ void check_params(const forest_params_t* params, bool dense)
ASSERT(params->blocks_per_sm >= 0, "blocks_per_sm must be nonnegative");
ASSERT(params->n_items >= 0, "n_items must be non-negative");
ASSERT(params->threads_per_tree > 0, "threads_per_tree must be positive");
ASSERT(thrust::detail::is_power_of_2(params->threads_per_tree),
ASSERT((params->threads_per_tree & (params->threads_per_tree - 1)) == 0,
"threads_per_tree must be a power of 2");
ASSERT(params->threads_per_tree <= FIL_TPB,
"threads_per_tree must not "
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/genetic/fitness.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <thrust/device_vector.h>
#include <thrust/functional.h>
#include <thrust/iterator/permutation_iterator.h>
#include <thrust/memory.h>
#include <thrust/scan.h>
#include <thrust/sequence.h>
#include <thrust/sort.h>
#include <thrust/transform.h>
Expand Down
5 changes: 5 additions & 0 deletions cpp/src/glm/qn/glm_base.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#include <raft/linalg/map_then_reduce.hpp>
#include <raft/linalg/matrix_vector_op.hpp>
#include <raft/stats/mean.hpp>

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

#include <vector>

namespace ML {
Expand Down
8 changes: 8 additions & 0 deletions cpp/src/hdbscan/condensed_hierarchy.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@
#include <raft/sparse/convert/csr.hpp>
#include <raft/sparse/op/sort.hpp>

#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/extrema.h>
#include <thrust/functional.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/reduce.h>
#include <thrust/sort.h>
#include <thrust/transform.h>
#include <thrust/transform_reduce.h>
#include <thrust/tuple.h>

#include <cuml/cluster/hdbscan.hpp>

Expand Down
4 changes: 4 additions & 0 deletions cpp/src/hdbscan/detail/condense.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@

#include <cuml/cluster/hdbscan.hpp>

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

namespace ML {
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/hdbscan/detail/extract.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>

#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/extrema.h>
#include <thrust/for_each.h>
#include <thrust/reduce.h>
#include <thrust/sort.h>
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/hdbscan/detail/membership.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
#include <algorithm>

#include <thrust/execution_policy.h>
#include <thrust/fill.h>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/reduce.h>
#include <thrust/sort.h>
#include <thrust/transform.h>
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/hdbscan/detail/reachability.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
#include <cuml/neighbors/knn.hpp>
#include <raft/distance/distance.hpp>

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

namespace ML {
namespace HDBSCAN {
Expand Down
7 changes: 7 additions & 0 deletions cpp/src/hdbscan/detail/select.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@

#include <algorithm>

#include <thrust/copy.h>
#include <thrust/execution_policy.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/sort.h>
#include <thrust/transform.h>
#include <thrust/transform_reduce.h>
#include <thrust/tuple.h>

#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/hdbscan/detail/stabilities.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@
#include <algorithm>

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

#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
Expand Down
7 changes: 6 additions & 1 deletion cpp/src/hdbscan/detail/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@

#include "../condensed_hierarchy.cu"

#include <thrust/copy.h>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/functional.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/reduce.h>
#include <thrust/sort.h>
#include <thrust/transform.h>
#include <thrust/transform_reduce.h>
#include <thrust/tuple.h>

#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
Expand Down Expand Up @@ -186,4 +191,4 @@ void parent_csr(const raft::handle_t& handle,
}; // namespace Utils
}; // namespace detail
}; // namespace HDBSCAN
}; // namespace ML
}; // namespace ML
4 changes: 4 additions & 0 deletions cpp/src/hdbscan/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "detail/reachability.cuh"
#include <cuml/cluster/hdbscan.hpp>

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

namespace ML {
namespace HDBSCAN {

Expand Down
5 changes: 5 additions & 0 deletions cpp/src/hierarchy/pw_dist_graph.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@

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

#include <limits>

Expand Down
6 changes: 6 additions & 0 deletions cpp/src/kmeans/kmeans_mg_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#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>
#include <thrust/transform.h>

#include "common.cuh"
#include "sg_impl.cuh"

Expand Down
3 changes: 3 additions & 0 deletions cpp/src/kmeans/sg_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include <rmm/device_scalar.hpp>
#include <rmm/device_uvector.hpp>

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

namespace ML {

namespace kmeans {
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/pca/sign_flip_mg.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

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

#include <cstddef>

Expand Down
8 changes: 5 additions & 3 deletions cpp/src/randomforest/randomforest.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@

#pragma once

#include <raft/common/nvtx.hpp>

#include <decisiontree/batched-levelalgo/quantiles.cuh>
#include <decisiontree/decisiontree.cuh>
#include <decisiontree/treelite_util.h>

#include <metrics/scores.cuh>

#include <raft/common/nvtx.hpp>
#include <raft/cudart_utils.h>
#include <raft/random/permute.hpp>
#include <raft/random/rng.cuh>

#include <raft/cudart_utils.h>
#include <thrust/execution_policy.h>
#include <thrust/sequence.h>

#ifdef _OPENMP
#include <omp.h>
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/solver/lars_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include <rmm/device_uvector.hpp>
#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/extrema.h>
#include <thrust/fill.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/sequence.h>
#include <thrust/sort.h>
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/svm/linear.cu
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
#include <rmm/device_uvector.hpp>
#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/fill.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/tuple.h>

#include <glm/ols.cuh>
#include <glm/qn/qn.cuh>
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/svm/smosolver.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
#include <raft/cuda_utils.cuh>
#include <raft/cudart_utils.h>
#include <string>
#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/fill.h>
#include <thrust/iterator/constant_iterator.h>
#include <type_traits>

#include "kernelcache.cuh"
Expand Down
1 change: 1 addition & 0 deletions cpp/src/svm/svc_impl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <rmm/mr/device/per_device_resource.hpp>
#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/iterator/counting_iterator.h>

namespace ML {
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/svm/workingset.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
#include <thrust/device_ptr.h>
#include <thrust/iterator/permutation_iterator.h>

#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/execution_policy.h>
#include <thrust/iterator/permutation_iterator.h>

#include <cub/cub.cuh>
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/tsne/barnes_hut_tsne.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <raft/cudart_utils.h>
#include <raft/linalg/eltwise.hpp>

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

namespace ML {
namespace TSNE {

Expand Down
3 changes: 3 additions & 0 deletions cpp/src/tsne/distances.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>

#include <thrust/functional.h>
#include <thrust/transform_reduce.h>

namespace ML {
namespace TSNE {

Expand Down
4 changes: 4 additions & 0 deletions cpp/src/tsne/exact_kernels.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include <raft/cudart_utils.h>
#include <raft/linalg/eltwise.hpp>

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

#define restrict __restrict__

namespace ML {
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/tsne/exact_tsne.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include <cuml/common/logger.hpp>
#include <raft/cudart_utils.h>

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

namespace ML {
namespace TSNE {

Expand Down
Loading

0 comments on commit 892558b

Please sign in to comment.