A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
allocHost
ArrayFire Functions | ArrayFire Functions by Category » Functions to create and modify Arrays » Managing devices in ArrayFire

Allocate memory on host More...

## Functions
AFAPI void * | allocHost (const size_t elements, const dtype type)
| Allocate memory on host.
template<typename T >
AFAPI T * | allocHost (const size_t elements)
| Allocate memory on host.
AFAPI af_err | af_alloc_host (void **ptr, const dim_t bytes)

## Detailed Description

Allocate memory on host

This function is used for allocating regular memory on host. This is useful where the compiler version of ArrayFire library is different from the executable's compiler version.

It does not use ArrayFire's memory manager.

## Function Documentation

## ◆ af_alloc_host()

AFAPI af_err af_alloc_host | ( | void ** | ptr,
|  | const dim_t | bytes )

## ◆ allocHost() [1/2]

template<typename T >

AFAPI T * allocHost | ( | const size_t | elements | ) |

Allocate memory on host.

Allocate memory on host

This function is used for allocating regular memory on host. This is useful where the compiler version of ArrayFire library is different from the executable's compiler version.

It does not use ArrayFire's memory manager.

Parameters

  [in] | elements | the number of elements to allocate

Returns
  the pointer to the memory

Note
  the size of the memory allocated is the number of `elements` * sizeof(type)

## ◆ allocHost() [2/2]

AFAPI void * allocHost | ( | const size_t | elements,
|  | const dtype | type )

Allocate memory on host.

Allocate memory on host

This function is used for allocating regular memory on host. This is useful where the compiler version of ArrayFire library is different from the executable's compiler version.

It does not use ArrayFire's memory manager.

Parameters

  [in] | elements | the number of elements to allocate
  [in] | type | is the type of the elements to allocate

Returns
  the pointer to the memory