Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Codec Engine skelCachingPolicy

From Texas Instruments Wiki
Jump to: navigation, search

The Server.skelCachingPolicy feature was introduced in Codec Engine 2.25.02.

Introduction

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:

/* 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]);
}

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 next process() 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, and Memory_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

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:

var Server = xdc.useModule('ti.sdo.ce.Server');
Server.skelCachingPolicy = Server.WBINVALL;

See Also