www.ti.com
Data Memory
Guideline 1
Algorithms should minimize their persistent data memory requirements in favor of scratch memory.
In addition to the types of memory described above, there are often several memory spaces provided by a DSP to algorithms.
∙
∙
∙External memory is memory that is external to the DSP and may require more than zero wait states per access.
These memory spaces are often treated very differently by algorithm implementations; in order to optimize performance, frequently accessed data is placed in
2.3.3 Algorithm versus Application
Other than a memory block'ssize, alignment, and memory space, three independent questions must be answered before a client can properly manage a block of an algorithm'sdata memory.
∙Is the block of memory treated as scratch or persistent by the algorithm?
∙Is the block of memory shared by more than one algorithm?
∙Do the algorithms that share the block preempt one another?
The first question is determined by the implementation of the algorithm; the algorithm must be written with assumptions about the contents of certain memory buffers. We'veargued that there is significant benefit to distinguish between scratch memory and persistent memory, but it is up to the algorithm implementation to trade the benefits of increasing scratch, and decreasing persistent memory against the potential performance overhead incurred by
The second two questions regarding sharing and preemption, can only be answered by the client of an
There is a special type of persistent memory managed by clients of algorithms that is worth distinguishing: shadow memory is unshared persistent memory that is used to shadow or save the contents of shared registers and memory in a system. Shadow memory is not used by algorithms; it is used by their clients to save the memory regions shared by various algorithms.
Figure 2-2 illustrates the relationship between the various types of memory.
Figure 2-2. Data Memory Types
SharedPrivate
Scratch
Persistent
Shadow
22 | General Programming Guidelines | SPRU352G |