Memory Attributes

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.

Physically Contiguous Memory

Important: The syntax and implementation of this pragma might be revised in a future release.
The syntax for this pragma is:
#pragma SDS data mem_attribute(ArrayName:contiguity)

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.

Some notes about the syntax:
  • ArrayName must be one of the formal arguments of the function definition.
  • Contiguity must be either PHYSICAL_CONTIGUOUS or NON_PHYSICAL_CONTIGUOUS. The default value is set to be NON_PHYSICAL_CONTIGUOUS.

    PHYSICAL_CONTIGUOUS means that all memory corresponding to the associated ArrayName is allocated using sds_alloc, while NON_PHYSICAL_CONTIGUOUS means that all memory corresponding to the associated ArrayName is allocated using malloc or as a free variable on the stack. This helps the SDSoC compiler select the optimal data mover.

  • Multiple arrays can be specified in one pragma, separated by commas.

Example 1

The following code snippet shows an example of specifying the 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.