This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

allocate a buffer into a cache memory

Hello,

First, I'm using the dm6437 processor. I want to know if it's possible to create/allocate a specific buffer into a cache memory (L1D ,L1P or L2 )?

 

If yes, I want to know if I can make this by using the DSP/BIOS configuration, because there are an icon in the .tcf file which named "BUF-buffer Manager" (in the system option) I'm guessing that it's done for buffer allocation or something like this.

 

Regards,

  • Hot snow said:
    First, I'm using the dm6437 processor. I want to know if it's possible to create/allocate a specific buffer into a cache memory (L1D ,L1P or L2 )?

    While you cannot allocate into cache memory directly (the cache simply cannot be accessed directly), you can allocate into internal memory which is not configured as cache. There are actually a few ways of doing this, it can be done statically (at link time) or dynamically (at run time).

    If you wanted to do this statically with a globally declared buffer, you could use the DATA_SECTION pragma as discussed in section 6.8.4 of SPRU187. In this method you would essentially have some internal memory defined in your linker command file (or by way of your memory map in the BIOS configuration file), and than you would mark your buffer/array with the pragma, assigning it to the internal section. With this method you would have a constant area of internal memory for the buffer.

    If you wanted to do this dynamically you could use the MEM_alloc() as discussed in section 2.17 of SPRU403. In this case you would have to define a heap in an internal memory segment in your BIOS configuration file which you can allocate out of at run time. To do the allocation internally you just have to pass MEM_alloc the appropriate memory segment identifier so that it knows to allocate in the internal heap.

    The other dynamic option is to use the BUF capabilities as you suggest, this feature is discussed in section 2.3 of SPRU403. The BUF module gives you a more deterministic buffer allocation capability that is generally lighter weight than a malloc like allocation like MEM_alloc which uses an actual heap.

  • Thank you for your detailed explanation...

    In fact, I'm asking about this because we are using a "video_preview" application and the image processing  in our application very slow. So, we have decided to allocate a buffer into the cache memory to allocate the input image in order to make the image processing more higher.

    In fact, I'm wondering if allocating a buffer into the internal memory is more efficient than to allocate it into the external memory or no? (I'm speaking about the speed of execution).

  • Hot snow said:
    In fact, I'm wondering if allocating a buffer into the internal memory is more efficient than to allocate it into the external memory or no?



    In general the answer is yes, having everything you can have in internal memory will be faster than external memory, you want the most used code and data allocated internally if possible. 

    However, the optimal solution may not be to allocate buffers in internal memory manually since there is a limited amount of internal RAM available, in particular disabling cache memory to make it into addressable SRAM may not improve performance depending on your system and algorithms. As long as you keep the cache fully allocated, and are just using some of the extra L1D space, that would be a good place to start to see how efficient it will be. Also keep in mind that the internal memory on the DM6437 device is relatively small, you would not be able to fit a SDTV sized frame internally, as a D1 NTSC SDTV frame will be 720x480x2=691KB, so you would have to copy chunks in and out of DDR2 space anyway, which is why the cache usually does a reasonable job compared to internal allocations.