A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
Native Memory Interface
ArrayFire Functions by Category » Memory Management

Native alloc, native free, get device id, etc. More...

## Functions
AFAPI af_err | af_memory_manager_get_active_device_id (af_memory_manager handle, int *id)
| Gets the id of the currently-active device.
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.
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.
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.
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.
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.

## Detailed Description

Native alloc, native free, get device id, etc.

## Function Documentation

## ◆ af_memory_manager_get_active_device_id()

AFAPI af_err af_memory_manager_get_active_device_id | ( | af_memory_manager | handle,
|  | int * | id )

Gets the id of the currently-active device.

Parameters

  [in] | handle | the af_memory_manager handle
  [out] | id | the id of the active device

Returns
  AF_SUCCESS

## ◆ af_memory_manager_get_max_memory_size()

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.

Parameters

  [in] | handle | the af_memory_manager handle
  [out] | size | the max memory size for the device
  [in] | id | the device id

Returns
  AF_SUCCESS

## ◆ af_memory_manager_get_memory_pressure_threshold()

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.

Parameters

  [in] | handle | the af_memory_manager handle
  [out] | value | the memory pressure threshold

Returns
  AF_SUCCESS

## ◆ af_memory_manager_native_alloc()

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.

Parameters

  [in] | handle | the af_memory_manager handle
  [out] | ptr | the pointer to the allocated buffer (for the CUDA and CPU backends). For the OpenCL backend, this is a pointer to a cl_mem, which can be cast accordingly
  [in] | size | the size of the pointer allocation

Returns
  AF_SUCCESS

## ◆ af_memory_manager_native_free()

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.

Parameters

  [in] | handle | the af_memory_manager handle
  [in] | ptr | the pointer to free

Returns
  AF_SUCCESS

## ◆ af_memory_manager_set_memory_pressure_threshold()

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.

The memory pressure threshold determines when the JIT tree evaluates based on how much memory usage there is. If the value returned by af_memory_manager_get_memory_pressure_fn exceeds the memory pressure threshold, the JIT will evaluate a subtree if generated kernels are valid.

Parameters

  [in] | handle | the af_memory_manager handle
  [in] | value | the new threshold value

Returns
  AF_SUCCESS