Skip to content

[Format][C++] Recommended/required value for ArrowDeviceArray.device_id int in case of CPU data #40801

@jorisvandenbossche

Description

@jorisvandenbossche

In #40717 (review), @paleolimbot noted that the current implementation of the C Device interface in Arrow C++ is using a device_id of -1 when exporting CPU data (while nanoarrow is using 0).

The spec itself doesn't say anything about this (https://arrow.apache.org/docs/format/CDeviceDataInterface.html#c.ArrowDeviceArray.device_id):

Mandatory. The device id to identify a specific device if multiple devices of this type are on the system. The semantics of the id will be hardware dependent, but we use an int64_t to future-proof the id as devices change over time.

Should we recommend or require a specific value for this case?

I noticed that the DLPack specification, from which the device type/id structure was taken, does specify to use 0 (https://dmlc.github.io/dlpack/latest/c_api.html#c.DLDevice.device_id):

The device index. For vanilla CPU memory, pinned memory, or managed memory, this is set to 0.

Should we adopt the same guideline for our spec?

cc @pitrou @zeroshade @kkraus14

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions