Intel® FPGA SDK for OpenCL™ Pro Edition: Best Practices Guide
Visible to Intel only — GUID: mwh1391807499818
Ixiasoft
Visible to Intel only — GUID: mwh1391807499818
Ixiasoft
4.4. Allocating Aligned Memory
Aligning the host-side memories allows direct memory access (DMA) transfers to occur to and from the FPGA and improves buffer transfer efficiency.
To set up aligned memory allocations, add the following source code to your host program:
- For Windows:
#define AOCL_ALIGNMENT 64 #include <malloc.h> void *ptr = _aligned_malloc (size, AOCL_ALIGNMENT);
To free up an aligned memory block, include the function call _aligned_free(ptr);
- For Linux:
#define AOCL_ALIGNMENT 64 #include <stdlib.h> void *ptr = NULL; posix_memalign (&ptr, AOCL_ALIGNMENT, size);
To free up an aligned memory block, include the function call free(ptr);