Skip to content

Commit

Permalink
Use rmm::exec_policy instead of thrust::cuda::par.on + remove rmm::de…
Browse files Browse the repository at this point in the history
…vice_vector
  • Loading branch information
viclafargue committed Jul 5, 2021
1 parent eb1253a commit f6fe37a
Show file tree
Hide file tree
Showing 24 changed files with 118 additions and 117 deletions.
3 changes: 2 additions & 1 deletion cpp/include/raft/linalg/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/iterator/counting_iterator.h>
#include <rmm/exec_policy.hpp>

namespace raft {
namespace linalg {
Expand All @@ -40,7 +41,7 @@ void range(T *out, int start, int end, cudaStream_t stream) {
thrust::counting_iterator<int> first(start);
thrust::counting_iterator<int> last = first + (end - start);
thrust::device_ptr<T> ptr(out);
thrust::copy(thrust::cuda::par.on(stream), first, last, ptr);
thrust::copy(rmm::exec_policy(stream), first, last, ptr);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions cpp/include/raft/linalg/transpose.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#pragma once

#include <raft/linalg/cublas_wrappers.h>
#include <thrust/device_vector.h>
#include <raft/handle.hpp>
#include <rmm/exec_policy.hpp>

namespace raft {
namespace linalg {
Expand Down Expand Up @@ -60,7 +60,7 @@ void transpose(math_t *inout, int n, cudaStream_t stream) {
auto d_inout = inout;
auto counting = thrust::make_counting_iterator<int>(0);

thrust::for_each(thrust::cuda::par.on(stream), counting, counting + size,
thrust::for_each(rmm::exec_policy(stream), counting, counting + size,
[=] __device__(int idx) {
int s_row = idx % m;
int s_col = idx / m;
Expand Down
14 changes: 7 additions & 7 deletions cpp/include/raft/matrix/matrix.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
#include <cusolverDn.h>
#include <raft/cudart_utils.h>
#include <raft/linalg/cublas_wrappers.h>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <algorithm>
#include <cstddef>
#include <raft/cache/cache_util.cuh>
#include <raft/cuda_utils.cuh>
#include <raft/handle.hpp>
#include <rmm/exec_policy.hpp>

namespace raft {
namespace matrix {
Expand Down Expand Up @@ -64,7 +64,7 @@ void copyRows(const m_t *in, idx_t n_rows, idx_t n_cols, m_t *out,
idx_t size = n_rows_indices * n_cols;
auto counting = thrust::make_counting_iterator<idx_t>(0);

thrust::for_each(thrust::cuda::par.on(stream), counting, counting + size,
thrust::for_each(rmm::exec_policy(stream), counting, counting + size,
[=] __device__(idx_t idx) {
idx_t row = idx % n_rows_indices;
idx_t col = idx / n_rows_indices;
Expand Down Expand Up @@ -108,7 +108,7 @@ void truncZeroOrigin(m_t *in, idx_t in_n_rows, m_t *out, idx_t out_n_rows,
auto d_q_trunc = out;
auto counting = thrust::make_counting_iterator<idx_t>(0);

thrust::for_each(thrust::cuda::par.on(stream), counting, counting + size,
thrust::for_each(rmm::exec_policy(stream), counting, counting + size,
[=] __device__(idx_t idx) {
idx_t row = idx % m;
idx_t col = idx / m;
Expand All @@ -133,8 +133,8 @@ void colReverse(m_t *inout, idx_t n_rows, idx_t n_cols, cudaStream_t stream) {
auto d_q_reversed = inout;
auto counting = thrust::make_counting_iterator<idx_t>(0);

thrust::for_each(thrust::cuda::par.on(stream), counting,
counting + (size / 2), [=] __device__(idx_t idx) {
thrust::for_each(rmm::exec_policy(stream), counting, counting + (size / 2),
[=] __device__(idx_t idx) {
idx_t dest_row = idx % m;
idx_t dest_col = idx / m;
idx_t src_row = dest_row;
Expand All @@ -161,8 +161,8 @@ void rowReverse(m_t *inout, idx_t n_rows, idx_t n_cols, cudaStream_t stream) {
auto d_q_reversed = inout;
auto counting = thrust::make_counting_iterator<idx_t>(0);

thrust::for_each(thrust::cuda::par.on(stream), counting,
counting + (size / 2), [=] __device__(idx_t idx) {
thrust::for_each(rmm::exec_policy(stream), counting, counting + (size / 2),
[=] __device__(idx_t idx) {
idx_t dest_row = idx % m;
idx_t dest_col = idx / m;
idx_t src_row = (m - dest_row) - 1;
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/raft/sparse/convert/csr.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void sorted_coo_to_csr(const T *rows, int nnz, T *row_ind, int m,
thrust::device_ptr<T> row_counts_d =
thrust::device_pointer_cast(row_counts.data());
thrust::device_ptr<T> c_ind_d = thrust::device_pointer_cast(row_ind);
exclusive_scan(thrust::cuda::par.on(stream), row_counts_d, row_counts_d + m,
exclusive_scan(rmm::exec_policy(stream), row_counts_d, row_counts_d + m,
c_ind_d);
}

Expand Down
1 change: 0 additions & 1 deletion cpp/include/raft/sparse/coo.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <cusparse_v2.h>

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

#include <cuda_runtime.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "coo_mask_row_iterators.cuh"

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

namespace raft {
namespace sparse {
Expand Down
2 changes: 0 additions & 2 deletions cpp/include/raft/sparse/distance/utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include <cub/cub.cuh>

#include <rmm/device_vector.hpp>

namespace raft {
namespace sparse {
namespace distance {
Expand Down
3 changes: 2 additions & 1 deletion cpp/include/raft/sparse/linalg/add.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <raft/sparse/cusparse_wrappers.h>
#include <raft/cuda_utils.cuh>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>

#include <thrust/device_ptr.h>
#include <thrust/scan.h>
Expand Down Expand Up @@ -181,7 +182,7 @@ size_t csr_add_calc_inds(const int *a_ind, const int *a_indptr, const T *a_val,
thrust::device_ptr<int> row_counts_d =
thrust::device_pointer_cast(row_counts.data());
thrust::device_ptr<int> c_ind_d = thrust::device_pointer_cast(out_ind);
exclusive_scan(thrust::cuda::par.on(stream), row_counts_d, row_counts_d + m,
exclusive_scan(rmm::exec_policy(stream), row_counts_d, row_counts_d + m,
c_ind_d);

return cnnz;
Expand Down
5 changes: 3 additions & 2 deletions cpp/include/raft/sparse/linalg/symmetrize.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <raft/sparse/cusparse_wrappers.h>
#include <raft/cuda_utils.cuh>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>

#include <raft/sparse/op/sort.h>
#include <thrust/device_ptr.h>
Expand Down Expand Up @@ -293,8 +294,8 @@ void from_knn_symmetrize_matrix(const value_idx *restrict knn_indices,
thrust::device_pointer_cast(row_sizes.data());

// Rolling cumulative sum
thrust::exclusive_scan(thrust::cuda::par.on(stream), __row_sizes,
__row_sizes + n, __edges);
thrust::exclusive_scan(rmm::exec_policy(stream), __row_sizes, __row_sizes + n,
__edges);

// (5) Perform final data + data.T operation in tandem with memcpying
symmetric_sum<<<numBlocks, threadsPerBlock, 0, stream>>>(
Expand Down
Loading

0 comments on commit f6fe37a

Please sign in to comment.