Hi Swapnil Haria,

Thanks for your kind reply, bellow is program which can be used to
reproduce the effect,

regards,
Usman Ali
MSEE Student, ITU, Lahore

#include <stdio.h>
#include <unistd.h>


int probe(void *addr) {
        volatile unsigned long time;
        asm __volatile__ (
                " mfence \n"
                " lfence \n"
                " rdtsc \n"
                " lfence \n"
                " movl %%eax, %%esi \n"
                " movl (%1), %%eax \n"
                " lfence \n"
                " rdtsc \n"
                " subl %%esi, %%eax \n"
                " clflush 0(%1) \n"
                : "=a" (time)
                : "c" (addr)
                : "%esi", "%edx");
        return time;    

}


int readOnly(void *addr) {
        volatile unsigned long time;
        asm __volatile__ (
                " mfence \n"
                " lfence \n"
                " rdtsc \n"
                " lfence \n"
                " movl %%eax, %%esi \n"
                " movl (%1), %%eax \n"
                " lfence \n"
                " rdtsc \n"
                " subl %%esi, %%eax \n"
                : "=a" (time)
                : "c" (addr)
                : "%esi", "%edx");
        return time;    

}

int main(void){
        
        int t=0, total = 0, n=100;

        int pO = 123456;
        void * p = &pO;
        
        for(int i=0; i < n; i++){
                
                if(i%2){
                
                        t = probe(p);
                        t = probe(p);
                        t = probe(p);
                
                }else{
                        t = readOnly(p);
                        t = readOnly(p);
                        t = readOnly(p);
                }
                
                printf("\n----Cycle: %d \n", t);
                
        }


        printf("Done --ud-- \n");               
        return 0;

        sleep(1);
}







// END of PROGRAM
_______________________________________________
gem5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to