kkraus14 commented on code in PR #37040:
URL: https://github.com/apache/arrow/pull/37040#discussion_r1291600854
##########
cpp/src/arrow/device.h:
##########
@@ -98,6 +100,64 @@ class ARROW_EXPORT Device : public
std::enable_shared_from_this<Device>,
/// \brief Return the DeviceAllocationType of this device
virtual DeviceAllocationType device_type() const = 0;
+ /// \brief EXPERIMENTAL: An object that provides event/stream sync primitives
+ ///
+ ///
+ class ARROW_EXPORT SyncEvent {
+ public:
+ virtual ~SyncEvent() = default;
+
+ /// @brief Block until sync event is completed.
+ ///
+ /// Should be a no-op for CPU devices.
+ virtual Status wait() = 0;
+
+ /// @brief Make the provided stream wait on the sync event.
+ ///
+ /// Tells the provided stream that it should wait until the
+ /// synchronization event is completed without blocking the CPU.
+ /// @param stream Should be appropriate for the underlying device
+ virtual Status stream_wait(void* stream) = 0;
+
+ virtual void set_stream(void* stream) { stream_ = stream; }
+
+ Result<void*> get_event() {
+ if (!sync_event_) {
+ ARROW_ASSIGN_OR_RAISE(sync_event_, create_event());
+ owns_event_ = true;
+ }
+ return sync_event_;
+ }
+
+ void clear_event() {
+ if (owns_event_) {
+ release_event(sync_event_);
+ }
+ sync_event_ = nullptr;
+ }
+
+ Status record_event() {
+ if (!stream_) {
+ return Status::Invalid(
+ "Cannot record event on null stream, call set_stream first.");
+ }
+ ARROW_ASSIGN_OR_RAISE(auto ev, get_event());
+ return record_event_on_stream(ev);
+ }
Review Comment:
These don't look thread safe. Do they need to be or do we need to document
that this isn't thread safe somewhere?
##########
cpp/src/arrow/device.h:
##########
@@ -98,6 +100,64 @@ class ARROW_EXPORT Device : public
std::enable_shared_from_this<Device>,
/// \brief Return the DeviceAllocationType of this device
virtual DeviceAllocationType device_type() const = 0;
+ /// \brief EXPERIMENTAL: An object that provides event/stream sync primitives
+ ///
+ ///
+ class ARROW_EXPORT SyncEvent {
+ public:
+ virtual ~SyncEvent() = default;
+
+ /// @brief Block until sync event is completed.
+ ///
+ /// Should be a no-op for CPU devices.
Review Comment:
Are we sure there's no CPU paradigm where things could be asynchronous?
--
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]