Skip to content

Commit b3d0557

Browse files
authored
Don't use cudaStream_t legacy (#8036)
1 parent 094b113 commit b3d0557

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

cub/test/catch2_test_device_run_length_encode_env.cu

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ struct stream_registry_factory_t;
1111

1212
#include <thrust/device_vector.h>
1313

14+
#include <cuda/devices>
1415
#include <cuda/iterator>
16+
#include <cuda/stream>
1517

1618
#include "catch2_test_env_launch_helper.h"
1719

@@ -152,8 +154,7 @@ TEST_CASE("DeviceRunLengthEncode::Encode uses custom stream", "[run_length_encod
152154
auto d_num_runs_out = c2h::device_vector<int>(1);
153155
int num_items = static_cast<int>(d_in.size());
154156

155-
cudaStream_t custom_stream;
156-
REQUIRE(cudaSuccess == cudaStreamCreate(&custom_stream));
157+
cuda::stream custom_stream{cuda::devices[0]};
157158

158159
size_t expected_bytes_allocated{};
159160
REQUIRE(
@@ -167,13 +168,14 @@ TEST_CASE("DeviceRunLengthEncode::Encode uses custom stream", "[run_length_encod
167168
d_num_runs_out.begin(),
168169
num_items));
169170

170-
auto stream_prop = stdexec::prop{cuda::get_stream_t{}, cuda::stream_ref{custom_stream}};
171+
cuda::stream_ref stream_ref{custom_stream};
172+
auto stream_prop = stdexec::prop{cuda::get_stream_t{}, stream_ref};
171173
auto env = stdexec::env{stream_prop, expected_allocation_size(expected_bytes_allocated)};
172174

173175
run_length_encode_env(
174176
d_in.begin(), d_unique_out.begin(), d_counts_out.begin(), d_num_runs_out.begin(), num_items, env);
175177

176-
REQUIRE(cudaSuccess == cudaStreamSynchronize(custom_stream));
178+
custom_stream.sync();
177179

178180
c2h::device_vector<int> expected_unique{0, 2, 9, 5, 8};
179181
c2h::device_vector<int> expected_counts{1, 2, 1, 3, 1};
@@ -184,8 +186,6 @@ TEST_CASE("DeviceRunLengthEncode::Encode uses custom stream", "[run_length_encod
184186
d_counts_out.resize(d_num_runs_out[0]);
185187
REQUIRE(d_unique_out == expected_unique);
186188
REQUIRE(d_counts_out == expected_counts);
187-
188-
REQUIRE(cudaSuccess == cudaStreamDestroy(custom_stream));
189189
}
190190

191191
TEST_CASE("DeviceRunLengthEncode::NonTrivialRuns uses custom stream", "[run_length_encode][device]")
@@ -196,8 +196,7 @@ TEST_CASE("DeviceRunLengthEncode::NonTrivialRuns uses custom stream", "[run_leng
196196
auto d_num_runs_out = c2h::device_vector<int>(1);
197197
int num_items = static_cast<int>(d_in.size());
198198

199-
cudaStream_t custom_stream;
200-
REQUIRE(cudaSuccess == cudaStreamCreate(&custom_stream));
199+
cuda::stream custom_stream{cuda::devices[0]};
201200

202201
size_t expected_bytes_allocated{};
203202
REQUIRE(
@@ -211,13 +210,14 @@ TEST_CASE("DeviceRunLengthEncode::NonTrivialRuns uses custom stream", "[run_leng
211210
d_num_runs_out.begin(),
212211
num_items));
213212

214-
auto stream_prop = stdexec::prop{cuda::get_stream_t{}, cuda::stream_ref{custom_stream}};
213+
cuda::stream_ref stream_ref{custom_stream};
214+
auto stream_prop = stdexec::prop{cuda::get_stream_t{}, stream_ref};
215215
auto env = stdexec::env{stream_prop, expected_allocation_size(expected_bytes_allocated)};
216216

217217
non_trivial_runs_env(
218218
d_in.begin(), d_offsets_out.begin(), d_lengths_out.begin(), d_num_runs_out.begin(), num_items, env);
219219

220-
REQUIRE(cudaSuccess == cudaStreamSynchronize(custom_stream));
220+
custom_stream.sync();
221221

222222
c2h::device_vector<int> expected_offsets{1, 4};
223223
c2h::device_vector<int> expected_lengths{2, 3};
@@ -228,6 +228,4 @@ TEST_CASE("DeviceRunLengthEncode::NonTrivialRuns uses custom stream", "[run_leng
228228
d_lengths_out.resize(d_num_runs_out[0]);
229229
REQUIRE(d_offsets_out == expected_offsets);
230230
REQUIRE(d_lengths_out == expected_lengths);
231-
232-
REQUIRE(cudaSuccess == cudaStreamDestroy(custom_stream));
233231
}

0 commit comments

Comments
 (0)