[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[microblaze-uclinux] another compiler oddity



Hi,

one of my co-worker found this.  in a flat funciton, accessing block
ram is _slower_ thank dram.  if you make inner loop a function, block
ram is faster as i expected.

any thoughts?
--
             yashi


#include<stdio.h>
#include<sys/time.h>

#define BRAM_START 0x00001000
#define BRAM_SIZE  0x00001000
#define NR_TEST    100000

volatile unsigned char dram[BRAM_SIZE];
volatile unsigned char *bram=(unsigned char *)BRAM_START;

struct timeval start, stop;

print_time(void)
{
        time_t sec;
        suseconds_t usec;

        sec  = stop.tv_sec  - start.tv_sec;
        usec = stop.tv_usec - start.tv_usec;
        if(usec < 0){
                usec += 1000000;
                sec--;
        }
        printf("Elapsed time : %ld.%ld\n", sec, usec);
}

#if 0

int main(void)
{
        int i,j,k;

        gettimeofday(&start, NULL);
        for (i=0; i<NR_TEST; i++)
                *(dram) = i;
        gettimeofday(&stop, NULL);
        print_time();


        gettimeofday(&start, NULL);
        for (i=0; i<NR_TEST; i++)
                *(bram) = i;
        gettimeofday(&stop, NULL);
        print_time();


}

#else

static inline void do_test(volatile unsigned char *addr)
{
        int i,j;

        gettimeofday(&start, NULL);
        for (i=0; i<NR_TEST; i++)
                *(addr) = i;
        gettimeofday(&stop, NULL);
        print_time();
}

int main(void)
{
        do_test(dram);
        do_test(bram);

        return 0;
}

#endif
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@itee.uq.edu.au
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/