-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(extensions/nanoarrow_device): Document device extension #497
Comments
The old README: nanoarrow device optionThe nanoarrow device options provides a similar set of tools as the core nanoarrow C API Currently, this option provides an implementation of CUDA devices Examplestruct ArrowDevice* gpu = ArrowDeviceMetalDefaultDevice();
// Alternatively, ArrowDeviceCuda(ARROW_DEVICE_CUDA, 0)
// or ArrowDeviceCuda(ARROW_DEVICE_CUDA_HOST, 0)
struct ArrowDevice* cpu = ArrowDeviceCpu();
struct ArrowArray array;
struct ArrowDeviceArray device_array;
struct ArrowDeviceArrayView device_array_view;
// Build a CPU array
ASSERT_EQ(ArrowArrayInitFromType(&array, NANOARROW_TYPE_STRING), NANOARROW_OK);
ASSERT_EQ(ArrowArrayStartAppending(&array), NANOARROW_OK);
ASSERT_EQ(ArrowArrayAppendString(&array, ArrowCharView("abc")), NANOARROW_OK);
ASSERT_EQ(ArrowArrayAppendString(&array, ArrowCharView("defg")), NANOARROW_OK);
ASSERT_EQ(ArrowArrayAppendNull(&array, 1), NANOARROW_OK);
ASSERT_EQ(ArrowArrayFinishBuildingDefault(&array, nullptr), NANOARROW_OK);
// Convert to a DeviceArray, still on the CPU
ASSERT_EQ(ArrowDeviceArrayInit(cpu, &device_array, &array), NANOARROW_OK);
// Parse contents into a view that can be copied to another device
ArrowDeviceArrayViewInit(&device_array_view);
ArrowArrayViewInitFromType(&device_array_view.array_view, string_type);
ASSERT_EQ(ArrowDeviceArrayViewSetArray(&device_array_view, &device_array, nullptr),
NANOARROW_OK);
// Copy to another device. For some devices, ArrowDeviceArrayMoveToDevice() is
// possible without an explicit copy (although this sometimes triggers an implicit
// copy by the driver).
struct ArrowDeviceArray device_array2;
device_array2.array.release = nullptr;
ASSERT_EQ(
ArrowDeviceArrayViewCopy(&device_array, &device_array_view, gpu, &device_array2),
NANOARROW_OK); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As I was reminded in #488 (comment) , we have very minimal top-level documentation for the nanoarrow device extension (we do have inline function documentation, though). After some of the larger-scale details are sorted out, the high-level documentation and/or a getting started article should be added (which will also help flush out the scope of the extension and how it might be used).
The text was updated successfully, but these errors were encountered: