Hi, everyone, I don't really know if it is proper to post this topic here.
In order to accelerate our applications, I adopted the PREFETCH instruction of UltraSparc. However, the results are not expected: the one with prefetch works even a little bit slower. The whole program is listed below. I read the Ultrasparc specification and found that "when executed in nonprivileged or privileged mode, PREFETCH has the same observable effect as a NOP". I don't know how to understand this sentence. What are the nonprivileged, privileged, and hyperprivileged modes in Linux? Could that be user mode and kernel mode? I mean, does it mean I can only make use of that instruction in kernel mode? Thanks a lot! testprefetch.c: #include <stdlib.h> #include <stdio.h> #include <sys/time.h> #define MEGA 1024*1024 #define TIMES 1 #define LASTITEM 100*MEGA-1 int main(){ struct timeval begin,end; register int i,j; int foo, bar; int *data=(int *)malloc(100*sizeof(int)*MEGA); //400MB in order to avoid being cached in L2 cache, which is 3M register int *buf, *lastone; lastone=&data[LASTITEM]; gettimeofday(&begin,NULL); for(i=0;i<TIMES;i++){ buf=data; while(buf<lastone){ __asm__ __volatile__("prefetch\t[%0], #n_writes"::"r"(buf)); __asm__ __volatile__("prefetch\t[%0], #n_writes"::"r"(buf+16)); __asm__ __volatile__("prefetch\t[%0], #n_writes"::"r"(buf+32)); __asm__ __volatile__("prefetch\t[%0], #n_writes"::"r"(buf+48)); for(j=0;j<100;j++) foo+=j; //do some trivial things to pass time bar=foo; *buf=i; *(buf+16)=i; *(buf+32)=i; *(buf+48)=i; buf+=64; } } gettimeofday(&end,NULL); printf("time in usec is %d\n",((end.tv_sec*1000000+end.tv_usec)-(begin.tv_sec*1000000+begin.tv_usec))); } -- Best regards, Jiaqi - To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html