bkietz commented on code in PR #43542:
URL: https://github.com/apache/arrow/pull/43542#discussion_r1733115704
##########
cpp/src/arrow/chunked_array.h:
##########
@@ -116,6 +118,10 @@ class ARROW_EXPORT ChunkedArray {
/// \return an ArrayVector of chunks
const ArrayVector& chunks() const { return chunks_; }
+ /// \return The set of device allocation types used by the chunks in this
+ /// chunked array.
+ DeviceAllocationTypeSet DeviceTypeSet() const;
Review Comment:
Nit (maybe?) I would've expected this to be named `device_types()`
##########
cpp/src/arrow/device_allocation_type_set.cc:
##########
@@ -0,0 +1,80 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <string>
+
+#include "arrow/device_allocation_type.h"
+#include "arrow/device_allocation_type_set.h"
+
+namespace arrow {
+
+const char* DeviceAllocationTypeToCStr(DeviceAllocationType type) {
+ switch (type) {
+ case DeviceAllocationType::kCPU:
+ return "CPU";
+ case DeviceAllocationType::kCUDA:
+ return "CUDA";
+ case DeviceAllocationType::kCUDA_HOST:
+ return "CUDA_HOST";
+ case DeviceAllocationType::kOPENCL:
+ return "OPENCL";
+ case DeviceAllocationType::kVULKAN:
+ return "VULKAN";
+ case DeviceAllocationType::kMETAL:
+ return "METAL";
+ case DeviceAllocationType::kVPI:
+ return "VPI";
+ case DeviceAllocationType::kROCM:
+ return "ROCM";
+ case DeviceAllocationType::kROCM_HOST:
+ return "ROCM_HOST";
+ case DeviceAllocationType::kEXT_DEV:
+ return "EXT_DEV";
+ case DeviceAllocationType::kCUDA_MANAGED:
+ return "CUDA_MANAGED";
+ case DeviceAllocationType::kONEAPI:
+ return "ONEAPI";
+ case DeviceAllocationType::kWEBGPU:
+ return "WEBGPU";
+ case DeviceAllocationType::kHEXAGON:
+ return "HEXAGON";
+ }
+ return "<UNKNOWN>";
+}
+
+std::string DeviceAllocationTypeSet::ToString() const {
+ std::string result = "{";
+ for (int i = 1; i <= kDeviceAllocationTypeMax; i++) {
+ if (device_type_bitset_.test(i)) {
+ // Skip all the unused values in the enum.
+ switch (i) {
+ case 0:
+ case 5:
+ case 6:
+ continue;
+ }
Review Comment:
```suggestion
for (int i : {
DeviceAllocationType::kCPU,
DeviceAllocationType::kCUDA,
DeviceAllocationType::kCUDA_HOST,
DeviceAllocationType::kOPENCL,
DeviceAllocationType::kVULKAN,
DeviceAllocationType::kMETAL,
DeviceAllocationType::kVPI,
DeviceAllocationType::kROCM,
DeviceAllocationType::kROCM_HOST,
DeviceAllocationType::kEXT_DEV,
DeviceAllocationType::kCUDA_MANAGED,
DeviceAllocationType::kONEAPI,
DeviceAllocationType::kWEBGPU,
DeviceAllocationType::kHEXAGON,
}) {
```
##########
cpp/src/arrow/device_allocation_type.h:
##########
@@ -0,0 +1,41 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+namespace arrow {
+
+/// \brief EXPERIMENTAL: Device type enum which matches up with C Data Device
types
+enum class DeviceAllocationType : char {
Review Comment:
Maybe this should go to type_fwd.h instead?
--
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]