MAGMA  2.7.1
Matrix Algebra for GPU and Multicore Architectures
 All Classes Files Functions Friends Groups Pages
Allocate CPU host memory

imalloc_cpu, smalloc_cpu, etc. More...

Functions

static magma_int_t magma_imalloc_cpu (magma_int_t **ptr_ptr, size_t n)
 Type-safe version of magma_malloc_cpu(), for magma_int_t arrays. Allocates n*sizeof(magma_int_t) bytes.
 
static magma_int_t magma_index_malloc_cpu (magma_index_t **ptr_ptr, size_t n)
 Type-safe version of magma_malloc_cpu(), for magma_index_t arrays. Allocates n*sizeof(magma_index_t) bytes.
 
static magma_int_t magma_uindex_malloc_cpu (magma_uindex_t **ptr_ptr, size_t n)
 Type-safe version of magma_malloc_cpu(), for magma_uindex_t arrays. Allocates n*sizeof(magma_uindex_t) bytes.
 
static magma_int_t magma_smalloc_cpu (float **ptr_ptr, size_t n)
 Type-safe version of magma_malloc_cpu(), for float arrays. Allocates n*sizeof(float) bytes.
 
static magma_int_t magma_dmalloc_cpu (double **ptr_ptr, size_t n)
 Type-safe version of magma_malloc_cpu(), for double arrays. Allocates n*sizeof(double) bytes.
 
static magma_int_t magma_cmalloc_cpu (magmaFloatComplex **ptr_ptr, size_t n)
 Type-safe version of magma_malloc_cpu(), for magmaFloatComplex arrays. Allocates n*sizeof(magmaFloatComplex) bytes.
 
static magma_int_t magma_zmalloc_cpu (magmaDoubleComplex **ptr_ptr, size_t n)
 Type-safe version of magma_malloc_cpu(), for magmaDoubleComplex arrays. Allocates n*sizeof(magmaDoubleComplex) bytes.
 
magma_int_t magma_malloc_cpu (void **ptrPtr, size_t size)
 Allocate size bytes on CPU. More...
 
magma_int_t magma_free_cpu (void *ptr)
 Frees CPU memory previously allocated by magma_malloc_cpu(). More...
 

Detailed Description

imalloc_cpu, smalloc_cpu, etc.

Function Documentation

magma_int_t magma_malloc_cpu ( void **  ptrPtr,
size_t  size 
)

Allocate size bytes on CPU.

The purpose of using this instead of malloc is to properly align arrays for vector (SSE, AVX) instructions. The default implementation uses posix_memalign (on Linux, MacOS, etc.) or _aligned_malloc (on Windows) to align memory to a 64 byte boundary (typical cache line size). Use magma_free_cpu() to free this memory.

Parameters
[out]ptrPtrOn output, set to the pointer that was allocated. NULL on failure.
[in]sizeSize in bytes to allocate. If size = 0, allocates some minimal size.
Returns
MAGMA_SUCCESS
MAGMA_ERR_HOST_ALLOC on failure

Type-safe versions avoid the need for a (void**) cast and explicit sizeof.

See Also
magma_smalloc_cpu
magma_dmalloc_cpu
magma_cmalloc_cpu
magma_zmalloc_cpu
magma_imalloc_cpu
magma_index_malloc_cpu
magma_int_t magma_free_cpu ( void *  ptr)

Frees CPU memory previously allocated by magma_malloc_cpu().

The default implementation uses free(), which works for both malloc and posix_memalign. For Windows, _aligned_free() is used.

Parameters
[in]ptrPointer to free.
Returns
MAGMA_SUCCESS
MAGMA_ERR_INVALID_PTR on failure