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 SDSbound to the function declaration. This pragma applies to all the callers of the function.

Some notes about the syntax:
  • ArrayNamemust be one of the formal arguments of the function definition.
  • Contiguitymust 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 associatedArrayNameis allocated usingsds_alloc, while NON_PHYSICAL_CONTIGUOUS means that all memory corresponding to the associatedArrayNameis allocated usingmallocor 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 contiguityattribute:
#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 arrayAis 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.