//#include #include #include #include #include #include #include #include /* #include */ #if __UPC_TICK__ #include #endif static int64_t mygetMicrosecondTimeStamp(void) { #if __UPC_TICK__ return upc_ticks_to_ns(upc_ticks_now()) / 1000; #else int64_t retval; struct timeval tv; if (gettimeofday(&tv, NULL)) { perror("gettimeofday"); abort(); } retval = ((int64_t)tv.tv_sec) * 1000000 + tv.tv_usec; return retval; #endif } #define TIME() mygetMicrosecondTimeStamp() shared char *space; char *lptr; shared [10] char *sptr; shared [] char *pIsptr; shared char *p1sptr; int doit(int iters); int main(int argc, char **argv) { int iters = 10000; size_t blocks; if (argc > 1) iters = atoi(argv[1]); blocks = ((size_t)iters)*(iters+1)/20; space = (char shared *)upc_all_alloc(THREADS * blocks,10); if (!space) { printf("Unsufficient memory for %i iterations\n", iters); upc_global_exit(1); } sptr = (shared [10] char *)space; pIsptr = (shared [] char *)space; p1sptr = (shared char *)space; lptr = (char *)&lptr; /* this is bogus, but ok */ printf("Executing ptrmath tests with %i iters...\n",iters); doit(iters); upc_barrier; printf("done.\n"); return 0; } volatile shared [2] int sar[2*THREADS]; volatile shared int p1ar[THREADS]; volatile shared [] int pIar[100]; volatile int vlar[2]; volatile int lar[2]; volatile shared [2] double d_sar[2*THREADS]; volatile shared double d_p1ar[THREADS]; volatile shared [] double d_pIar[100]; volatile double d_vlar[2]; volatile double d_lar[2]; int doit(int iters) { shared [10] char * volatile mysptr = sptr; shared [10] char * volatile mysptr2 = sptr; char * volatile mylptr = lptr; char * volatile mylptr2 = lptr; shared char * volatile myp1sptr = p1sptr; shared char *volatile myp1sptr2 = p1sptr; shared [] char * volatile mypIsptr = pIsptr; shared [] char * volatile mypIsptr2 = pIsptr; int i; int x=0; volatile int j; volatile double dj; int64_t start,end; #define TIMEIT(desc, code) \ start = TIME(); \ for(i=0;i