kkraus14 commented on code in PR #37365:
URL: https://github.com/apache/arrow/pull/37365#discussion_r1307797177
##########
cpp/src/arrow/gpu/cuda_context.cc:
##########
@@ -281,6 +279,49 @@ Result<std::shared_ptr<CudaDevice>> AsCudaDevice(const
std::shared_ptr<Device>&
}
}
+Status CudaDevice::Stream::WaitEvent(const Device::SyncEvent& event) {
+ auto cuda_event =
+ checked_cast<const CudaDevice::SyncEvent*, const
Device::SyncEvent*>(&event);
+ if (!cuda_event) {
+ return Status::Invalid("CudaDevice::Stream cannot Wait on non-cuda event");
+ }
+
+ auto cu_event = cuda_event->value();
+ if (!cu_event) {
+ return Status::Invalid("Cuda Stream cannot wait on null event");
+ }
+
+ ContextSaver set_temporary((CUcontext)(context_.get()->handle()));
+ // TODO: do we need to account for CUevent_capture_flags??
+ CU_RETURN_NOT_OK("cuStreamWaitEvent",
+ cuStreamWaitEvent(stream_, cu_event,
CU_EVENT_WAIT_DEFAULT));
+ return Status::OK();
+}
+
+Status CudaDevice::Stream::Synchronize() const {
+ ContextSaver set_temporary((CUcontext)(context_.get()->handle()));
+ CU_RETURN_NOT_OK("cuStreamSynchronize", cuStreamSynchronize(stream_));
+ return Status::OK();
+}
+
+Status CudaDevice::SyncEvent::Wait() {
+ ContextSaver set_temporary((CUcontext)(context_.get()->handle()));
+ CU_RETURN_NOT_OK("cuEventSynchronize", cuEventSynchronize(value()));
+ return Status::OK();
+}
+
+Status CudaDevice::SyncEvent::Record(const Device::Stream& st) {
+ auto cuda_stream = checked_cast<const CudaDevice::Stream*, const
Device::Stream*>(&st);
+ if (!cuda_stream) {
+ return Status::Invalid("CudaDevice::Event cannot record on non-cuda
stream");
+ }
+
+ ContextSaver set_temporary((CUcontext)(context_.get()->handle()));
+ CU_RETURN_NOT_OK("cuEventRecord", cuEventRecord(value(),
cuda_stream->value()));
+ // TODO: there is also cuEventRecordWithFlags, do we want to allow flags?
Review Comment:
As far as I can tell HIP and SYCL don't support flags here. We can always
introduce a `RecordWithFlags` API later if needed that wouldn't break the ABI.
--
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]