NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Codec Engine skelCachingPolicy
The Server.skelCachingPolicy
feature was introduced in Codec Engine 2.25.02.
Introduction[edit]
For remote execution of codecs, the DSP server manages cache for I/O buffers exchanged between the codec (running on the DSP) and the ARM side app. The cache management is performed in the "skeleton" for the codec. The default cache management policy is for the skeleton to invalidate the input and output buffers from the DSP cache, before calling the codec's process() function. After returning from the process() function, the skeleton then performs a cache writeback of output buffers to ensure that CPU writes to the cache are flushed to external memory. Below is a section of code from the sphenc_skel.c illustrating the default caching policy:
<syntaxhighlight lang='c'> /* invalidate cache for all input buffers */ for (i = 0; i < inBufs.numBufs; i++) {
Memory_cacheInv(inBufs.bufs[i], inBufs.bufSizes[i]);
}
/* invalidate cache for all output buffers */ for (i = 0; i < outBufs.numBufs; i++) {
Memory_cacheInv(outBufs.bufs[i], outBufs.bufSizes[i]);
}
/* unmarshall outArgs based on the "size" of inArgs */ pOutArgs = (ISPHENC_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
msg->cmd.process.inArgs.size);
/* make the process call */ msg->visa.status = SPHENC_process(handle,
&inBufs, &outBufs, &(msg->cmd.process.inArgs), pOutArgs);
/* writeback the cache for all output buffers */ for (i = 0; i < outBufs.numBufs; i++) {
Memory_cacheWb(outBufs.bufs[i], outBufs.bufSizes[i]);
} </syntaxhighlight>
The default cache management policy is conservative in that it guarantees correctness, but it does not necessarily give optimal performance. For example, if the buffer sizes are very large, the cost of performing the Memory_cacheInv()
before processing and Memory_cacheWb()
after processing, may be greater than performing a single Memory_cacheWbInvAll()
after processing. However, to ensure correctness if the Memory_cacheInv()
and Memory_cacheWb()
calls are replaced with a single Memory_cacheWbInvAll()
, the system must ensure that the following conditions are met:
- The cache is clean before the first
process()
call - Input and output buffers are not touched by the local processor after the
Memory_cacheWbInv()
and before they are used in the nextprocess()
call.
The Server.skelCachingPolicy
feature allows the system designer to choose one of the three cache management policies used by the skeletons:
- The default policy, where
Memory_cacheInv()
is performed on input and output buffers before processing, andMemory_cacheWb()
is performed on output buffers after processing. - The wbInvAll policy, where no cache operations are performed before processing, and
Memory_cacheWBInvAll()
is performed after processing. - No cache management is performed in the skeletons.
Configuration[edit]
The Server module has an new configuration parameter, skelCachingPolicy, which can be set to one of the following values:
- LOCALBUFFERINVWB - The default policy that will be used if this configuration parameter is not set.
- WBINVALL - Skeletons perform only
Memory_cacheWbInvAll()
after processing. - NONE - No cache management performed in skeletons
Here is an example configuration in a server's configuration file:
<syntaxhighlight lang='javascript'> var Server = xdc.useModule('ti.sdo.ce.Server'); Server.skelCachingPolicy = Server.WBINVALL; </syntaxhighlight>