MCPcopy Index your code
hub / github.com/arrayfire/arrayfire-rust / new_from_device_ptr

Method new_from_device_ptr

src/core/array.rs:356–370  ·  view source on GitHub ↗

Constructs a new Array object from device pointer The example show cases the usage using CUDA API, but usage of this function will be similar in CPU and OpenCL backends also. In the case of OpenCL backend, the pointer would be cl_mem. A short example of how to create an Array from device pointer is shown below but for detailed set of examples, please check out the tutorial book pages: - [Interope

(dev_ptr: *mut T, dims: Dim4)

Source from the content-addressed store, hash-verified

354 ///}
355 /// ```
356 pub fn new_from_device_ptr(dev_ptr: *mut T, dims: Dim4) -> Self {
357 let aftype = T::get_af_dtype();
358 unsafe {
359 let mut temp: af_array = std::ptr::null_mut();
360 let err_val = af_device_array(
361 &mut temp as *mut af_array,
362 dev_ptr as *mut c_void,
363 dims.ndims() as c_uint,
364 dims.get().as_ptr() as *const dim_t,
365 aftype as c_uint,
366 );
367 HANDLE_ERROR(AfError::from(err_val));
368 temp.into()
369 }
370 }
371
372 /// Returns the backend of the Array
373 ///

Callers

nothing calls this directly

Calls 4

HANDLE_ERRORFunction · 0.85
ndimsMethod · 0.80
intoMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected