Closed
Description
In C++ we can use a raw device pointer to create an arrayfire Array:
// Create an array on the host, copy it into an ArrayFire 2x3 ArrayFire
// array
float host_ptr[] = {0, 1, 2, 3, 4, 5};
array a(2, 3, host_ptr);
// Create a CUDA device pointer, populate it with data from the host
float *device_ptr;
cudaMalloc((void **)&device_ptr, 6 * sizeof(float));
cudaMemcpy(device_ptr, host_ptr, 6 * sizeof(float), cudaMemcpyHostToDevice);
// Convert the CUDA-allocated device memory into an ArrayFire array:
array b(2, 3, device_ptr, afDevice); // Note: afDevice (default: afHost)
// Note that ArrayFire takes ownership over `device_ptr`, so memory will
// be freed when `b` id destructed. Do not call cudaFree(device_ptr)!
(from http://arrayfire.org/docs/gettingstarted.htm).
However, we cannot do this in the current Rust API, while this feature is very useful in practice when we want to modify existing cuda arrays.
Metadata
Metadata
Assignees
Type
Projects
Status
Features & Improvements