A high-performance general-purpose compute library
memory.h File Reference
#include <af/defines.h>
#include <af/event.h>
#include <stddef.h>

Go to the source code of this file.

Typedefs

typedef void * af_memory_manager
 
typedef af_err(* af_memory_manager_initialize_fn) (af_memory_manager handle)
 Called after a memory manager is set and becomes active. More...
 
typedef af_err(* af_memory_manager_shutdown_fn) (af_memory_manager handle)
 Called after a memory manager is unset and becomes unused. More...
 
typedef af_err(* af_memory_manager_alloc_fn) (af_memory_manager handle, void **ptr, int user_lock, const unsigned ndims, dim_t *dims, const unsigned element_size)
 Function pointer that will be called by ArrayFire to allocate memory. More...
 
typedef af_err(* af_memory_manager_allocated_fn) (af_memory_manager handle, size_t *size, void *ptr)
 Checks the amount of allocated memory for a pointer. More...
 
typedef af_err(* af_memory_manager_unlock_fn) (af_memory_manager handle, void *ptr, int user_unlock)
 Unlocks memory from use. More...
 
typedef af_err(* af_memory_manager_signal_memory_cleanup_fn) (af_memory_manager handle)
 Called to signal the memory manager should free memory if possible. More...
 
typedef af_err(* af_memory_manager_print_info_fn) (af_memory_manager handle, char *buffer, int id)
 Populates a character array with human readable information about the current state of the memory manager. More...
 
typedef af_err(* af_memory_manager_user_lock_fn) (af_memory_manager handle, void *ptr)
 Called to lock a buffer as user-owned memory. More...
 
typedef af_err(* af_memory_manager_user_unlock_fn) (af_memory_manager handle, void *ptr)
 Called to unlock a buffer from user-owned memory. More...
 
typedef af_err(* af_memory_manager_is_user_locked_fn) (af_memory_manager handle, int *out, void *ptr)
 Queries if a buffer is user locked. More...
 
typedef af_err(* af_memory_manager_get_memory_pressure_fn) (af_memory_manager handle, float *pressure)
 Gets memory pressure for a memory manager. More...
 
typedef af_err(* af_memory_manager_jit_tree_exceeds_memory_pressure_fn) (af_memory_manager handle, int *out, size_t size)
 Called to query if additions to the JIT tree would exert too much memory pressure. More...
 
typedef void(* af_memory_manager_add_memory_management_fn) (af_memory_manager handle, int id)
 Adds a new device to the memory manager (OpenCL only) More...
 
typedef void(* af_memory_manager_remove_memory_management_fn) (af_memory_manager handle, int id)
 Removes a device from the memory manager (OpenCL only) More...
 

Functions

AFAPI af_err af_create_memory_manager (af_memory_manager *out)
 Creates an af_memory_manager handle. More...
 
AFAPI af_err af_release_memory_manager (af_memory_manager handle)
 Destroys an af_memory_manager handle. More...
 
AFAPI af_err af_set_memory_manager (af_memory_manager handle)
 Sets an af_memory_manager to be the default memory manager for non-pinned memory allocations in ArrayFire. More...
 
AFAPI af_err af_set_memory_manager_pinned (af_memory_manager handle)
 Sets an af_memory_manager to be the default memory manager for pinned memory allocations in ArrayFire. More...
 
AFAPI af_err af_unset_memory_manager ()
 Reset the memory manager being used in ArrayFire to the default memory manager, shutting down the existing memory manager. More...
 
AFAPI af_err af_unset_memory_manager_pinned ()
 Reset the pinned memory manager being used in ArrayFire to the default memory manager, shutting down the existing pinned memory manager. More...
 
AFAPI af_err af_memory_manager_get_payload (af_memory_manager handle, void **payload)
 Gets the payload ptr from an af_memory_manager. More...
 
AFAPI af_err af_memory_manager_set_payload (af_memory_manager handle, void *payload)
 Sets the payload ptr from an af_memory_manager. More...
 
AFAPI af_err af_memory_manager_set_initialize_fn (af_memory_manager handle, af_memory_manager_initialize_fn fn)
 Sets an af_memory_manager_initialize_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_shutdown_fn (af_memory_manager handle, af_memory_manager_shutdown_fn fn)
 Sets an af_memory_manager_shutdown_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_alloc_fn (af_memory_manager handle, af_memory_manager_alloc_fn fn)
 Sets an af_memory_manager_alloc_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_allocated_fn (af_memory_manager handle, af_memory_manager_allocated_fn fn)
 Sets an af_memory_manager_allocated_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_unlock_fn (af_memory_manager handle, af_memory_manager_unlock_fn fn)
 Sets an af_memory_manager_unlock_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_signal_memory_cleanup_fn (af_memory_manager handle, af_memory_manager_signal_memory_cleanup_fn fn)
 Sets an af_memory_manager_signal_memory_cleanup_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_print_info_fn (af_memory_manager handle, af_memory_manager_print_info_fn fn)
 Sets an af_memory_manager_print_info_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_user_lock_fn (af_memory_manager handle, af_memory_manager_user_lock_fn fn)
 Sets an af_memory_manager_user_lock_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_user_unlock_fn (af_memory_manager handle, af_memory_manager_user_unlock_fn fn)
 Sets an af_memory_manager_user_unlock_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_is_user_locked_fn (af_memory_manager handle, af_memory_manager_is_user_locked_fn fn)
 Sets an af_memory_manager_is_user_locked_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_get_memory_pressure_fn (af_memory_manager handle, af_memory_manager_get_memory_pressure_fn fn)
 Sets an af_memory_manager_get_memory_pressure_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_jit_tree_exceeds_memory_pressure_fn (af_memory_manager handle, af_memory_manager_jit_tree_exceeds_memory_pressure_fn fn)
 Sets an af_memory_manager_jit_tree_exceeds_memory_pressure_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_add_memory_management_fn (af_memory_manager handle, af_memory_manager_add_memory_management_fn fn)
 Sets an af_memory_manager_add_memory_management_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_remove_memory_management_fn (af_memory_manager handle, af_memory_manager_remove_memory_management_fn fn)
 Sets an af_memory_manager_remove_memory_management_fn for a memory manager. More...
 
AFAPI af_err af_memory_manager_get_active_device_id (af_memory_manager handle, int *id)
 Gets the id of the currently-active device. More...
 
AFAPI af_err af_memory_manager_native_alloc (af_memory_manager handle, void **ptr, size_t size)
 Allocates memory with a native memory function for the active backend. More...
 
AFAPI af_err af_memory_manager_native_free (af_memory_manager handle, void *ptr)
 Frees a pointer with a native memory function for the active backend. More...
 
AFAPI af_err af_memory_manager_get_max_memory_size (af_memory_manager handle, size_t *size, int id)
 Gets the maximum memory size for a managed device. More...
 
AFAPI af_err af_memory_manager_get_memory_pressure_threshold (af_memory_manager handle, float *value)
 Gets the memory pressure threshold for a memory manager. More...
 
AFAPI af_err af_memory_manager_set_memory_pressure_threshold (af_memory_manager handle, float value)
 Sets the memory pressure threshold for a memory manager. More...