Skip to content

Commit

Permalink
add another stream test
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroshade committed Aug 24, 2023
1 parent 6ba42c2 commit 38daa6d
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions cpp/src/arrow/gpu/cuda_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ TEST_F(TestCudaDevice, WrapDeviceSyncEvent) {

CUevent event;
ASSERT_CUDA_OK(cuEventCreate(&event, CU_EVENT_DEFAULT));
ASSERT_EQ(CUDA_SUCCESS, cuEventQuery(event));
ASSERT_CUDA_OK(cuEventQuery(event));

{
// wrap event with no-op destructor
Expand All @@ -237,16 +237,15 @@ TEST_F(TestCudaDevice, WrapDeviceSyncEvent) {
// verify it's the same event we passed in
ASSERT_EQ(ev->get_raw(), &event);
auto cuda_ev = checked_pointer_cast<CudaDevice::SyncEvent>(ev);
ASSERT_EQ(CUDA_SUCCESS, cuEventQuery(*cuda_ev));
ASSERT_CUDA_OK(cuEventQuery(*cuda_ev));
}

// verify that the event is still valid on the device when the shared_ptr
// goes away since we didn't give it ownership.
ASSERT_EQ(CUDA_SUCCESS, cuEventQuery(event));
ASSERT_CUDA_OK(cuEventQuery(event));
ASSERT_CUDA_OK(cuEventDestroy(event));
}


TEST_F(TestCudaDevice, DefaultStream) {
CudaDevice::Stream stream{context_};
ASSERT_OK_AND_ASSIGN(auto ev, mm_->MakeDeviceSyncEvent());
Expand All @@ -257,6 +256,26 @@ TEST_F(TestCudaDevice, DefaultStream) {
ASSERT_OK(stream.Synchronize());
}

TEST_F(TestCudaDevice, ExplicitStream) {
// need a context to call cuEventCreate
ContextSaver set_temporary((CUcontext)(context_.get()->handle()));

CUstream cu_stream;
ASSERT_CUDA_OK(cuStreamCreate(&cu_stream, CU_STREAM_NON_BLOCKING));

{
CudaDevice::Stream stream(context_, cu_stream);
ASSERT_OK_AND_ASSIGN(auto ev, mm_->MakeDeviceSyncEvent());

ASSERT_OK(ev->Record(stream));
ASSERT_OK(stream.WaitEvent(*ev));
ASSERT_OK(ev->Wait());
ASSERT_OK(stream.Synchronize());
}

ASSERT_CUDA_OK(cuStreamDestroy(cu_stream));
}

// ------------------------------------------------------------------------
// Test CudaContext

Expand Down

0 comments on commit 38daa6d

Please sign in to comment.