paleolimbot commented on code in PR #488:
URL: https://github.com/apache/arrow-nanoarrow/pull/488#discussion_r1618034523
##########
extensions/nanoarrow_device/src/nanoarrow/nanoarrow_device_cuda.c:
##########
@@ -32,67 +71,63 @@ static void ArrowDeviceCudaDeallocator(struct
ArrowBufferAllocator* allocator,
struct ArrowDeviceCudaAllocatorPrivate* allocator_private =
(struct ArrowDeviceCudaAllocatorPrivate*)allocator->private_data;
- int prev_device = 0;
- // Not ideal: we have no place to communicate any errors here
- cudaGetDevice(&prev_device);
- cudaSetDevice((int)allocator_private->device_id);
-
switch (allocator_private->device_type) {
case ARROW_DEVICE_CUDA:
- cudaFree(allocator_private->allocated_ptr);
+ cuMemFree((CUdeviceptr)allocator_private->allocated_ptr);
break;
case ARROW_DEVICE_CUDA_HOST:
- cudaFreeHost(allocator_private->allocated_ptr);
+ cuMemFreeHost(allocator_private->allocated_ptr);
break;
default:
break;
}
- cudaSetDevice(prev_device);
ArrowFree(allocator_private);
}
static ArrowErrorCode ArrowDeviceCudaAllocateBuffer(struct ArrowDevice* device,
struct ArrowBuffer* buffer,
int64_t size_bytes) {
- int prev_device = 0;
- cudaError_t result = cudaGetDevice(&prev_device);
- if (result != cudaSuccess) {
- return EINVAL;
- }
Review Comment:
I believe so...it's created using the `CUdevice` and I stole this from Arrow
C++ (the push/pop context always surrounds the `cuMemAlloc()` there). I also
don't have a multi GPU system to test on 🙂
--
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]