zeroshade commented on code in PR #37365:
URL: https://github.com/apache/arrow/pull/37365#discussion_r1307940132


##########
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) {

Review Comment:
   I presume I'd run into the same issue as I did with the events that I'd get 
a segfault trying to do anything with the stream after it is destroyed, so I'm 
not sure what I could do to test here other than the fact that the ASAN tests 
should catch the memory leak if it doesn't get destroyed.



-- 
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]

Reply via email to