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.

Understanding Cache c6747

Other Parts Discussed in Thread: OMAP-L137, SYSBIOS

I am trying to understand the Cache performance of c6747 DSP. When I try out I  get same no. cycles when memory is accessed First time and later. How is it possible. How do I confirm that Cache is working? 

If I set the L1DCFG to 0K memory setting, then there is no change in the number of cycles. I still get same number of cycles. 

 

Can anyone explain how to derive it. I need these metrics to evaluate the number of additional MIPS required for the overall voip algorithms because of memory accesses. 

Regards,

Hari

 

 

 

 

 

#pragma CODE_SECTION(testWrite, ".L1Code:testWrite")

void testWrite(char *pBuf, int len)

{

register int  i;

register int  *ptr = (int *) pBuf;

for (i=0;i<len/4;i++)

{

ptr[i]=i;

}

 

}

 

 

#pragma CODE_SECTION(testRead, ".L1Code:testRead")

void testRead(char *pBuf, int len)

{

register int i,j;

register int *ptr = (int *) pBuf;

for (i=0;i<len/4;i++)

{

j=ptr[i];

}

 

}

 

 

main()

{

BCACHE_wbInvAll(); // 7.7K cycles

 

// testWrite(Externbuf,SIZE_OF_ARR);

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

 

testWrite(Externbuf,SIZE_OF_ARR);// 20K cycles  for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testWrite(Externbuf,SIZE_OF_ARR);// 20K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

testWrite(Externbuf,SIZE_OF_ARR);// 20K cycles for 4K byte array

testRead(Externbuf,SIZE_OF_ARR);// 17K cycles for 4K byte array

}

  • You don't say where the Externbuf is located.  I can see that you have changed one of the MAR registers (looks like 0x0000000f but hard to tell, the image is really small).  Does that MAR register correspond to Externbuf?  If not, you need to set the MAR for Externbuf to enable accesses to it to be cached.

    Regards,

    - Rob

  • Yes. Externbuf is @ 0xC0000000 4K Buffer size. 

    And MAR register is 0x0000000F --------> correct for MAR 128-159 

     

     

     

    #include <std.h>

    #include <bcache.h>

     

    #define SIZE_OF_ARR (1024*4)

    #pragma DATA_SECTION(L1buf, ".L1Data:L1buf")

    char L1buf[SIZE_OF_ARR];

    #pragma DATA_SECTION(L2buf, ".L2Data:L2buf")

    char L2buf[SIZE_OF_ARR];

    #pragma DATA_SECTION(Externbuf, ".DDRData:Externbuf")

    char Externbuf[SIZE_OF_ARR];

     

     

  • I tried further making L1D cache and L1P cache memory is 0K. Even then I get the same cycles. Here in my program, this function is resident in L1P memory. I guess cache is not required for this part of the code. Currently only L2 Cache is enabled. 

     

     

     

  • FYI, and it looks like you corrected it, MARs 128-159 control memory addresses 0x80000000 -> 0x9fffffff.  To allow cacheing of memory at 0xc0000000 you need to enable MAR 192, and I see from your screenshot above that you have enabled cacheing for 0xc0000000 -> 0xdfffffff (MAR 192-223).

    Even though L1 caches are off in your latest post, DDR access *should* be getting cached in the L2 cache, as long as the MAR bit for that DDR address is set (which it appears to be).  I have no explanation, based on what you've provided.

    Regards,

    - Rob

  • Hari,

    Some basic questions first:

    1.  How are you benchmarking the cycles?  Are you using a BIOS CLK_gethtime()  API to do this?

    2.  Have you confirmed that your board is running at the correct frequency as your BIOS config file?

    Now that we have those basic questions out of the way:

    3.  Make sure your MAR registers are corect which they appear to be from the screen shot above.

    4.  One way you might be able to confirm if things are getting cached is If you are using CCS, it should show you whether a memory is cached in L1 or L2 or not cached at all.  Typically these are color coded.  You should be able to see this in a CCS memory window.

    5.  If that still doesn't help...please check to make sure the Cache Registers are set accordingly. 

                          L2 register = 0x01840000.  L1P register = 0x01840020, L1D register = 0x01840040. 

        A value of 0 means Cache is not enabled.  Any value > 0 means some amount of cache is enabled.

    Judah

  • 1. CCS 3.3 Profile -> clock -> Enable

                           Profile -> clock -> View

    (At the right bottom corner of the screen) clock cycles are displayed. 

     

    2. I guess the cycle count is ok. The major problem is that if set L1, L1P Cache memory G3252.Evm6747.ziplobal settings to 0 in TCF file, the count should increase, that never happens. 

     

    3. MAR bits are set for 192 and 128 as 0xFFFFFFFF as shown in previous log. 

    4. I never see the color changing. 

    5. REgister display Values > 0

  • Hari,

    It looks like the Cache should be enabled but you aren't able to verify that it is.  I really don't have any other things that you can look at this point.  One question I did have was:  Why does 0x01840020 and 0x01840040 showing 0x2 when you set them to 0 in your .tcf file?

    My suggestions at this point are:

    1.  Can you try a different and simpler program to see if you can see that the cache is working?  Don't do any BCACHE calls, just put an array in external memory and read/write to it.  Again, use CCS memory view to see if you can see it cached.

    2.  You can try using the BCACHE runtime API's for setting the Cache sizes of L1P, L1D, and L2.

    Judah

  • I am using EVM OMAP-L137 running the c6747 Can you pl. suggest any changes. Meanwhile I shall try to simplify the program. I tried with/without BCACHE calls. I still see no difference. 

    7652.Evm6747.zip

  • Hari,

    I'm not sure what to suggest at this point but I ran a couple of Cache benchmark tests and it shows that stuff in DDR is slower for big buffers.

    Judah

    7181.cache_benchmark_test.txt

  • Thanks for the analysis. Can you provide me these example programs, so that I can run similarly on my evm and modify. Appreciate your help. 

    Cache while copying from External memory to Internal and viceversa. 

    Regards,

    Hari

     

  • Hari,

    Here are some test examples.  These are from SYSBIOS 6.x.  If you are using BIOS 5.x you will need to port it to the BIOS 5.x API's.

    7823.tests.zip

    Judah