pragma SDS data mem_attribute
Description
This pragma must be specified immediately preceding a function declaration, or immediately
preceding another #pragma SDS
bound to the function declaration. This
pragma applies to all the callers of the function.
For an operating system like Linux that supports virtual memory, user-space allocated memory is paged, which can affect system performance. SDSoC runtime also provides API to allocate physically contiguous memory. The pragmas in this section can be used to tell the compiler whether the arguments have been allocated in physically contiguous memory.
Syntax
#pragma SDS data mem_attribute(ArrayName:contiguity)
ArrayName
: Specifies one of the formal parameters of the function to assign the pragma to.Contiguity
: Must be specified as either PHYSICAL_CONTIGUOUS or NON_PHYSICAL_CONTIGUOUS. The default value is NON_PHYSICAL_CONTIGUOUS:- PHYSICAL_CONTIGUOUS means that all memory
corresponding to the associated
ArrayName
is allocated usingsds_alloc
. - NON_PHYSICAL_CONTIGUOUS means that all memory
corresponding to the associated
ArrayName
is allocated usingmalloc
or as a free variable on the stack. This helps the SDSoC compiler select the optimal data mover.
- PHYSICAL_CONTIGUOUS means that all memory
corresponding to the associated
- Multiple arrays can be specified in one pragma, separated by a comma
(,). For example:
#pragma SDS data mem_attribute(ArrayName:contiguity, ArrayName:contiguity)
Example 1
contiguity
attribute:#pragma SDS data mem_attribute(A:PHYSICAL_CONTIGUOUS)
void foo(int A[1024], int B[1024])
In the above example, the user tells the SDSoC compiler that array A
is allocated in the memory block that is physically contiguous.
The SDSoC compiler then chooses AXI_DMA_Simple instead of
AXI_DMA_SG, because the former is smaller and faster at transferring physically
contiguous memory.