Skip to content

Commit ee94b00

Browse files
committed
Replace stream with res where possible
1 parent 760bc2e commit ee94b00

23 files changed

Lines changed: 49 additions & 61 deletions

File tree

cpp/include/raft/core/bitset.cuh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,14 @@ void bitset_repeat(raft::resources const& handle,
148148
index_t repeat_times)
149149
{
150150
if (src_bit_len == 0 || repeat_times == 0) return;
151-
auto stream = resource::get_cuda_stream(handle);
152151

153152
constexpr index_t bits_per_element = sizeof(bitset_t) * 8;
154153
const index_t total_bits = src_bit_len * repeat_times;
155154
const index_t output_size = (total_bits + bits_per_element - 1) / bits_per_element;
156155

157156
int threadsPerBlock = 128;
158157
int blocksPerGrid = (output_size + threadsPerBlock - 1) / threadsPerBlock;
159-
raft::launch_kernel(stream, blocksPerGrid, threadsPerBlock)(
158+
raft::launch_kernel(handle, blocksPerGrid, threadsPerBlock)(
160159
bitset_repeat_kernel, d_src, d_output, src_bit_len, repeat_times);
161160

162161
return;

cpp/include/raft/linalg/detail/transpose.cuh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ void transpose_half(raft::resources const& handle,
8989
const IndexType stride_out = 1)
9090
{
9191
if (n_cols == 0 || n_rows == 0) return;
92-
auto stream = resource::get_cuda_stream(handle);
9392

9493
int dev_id, sm_count;
9594

@@ -118,7 +117,7 @@ void transpose_half(raft::resources const& handle,
118117
dim3 grids(adjusted_grid_x, adjusted_grid_y);
119118

120119
if (stride_in > 1 || stride_out > 1) {
121-
raft::launch_kernel(stream, grids, blocks)(
120+
raft::launch_kernel(handle, grids, blocks)(
122121
transpose_half_kernel<IndexType, block_dim_x, block_dim_y>,
123122
n_rows,
124123
n_cols,
@@ -127,7 +126,7 @@ void transpose_half(raft::resources const& handle,
127126
stride_in,
128127
stride_out);
129128
} else {
130-
raft::launch_kernel(stream, grids, blocks)(
129+
raft::launch_kernel(handle, grids, blocks)(
131130
transpose_half_kernel<IndexType, block_dim_x, block_dim_y>,
132131
n_rows,
133132
n_cols,

cpp/include/raft/matrix/detail/shift.cuh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,19 @@ void shift_dispatch(raft::resources const& handle,
139139
size_t n_rows = in_out.extent(0);
140140
size_t n_cols = in_out.extent(1);
141141
size_t TPB = 256;
142-
auto stream = raft::resource::get_cuda_stream(handle);
143142

144143
if (shift_type == ShiftType::COL) {
145144
size_t num_blocks = static_cast<size_t>((n_rows + TPB) / TPB);
146145
if (shift_direction == ShiftDirection::TOWARDS_BEGINNING) {
147-
raft::launch_kernel(stream, num_blocks, TPB)(
146+
raft::launch_kernel(handle, num_blocks, TPB)(
148147
col_shift_towards_beginning<ValueT, fill_value, fill_type>,
149148
in_out.data_handle(),
150149
n_rows,
151150
n_cols,
152151
k,
153152
value);
154153
} else { // ShiftDirection::TOWARDS_END
155-
raft::launch_kernel(stream, num_blocks, TPB)(
154+
raft::launch_kernel(handle, num_blocks, TPB)(
156155
col_shift_towards_end<ValueT, fill_value, fill_type>,
157156
in_out.data_handle(),
158157
n_rows,
@@ -163,15 +162,15 @@ void shift_dispatch(raft::resources const& handle,
163162
} else { // ShiftType::ROW
164163
size_t num_blocks = static_cast<size_t>((n_cols + TPB) / TPB);
165164
if (shift_direction == ShiftDirection::TOWARDS_BEGINNING) {
166-
raft::launch_kernel(stream, num_blocks, TPB)(
165+
raft::launch_kernel(handle, num_blocks, TPB)(
167166
row_shift_towards_beginning<ValueT, fill_value, fill_type>,
168167
in_out.data_handle(),
169168
n_rows,
170169
n_cols,
171170
k,
172171
value);
173172
} else { // ShiftDirection::TOWARDS_END
174-
raft::launch_kernel(stream, num_blocks, TPB)(
173+
raft::launch_kernel(handle, num_blocks, TPB)(
175174
row_shift_towards_end<ValueT, fill_value, fill_type>,
176175
in_out.data_handle(),
177176
n_rows,

cpp/include/raft/random/detail/multi_variable_gaussian.cuh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class multi_variable_gaussian_impl {
222222
// upper part (0) being filled with 0.0
223223
dim3 block(32, 32);
224224
dim3 grid(raft::ceildiv(dim, (int)block.x), raft::ceildiv(dim, (int)block.y));
225-
raft::launch_kernel(cudaStream, grid, block)(fill_uplo<T>, dim, UPPER, (T)0.0, P);
225+
raft::launch_kernel(handle, grid, block)(fill_uplo<T>, dim, UPPER, (T)0.0, P);
226226

227227
// P is lower triangular chol decomp mtrx
228228
raft::linalg::gemm(
@@ -233,7 +233,7 @@ class multi_variable_gaussian_impl {
233233
dim3 grid(raft::ceildiv(dim, (int)block.x));
234234
RAFT_CUDA_TRY(cudaMemsetAsync(info, 0, sizeof(int), cudaStream));
235235
grid.x = raft::ceildiv(dim * dim, (int)block.x);
236-
raft::launch_kernel(cudaStream, grid, block)(combined_dot_product<T>, dim, dim, eig, P, info);
236+
raft::launch_kernel(handle, grid, block)(combined_dot_product<T>, dim, dim, eig, P, info);
237237

238238
// checking if any eigen vals were negative
239239
raft::update_host(&info_h, info, 1, cudaStream);

cpp/include/raft/sparse/convert/detail/adj_to_csr.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void adj_to_csr(raft::resources const& handle,
157157
dim3 block(adj_to_csr_tpb, 1);
158158
dim3 grid(blocks_per_row, grid_rows);
159159

160-
raft::launch_kernel(stream, grid, block)(
160+
raft::launch_kernel(handle, grid, block)(
161161
adj_to_csr_kernel<index_t>, adj, row_ind, num_rows, num_cols, tmp, out_col_ind);
162162
}
163163

cpp/include/raft/sparse/convert/detail/bitmap_to_csr.cuh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ void calc_nnz_by_rows(raft::resources const& handle,
106106
sub_nnz_size = num_rows * ((num_cols + bits_per_sub_col - 1) / bits_per_sub_col);
107107
return;
108108
}
109-
auto stream = resource::get_cuda_stream(handle);
110109
const size_t total = num_rows * num_cols;
111110
const size_t bitmap_num =
112111
(total + index_t(sizeof(bitmap_t) * 8) - 1) / index_t(sizeof(bitmap_t) * 8);
@@ -117,7 +116,7 @@ void calc_nnz_by_rows(raft::resources const& handle,
117116

118117
auto block = bitmap_to_csr_tpb;
119118

120-
raft::launch_kernel(stream, grid, block)(calc_nnz_by_rows_kernel<bitmap_t, index_t, nnz_t>,
119+
raft::launch_kernel(handle, grid, block)(calc_nnz_by_rows_kernel<bitmap_t, index_t, nnz_t>,
121120
bitmap,
122121
num_rows,
123122
num_cols,
@@ -249,14 +248,13 @@ void fill_indices_by_rows(raft::resources const& handle,
249248
index_t bits_per_sub_col,
250249
size_t sub_nnz_size)
251250
{
252-
auto stream = resource::get_cuda_stream(handle);
253251
auto block_x = num_rows;
254252
auto block_y = sub_nnz_size / num_rows;
255253
dim3 grid(block_x, block_y, 1);
256254

257255
auto block = bitmap_to_csr_tpb;
258256

259-
raft::launch_kernel(stream, grid, block)(
257+
raft::launch_kernel(handle, grid, block)(
260258
fill_indices_by_rows_kernel<bitmap_t, index_t, nnz_t, check_nnz>,
261259
bitmap,
262260
indptr,

cpp/include/raft/sparse/convert/detail/bitset_to_csr.cuh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ void gpu_repeat_csr(raft::resources const& handle,
6565
{
6666
if (nnz == 0) return;
6767

68-
auto stream = resource::get_cuda_stream(handle);
6968
index_t repeat_csr_tpb = 256;
7069
index_t grid = (nnz + repeat_csr_tpb - 1) / (repeat_csr_tpb);
7170

72-
raft::launch_kernel(stream, grid, repeat_csr_tpb)(repeat_csr_kernel,
71+
raft::launch_kernel(handle, grid, repeat_csr_tpb)(repeat_csr_kernel,
7372
d_indptr,
7473
d_indices,
7574
d_repeated_indptr,

cpp/include/raft/sparse/linalg/detail/laplacian.cuh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ auto compute_graph_laplacian(
105105
auto result_structure = result.structure_view();
106106
auto static constexpr const threads_per_block = 256;
107107
auto blocks = std::min(int((dim + threads_per_block - 1) / threads_per_block), 65535);
108-
auto stream = resource::get_cuda_stream(res);
109-
raft::launch_kernel(stream, blocks, threads_per_block)(
108+
raft::launch_kernel(res, blocks, threads_per_block)(
110109
detail::compute_graph_laplacian_kernel<std::remove_const_t<ElementType>,
111110
std::remove_const_t<IndptrType>,
112111
std::remove_const_t<IndicesType>>,

cpp/include/raft/sparse/linalg/detail/symmetrize.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void coo_symmetrize(raft::resources const& handle,
208208
handle, raft::make_device_vector_view(out_cols, out_nnz), static_cast<IdxT>(0));
209209
raft::matrix::fill(handle, raft::make_device_vector_view(out_vals, out_nnz), static_cast<T>(0.0));
210210

211-
raft::launch_kernel(stream, grid, blk)(coo_symmetrize_kernel<TPB_X, T, Lambda, IdxT, nnz_t>,
211+
raft::launch_kernel(handle, grid, blk)(coo_symmetrize_kernel<TPB_X, T, Lambda, IdxT, nnz_t>,
212212
in_row_ind.data(),
213213
in_rows,
214214
in_cols,

cpp/include/raft/sparse/linalg/detail/utils.cuh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ void faster_dot_on_csr(raft::resources const& handle,
9797
{
9898
if (nnz == 0 || n_rows == 0) return;
9999

100-
auto stream = resource::get_cuda_stream(handle);
101-
102100
constexpr value_idx MAX_ROW_PER_ITER = 500;
103101
int dev_id, sm_count, blocks_per_sm;
104102

@@ -115,7 +113,7 @@ void faster_dot_on_csr(raft::resources const& handle,
115113
(std::min(value_idx(blocks_per_sm * sm_count * 16), nnz) + block_x - 1) / block_x;
116114
dim3 blocks(block_x, block_y, 1);
117115

118-
raft::launch_kernel(stream, blocks, tpb, smem_size)(
116+
raft::launch_kernel(handle, blocks, tpb, smem_size)(
119117
faster_dot_on_csr_kernel<value_idx, value_t, dot_t>,
120118
dot,
121119
indptr,
@@ -135,7 +133,7 @@ void faster_dot_on_csr(raft::resources const& handle,
135133
(std::min(value_idx(blocks_per_sm * sm_count * 16), nnz) + block_x - 1) / block_x;
136134
dim3 blocks(block_x, block_y, 1);
137135

138-
raft::launch_kernel(stream, blocks, tpb, smem_size)(
136+
raft::launch_kernel(handle, blocks, tpb, smem_size)(
139137
faster_dot_on_csr_kernel<value_idx, value_t, dot_t>,
140138
dot,
141139
indptr,
@@ -154,7 +152,7 @@ void faster_dot_on_csr(raft::resources const& handle,
154152
(std::min(value_idx(blocks_per_sm * sm_count * 16), nnz) + block_x - 1) / block_x;
155153
dim3 blocks(block_x, block_y, 1);
156154

157-
raft::launch_kernel(stream, blocks, tpb, smem_size)(
155+
raft::launch_kernel(handle, blocks, tpb, smem_size)(
158156
faster_dot_on_csr_kernel<value_idx, value_t, dot_t>,
159157
dot,
160158
indptr,
@@ -173,7 +171,7 @@ void faster_dot_on_csr(raft::resources const& handle,
173171
(std::min(value_idx(blocks_per_sm * sm_count * 16), nnz) + block_x - 1) / block_x;
174172
dim3 blocks(block_x, block_y, 1);
175173

176-
raft::launch_kernel(stream, blocks, tpb, smem_size)(
174+
raft::launch_kernel(handle, blocks, tpb, smem_size)(
177175
faster_dot_on_csr_kernel<value_idx, value_t, dot_t>,
178176
dot,
179177
indptr,

0 commit comments

Comments
 (0)