#include <stdbool.h>
#include <stdlib.h>
Go to the source code of this file.
Defines | |
#define | AFAPI __attribute__((visibility("default"))) |
#define | AFXAPI __attribute__((visibility("default"))) |
Typedefs | |
typedef afError(* | af_alloc_fn )(void **, size_t bytes) |
Memory handling function callback prototypes. | |
typedef afError(* | af_free_fn )(void *) |
typedef afError(* | af_garbage_fn )(size_t bytes) |
Enumerations | |
enum | afError { AF_SUCCESS = 0, AF_ERR_INTERNAL, AF_ERR_NOMEM, AF_ERR_BATCH, AF_ERR_ARG, AF_ERR_NOTSUP, AF_ERR_DRIVER, AF_ERR_RUNTIME, AF_ERR_EXTERN, AF_ERR_LICENSE, AF_ERR_SYSTEM } |
enum | af_class_id { afUNKNOWN_CLASS = 0, afCELL_CLASS, afSTRUCT_CLASS, afLOGICAL_CLASS, afCHAR_CLASS, afVOID_CLASS, afDOUBLE_CLASS, afSINGLE_CLASS, afINT8_CLASS, afUINT8_CLASS, afINT16_CLASS, afUINT16_CLASS, afINT32_CLASS, afUINT32_CLASS, afINT64_CLASS, afUINT64_CLASS, afFUNCTION_CLASS, afOPAQUE_CLASS, afOBJECT_CLASS, afINDEX_CLASS = afUINT32_CLASS } |
Functions | |
afError | af_errno (void) |
Fetch last error code. | |
const char * | af_errstr (void) |
Fetch the last error message, typically indicating file/line where error originated. | |
afError | af_malloc (void **ptr, size_t bytes) |
Allocate memory on the device. | |
afError | af_free (void *ptr) |
Free memory on the device. | |
afError | af_init (af_alloc_fn alloc, af_free_fn free, af_garbage_fn garbage) |
Initialize runtime to use these provided callbacks for memory management. |
#define AFAPI __attribute__((visibility("default"))) |
#define AFXAPI __attribute__((visibility("default"))) |
typedef afError(* af_alloc_fn)(void **, size_t bytes) |
Memory handling function callback prototypes.
typedef afError(* af_free_fn)(void *) |
typedef afError(* af_garbage_fn)(size_t bytes) |
enum afError |
enum af_class_id |
afError af_errno | ( | void | ) |
Fetch last error code.
const char* af_errstr | ( | void | ) |
Fetch the last error message, typically indicating file/line where error originated.
afError af_malloc | ( | void ** | ptr, |
size_t | bytes | ||
) |
Allocate memory on the device.
Directly maps to cudaMalloc() unless overridden by af_init().
afError af_free | ( | void * | ptr | ) |
Free memory on the device.
Directly maps to cudaFree() unless overridden by af_init().
afError af_init | ( | af_alloc_fn | alloc, |
af_free_fn | free, | ||
af_garbage_fn | garbage | ||
) |
Initialize runtime to use these provided callbacks for memory management.
All routines in ArrayFire use af_malloc() and af_free() to get allocate and free device memory, and af_garbage() under memory pressure. Unless set with af_init, those directly call cudaMalloc()/cudaFree(). Applications can instead insert their own memory management algorithm to manage reference counting and garbage collection.
[in] | alloc | Allocation callback |
[in] | free | Deallocation callback |
[in] | garbage | Garbage collection when under memory pressure |