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.

C6670 Cache Operation

Hi, recently I encounter a cache-related problem. The application scenario is assumed as follow:

Presupposition 1)  two core2,  e.g. core#0 and core#1 are used.  In every core, all L1D space is configured as cache. 

Presupposition 2) an array char x[256] is defined in MCSM memory. Its starting address is  0x0c000000. Meanwhile, x[0] to x[32] will be accessed by core#0 and x[33] to x[255] by core#1. The accesses to x are simultaneous since core#0 and core#1 are running concurrently. 

Presupposition 3) the memory allocation is fixed in two cores.

In order to maintain the cache coherence, the function CACHE_wbL1d(Address, ByteCnt, WAIT) is used. But in core#0, the Address(i.e. 0x0c000000) is 64-Bytes aligned but the ByteCnt(i.e. 32) is not  64-Bytes. In core#0, the Address(i.e. 0x0c000020) and ByteCnt(i.e. 224) are both not 64-Bytes aligned.

The address and length alignment can not be reached through memory reallocation because of Presupposition 3), my solution is:

For core#0, since the ByteCnt is not  64-Bytes, therefore, more bytes, i.e. 64-Bytes is actually written back and CACHE_wbL1d(0x0c000000, 64, WAIT) is used. But more bytes are written back.

For core#1, since the Address and ByteCnt parameters are both not 64-Bytes aligned, therefore, the Address reduces to 0x0c000000 and ByteCnt incease to 256 and CACHE_wbL1d(0x0c000000, 256, WAIT) is used. But more bytes are written back.

My question is that whether my solution is correct or not? If not, how to solve the problem?  

In my understanding, if the written back of core#0 is first, perhaps the  date in x[0] to x[32] written by core#0 will be wiped off by core#1 and vice versa. Is my understand correct or not.

Thank you for your kind help !

 

  • Hello,

    I believe you intended x[31:0] for core 0 and x[255:32] for core 1 (not x[32:0] and x[255:33]) since you indicated 32B for core 0.

    That said, what you said is correct.  Since the cache line size is 64B and a minimum of a cache line is written back, Core 0 will trample the first 32B of Core 1's no matter what, and Core 1 would either be incomplete or trample all of Core 0's when the caching operations occur.

    You'll need to revisit Supposition #3.  You may wish to duplicate the array before processing, and then recombine via an EDMA/QDMA transfer after coherence operations are done if it's required that they end up in a common array for some reason.

    Best Regards,

    Chad