Intel® FPGA SDK for OpenCL™ Pro Edition: Programming Guide

ID 683846
Date 6/21/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

5.3. Programming Strategies for Optimizing Pointer-to-Local Memory Size

When using a pointer-to-local kernel argument to create a local memory allocation, the Intel® FPGA SDK for OpenCL™ Offline Compiler must decide at compilation time (not runtime) on the size of the local memory system to build on the FPGA. This specification allows the offline compiler to build the correctly sized local memory system for the pointer argument. If you do not specify a size, the offline compiler uses the default size.
To specify a size other than the default of 16 kilobytes (kB), include the local_mem_size(N) attribute in the pointer declaration within your kernel source code, where the value N specifies the desired memory size in bytes. The N value should be a power of 2.
For example:
__kernel void myLocalMemoryPointer(
                  __local float * A,
                  __attribute__((local_mem_size(1024))) __local float * B,
                  __attribute__((local_mem_size(32768))) __local float * C)
{
	//statements
}

In the myLocalMemoryPointer kernel, 16 kB of local memory (default) is allocated to pointer A, 1 kB is allocated to pointer B, and 32 kB is allocated to pointer C.

Attention: Instead of using pointer-to-local kernel arguments, Intel® recommends that you define local memory systems within the kernel scope.