kkraus14 commented on code in PR #37040:
URL: https://github.com/apache/arrow/pull/37040#discussion_r1296230819


##########
cpp/src/arrow/device.h:
##########
@@ -98,6 +101,71 @@ 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.
+    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

Review Comment:
   Ideally we could have a single API that allows people to write 
device-agnostic code where possible. Waiting on an event in a stream is a 
consistent concept across CUDA, HIP, SYCL, and OpenCL, but if possible we 
should try to make the API play nicely with CPUs as well.



##########
cpp/src/arrow/device.h:
##########
@@ -165,6 +198,17 @@ class ARROW_EXPORT MemoryManager : public 
std::enable_shared_from_this<MemoryMan
   static Result<std::shared_ptr<Buffer>> ViewBuffer(
       const std::shared_ptr<Buffer>& source, const 
std::shared_ptr<MemoryManager>& to);
 
+  /// \brief Create a SyncEvent for exporting
+  ///
+  /// This version should construct the appropriate event for the device and
+  /// provide the unique_ptr with the correct deleter for the event type.  
+  virtual Result<std::shared_ptr<Device::SyncEvent>> MakeDeviceSync();
+
+  /// \brief Create a SyncEvent from imported device array.
+  ///   
+  /// @param sync_event passed in sync_event from the imported device array.
+  virtual Result<std::shared_ptr<Device::SyncEvent>> 
MakeDeviceSync(std::unique_ptr<void, void(*)(void*)> sync_event);

Review Comment:
   Can we name these as `MakeDeviceSyncEvent`? I read these as "Instruct the 
device to synchronize" 😅



##########
cpp/src/arrow/device.h:
##########
@@ -165,6 +198,17 @@ class ARROW_EXPORT MemoryManager : public 
std::enable_shared_from_this<MemoryMan
   static Result<std::shared_ptr<Buffer>> ViewBuffer(
       const std::shared_ptr<Buffer>& source, const 
std::shared_ptr<MemoryManager>& to);
 
+  /// \brief Create a SyncEvent for exporting
+  ///
+  /// This version should construct the appropriate event for the device and
+  /// provide the unique_ptr with the correct deleter for the event type.  
+  virtual Result<std::shared_ptr<Device::SyncEvent>> MakeDeviceSync();
+
+  /// \brief Create a SyncEvent from imported device array.
+  ///   
+  /// @param sync_event passed in sync_event from the imported device array.
+  virtual Result<std::shared_ptr<Device::SyncEvent>> 
MakeDeviceSync(std::unique_ptr<void, void(*)(void*)> sync_event);

Review Comment:
   Can we name these as `MakeDeviceSyncEvent`? I read these as "Instruct the 
device to synchronize" 😅



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