Go to the source code of this file.
Functions | |
| __VOLK_DECL_BEGIN VOLK_API void * | volk_malloc (size_t size, size_t alignment) |
Allocate size bytes of data aligned to alignment. More... | |
| VOLK_API void | volk_free (void *aptr) |
| Free's memory allocated by volk_malloc. More... | |
Free's memory allocated by volk_malloc.
| aptr | The aligned pointer allocaed by volk_malloc. |
| __VOLK_DECL_BEGIN VOLK_API void* volk_malloc | ( | size_t | size, |
| size_t | alignment | ||
| ) |
Allocate size bytes of data aligned to alignment.
Because we don't have a standard method to allocate buffers in memory that are guaranteed to be on an alignment, VOLK handles this itself. The volk_malloc function behaves like malloc in that it returns a pointer to the allocated memory. However, it also takes in an alignment specfication, which is usually something like 16 or 32 to ensure that the aligned memory is located on a particular byte boundary for use with SIMD.
Internally, the volk_malloc first checks if the compiler is C11 compliant and uses the new aligned_alloc method. If not, it checks if the system is POSIX compliant and uses posix_memalign. If that fails, volk_malloc handles the memory allocation and alignment internally.
Because of the ways in which volk_malloc may allocate memory, it is important to always free volk_malloc pointers using volk_free.
| size | The number of bytes to allocate. |
| alignment | The byte alignment of the allocated memory. |