Allocate memory using the ArrayFire memory manager. More...
Functions | |
AFAPI af_err | af_alloc_device (void **ptr, const dim_t bytes) |
Allocates memory using ArrayFire's memory manager. More... | |
AFAPI af_err | af_alloc_device_v2 (void **ptr, const dim_t bytes) |
Allocates memory using ArrayFire's memory manager. More... | |
AFAPI void * | alloc (const size_t elements, const dtype type) |
Allocates memory using ArrayFire's memory manager. More... | |
AFAPI void * | allocV2 (const size_t bytes) |
Allocates memory using ArrayFire's memory manager. More... | |
template<typename T > | |
T * | alloc (const size_t elements) |
Allocates memory using ArrayFire's memory manager. More... | |
Allocate memory using the ArrayFire memory manager.
This function will allocate memory on the device and return a pointer to it. The memory is allocated using ArrayFire's memory manager which will defer releasing memory to the driver and reuse the same memory for later operations.
This function will return different objects based on the type used. The interface returns a void pointer that needs to be cast to the backend appropriate memory type.
function | CPU | CUDA | OpenCL |
---|---|---|---|
af_alloc_device_v2 | T* | T* | cl_mem |
af::allocV2 | T* | T* | cl_mem |
af_alloc_device (deprecated) | T* | T* | cl::Buffer* |
af::alloc (deprecated) | T* | T* | cl::Buffer* |
Allocates memory using ArrayFire's memory manager.
This device memory returned by this function can only be freed using af_free_device
[out] | ptr | Pointer to the device memory on the current device. This is a CUDA device pointer for the CUDA backend. A cl::Buffer pointer on the OpenCL backend and a C pointer for the CPU backend |
[in] | bytes | The number of bites to allocate on the device |
Allocates memory using ArrayFire's memory manager.
This device memory returned by this function can only be freed using af_free_device_v2.
[out] | ptr | Pointer to the device memory on the current device. This is a CUDA device pointer for the CUDA backend. A cl::Buffer pointer on the OpenCL backend and a C pointer for the CPU backend |
[in] | bytes | The number of bites to allocate on the device |
T * alloc | ( | const size_t | elements | ) |
Allocates memory using ArrayFire's memory manager.
[in] | elements | the number of elements to allocate |
elements
* sizeof(type) Allocates memory using ArrayFire's memory manager.
[in] | elements | the number of elements to allocate |
[in] | type | is the type of the elements to allocate |
AFAPI void * allocV2 | ( | const size_t | bytes | ) |
Allocates memory using ArrayFire's memory manager.
[in] | bytes | the number of bytes to allocate |