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.

MSMC cache issue?

Hi

Can I call CACHE_invL1d passing a big size? For example

(L1D is 32K)

CACHE_invL1d (addr, 7296, CACHE_WAIT)
CACHE_invL1d (addr, 32768, CACHE_WAIT)

I'm asking this because I have the following problem

2 Shared struct in MSCM, accessed by 8 cores, defined as follow

---------------------------------------------------
#pragma DATA_ALIGN (CACHE_L2_LINESIZE);
#pragma DATA_SECTION(".MSharedSram")
volatile Struct1 far gStruct1;


#pragma DATA_ALIGN (CACHE_L2_LINESIZE);
#pragma DATA_SECTION(".MSharedSram")
volatile Struct2 far gStruct2;
---------------------------------------------------

sizeof(Struct1) is 7284
sizeof(Struct2) is 32656

struct1 allocated at address 0x0C109880
struct2 allocated at address 0x0C10B500

both structs are accessed as follow (pseudo code)

{
while ((CSL_semAcquireDirect (HW_SEM)) == 0);

CACHE_invL1d ((void*)&x, sizeof(x), CACHE_WAIT);

x= x + 1;

CACHE_wbL1d ((void*)&x, sizeof(x), CACHE_WAIT);


CSL_semReleaseSemaphore (HW_SEM);
}

to access struct1 I use size 7296 (size multiple of the cache line size) 
for example: CACHE_invL1d (addr, 7296, CACHE_WAIT)

to access struct2 I use size 32768, CACHE_invL1d (addr, 32768, CACHE_WAIT)


At regular interval (for debug, interval = 1 second), 8 cores read/write the structs:
- struct1 is always read correctly
- sometimes struct2 is accessed wrongly, that is, cores read back OLD values(There is a counter inside the struct, I see counter not incrementing correctly)

I found 2 workaround

Workaround1:
By DISABLING cache, program runs correctly for hours, to stress the program I set interval to 2 ms

Workaround2:
Cache ENABLED, I create a dummy struct of size 128 between struct1 and struct2 as follow

------------------------------------------------
#pragma DATA_ALIGN (CACHE_L2_LINESIZE);
#pragma DATA_SECTION(".MSharedSram")
volatile Struct1 far gStruct1;

#pragma DATA_ALIGN (CACHE_L2_LINESIZE);
#pragma DATA_SECTION(".MSharedSram")
volatile DummyStruct far gDummyStruct;

#pragma DATA_ALIGN (CACHE_L2_LINESIZE);
#pragma DATA_SECTION(".MSharedSram")
volatile Struct2 far gStruct2;
-----------------------------------------------

new address in memory are:
struct1 0x0C109880
dummyStruct 0x0C10B500
struct2 0x0C10B580

at startup I fill gDummyStruct with a know pattern, and at runtime I check that this struct is never overwritten
program runs correctly for hours, to stress the program I set interval to 2 ms


any idea????????

Thank you

Fabio