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.

Measuring Cycles in 64x+ processor

Hi all,

 

Iam using the Omap 3530 Beagle board as my target board and connected to 64x+ DSP processor through JTAG. Here I used the clock() function for measuring the cycles for sample program written below. The cycles is measured for two cases, for first case mapped the program memory to place in external memory and for second case mapped the program memory to place in internal memory. I used some cache config registers in program to use L1P & L1D cache with 32K size and given cachebility permissions to memory region i mapped in external memory.

 

    .global _cache_config
    .global    _cache_inv
   
_cache_config:

    ; L1P

    MVKL    0x1840020, A5
    MVKH    0x1840020, A5

    MVK        1, A6
    STW        A6, *+A5[0]            ; 32k cache


    ;L1D

    MVKL    0x1840040, A5
    MVKH    0x1840040, A5

    MVK        4, A6
    STW        A6, *+A5[0]            ; 32k cache


;L2

    MVKL    0x1840000, A5
    MVKH    0x1840000, A5

    MVK        2, A6
   
    STW        A6, *+A5[0]            ; 64k cache


    ; enable ext mem. cachebility

    ;MVKL    0x184804C, A5
    ;MVKH    0x184804C, A5        ;0x30000000 cacheble
    MVKL    0x1848200, A5
    MVKH    0x1848200, A5
    MVK        1, A6
    STW        A6, *+A5[0]            ; 0x8000000 cacheble
   
    B    B3
    NOP 5


_cache_inv:

    ; L1P

    MVKL    0x1845028, A5
    MVKH    0x1845028, A5

    MVK        1, A6
    STW        A6, *+A5[0]



    ; L1D

    MVKL    0x1845044, A5
    MVKH    0x1845044, A5

    MVK        1, A6
    STW        A6, *+A5[0]


    ; L2

    MVKL    0x1845004, A5
    MVKH    0x1845004, A5

    MVK        1, A6
    STW        A6, *+A5[0]




    B        B3
    NOP        5

 

 

#include <stdio.h>

void cache_config(void);

void add(int a,int b,int c)
{   
    c = a+b;
    b = a+c;
    a = c;
    b = a+c;
    a = a+c;
}

int main()
{
    unsigned int i,count1=0,count2=0,total=0;
    int arr[10]={1,10,2,3,4,5,6,7,8,9}, key=10, k=0;

    cache_inv();
    cache_config();
    count1 = clock();
   
    for(k=0;k<100;k++)
    {
        add(10,20,30);
        for(i=0;i<10;i++)
        {           
            arr[i+1]=arr[i];
        }
        for(i=0;i<10;i++)
        {
                key=key*9;
                arr[i]=arr[i+2]*arr[i+1];
        }
    }
   
    count2 = clock();
    total = count2 - count1;
   
    printf("\nHelloworld");
   
    printf("Total cycles : %d",total);
    return 0;
}

Case 1: this is for external memory

cycles =  1951   (with cache configuration)

cycles =  38,840  (with out cache configuration)

 

case 2: this is for internal memory

cycles = 50,650

cycles = 64,259

 

My question is that the cycles I got for placing program in external memory is correct or else I need to do any other work?

2. The cycles i got for second case is comparitively more than the cycles I got in external memory why this happens?

 

so any one help in this one and tell me the reason why it will happen for internal memory...

Thanks in advance,

Vinay.