zeroshade commented on code in PR #34972:
URL: https://github.com/apache/arrow/pull/34972#discussion_r1161875233
##########
cpp/src/arrow/c/abi.h:
##########
@@ -65,6 +65,69 @@ struct ArrowArray {
#endif // ARROW_C_DATA_INTERFACE
+#ifndef ARROW_C_DEVICE_DATA_INTERFACE
+#define ARROW_C_DEVICE_DATA_INTERFACE
+
+// ArrowDeviceType is compatible with dlpack DLDeviceType for portability
+// it uses the same values for each enum as the equivalent kDL<type> from
dlpack.h
+#ifdef __cplusplus
+typedef enum : int32_t {
+#else
+typedef enum {
+#endif
+ // CPU device, same as using ArrowArray directly
+ kArrowCPU = 1,
+ // CUDA GPU Device
+ kArrowCUDA = 2,
+ // Pinned CUDA CPU memory by cudaMallocHost
+ kArrowCUDAHost = 3,
+ // OpenCL Device
+ kArrowOpenCL = 4,
+ // Vulkan buffer for next-gen graphics
+ kArrowVulkan = 7,
+ // Metal for Apple GPU
+ kArrowMetal = 8,
+ // Verilog simulator buffer
+ kArrowVPI = 9,
+ // ROCm GPUs for AMD GPUs
+ kArrowROCM = 10,
+ // Pinned ROCm CPU memory allocated by hipMallocHost
+ kArrowROCMHost = 11,
+ // Reserved for extension
+ // used to quickly test extension devices,
+ // semantics can differ based on the implementation
+ kArrowExtDev = 12,
+ // CUDA managed/unified memory allocated by cudaMallocManaged
+ kArrowCUDAManaged = 13,
+ // unified shared memory allocated on a oneAPI non-partitioned
+ // device. call to oneAPI runtime is required to determine the
+ // device type, the USM allocation type and the sycl context it
+ // is bound to
+ kArrowOneAPI = 14,
+ // GPU support for next-gen WebGPU standard
+ kArrowWebGPU = 15,
+ // Qualcomm Hexagon DSP
+ kArrowHexagon = 16,
+} ArrowDeviceType;
+
+struct ArrowDeviceArray {
+ // the private_date and release callback of the arrow array
+ // should contain any necessary information and structures
+ // related to freeing the array according to the device it
+ // is allocated on, rather than having a separate release
+ // callback embedded here.
+ struct ArrowArray* array;
Review Comment:
The `ArrowArray` struct itself can't change because that would break the
ABI, but we might potentially create an `ArrowArrayV2` that would be good to
easily be able to plug in here.
That said, "who owns the memory" is a good question, and technically if we
did evolve this to point to an `ArrowArrayV2` in theory that would still be
breaking because while the ABI would still work just fine (all the sizes are
the same) attempting to access the members would fail because the struct itself
would be different. So my entire idea of using a pointer here is flawed in
general. I'll update this to just embed the struct.
--
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]