/* sobel-opt-prefetch.c * * Sobel function with remote data prefetching in local-shared memory (that's * why `localrow' is declared as a pointer to shared data). * (should be included in sobel.c) * * $Source: bitbucket.org:berkeleylab/upc-runtime.git/upc-tests/benchmarks/gwu_bench/sobel/sobel-opt-prefetch.c $ */ #define STRUCTSIZE 6 typedef struct { BYTET a[STRUCTSIZE]; } cpstruct; /* Bytes left after last STUCTSIZE chunk has been copied */ #define REMAINDER (IMGSIZE%STRUCTSIZE) #ifdef STATIC_ALLOC shared[IMGSIZE] BYTET localrow[THREADS][IMGSIZE]; #else shared[] BYTET* shared localrow[THREADS]; /* zero init (ANSI C) */ #endif int Sobel(void) { int i,j,d1,d2; double magnitude; shared BYTET* p_orig0; shared BYTET* p_orig1; shared BYTET* p_orig2; shared BYTET* p_edge; #ifndef STATIC_ALLOC if(localrow[MYTHREAD]==NULL) # ifdef __UPC_VERSION__ // UPC version 1.1 or higher localrow[MYTHREAD] = (shared[] BYTET*)upc_alloc(IMGSIZE * sizeof(BYTET)); # else localrow[MYTHREAD] = (shared[] BYTET*)upc_local_alloc(IMGSIZE, sizeof(BYTET)); # endif #endif upc_forall(i=1; i255? 255:(unsigned char)magnitude; } } return 0; } /* vi:ts=2:ai */