zeroshade commented on code in PR #37365:
URL: https://github.com/apache/arrow/pull/37365#discussion_r1307945624
##########
cpp/src/arrow/gpu/cuda_test.cc:
##########
@@ -213,6 +215,67 @@ TEST_F(TestCudaDevice, Copy) {
}
}
+TEST_F(TestCudaDevice, CreateSyncEvent) {
+ ASSERT_OK_AND_ASSIGN(auto ev, mm_->MakeDeviceSyncEvent());
+ ASSERT_TRUE(ev);
+ auto cuda_ev = checked_pointer_cast<CudaDevice::SyncEvent>(ev);
+ ASSERT_EQ(CUDA_SUCCESS, cuEventQuery(*cuda_ev));
+}
+
+TEST_F(TestCudaDevice, WrapDeviceSyncEvent) {
+ // need a context to call cuEventCreate
+ ContextSaver set_temporary((CUcontext)(context_.get()->handle()));
+
+ CUevent event;
+ ASSERT_CUDA_OK(cuEventCreate(&event, CU_EVENT_DEFAULT));
+ ASSERT_CUDA_OK(cuEventQuery(event));
+
+ {
+ // wrap event with no-op destructor
+ ASSERT_OK_AND_ASSIGN(auto ev, mm_->WrapDeviceSyncEvent(&event, [](void*)
{}));
+ ASSERT_TRUE(ev);
+ // 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_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_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());
+
+ ASSERT_OK(ev->Record(stream));
+ ASSERT_OK(stream.WaitEvent(*ev));
+ ASSERT_OK(ev->Wait());
+ 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));
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]