/* © Copyright The University of Edinburgh 2011 */ #include #include #include int main(int argc, char *argv) { static shared int x[THREADS]; int i; // Each image initialises its value of x x[MYTHREAD] = MYTHREAD; // Sync to ensure that each image has written // to its x before master accesses upc_barrier; // Master thread if ( MYTHREAD == 0 ) { // Loops over threads and print remote x for(i=1; i < THREADS; i++) printf("Value of x on image %3d = %3d\n", i, x[i]); } exit(EXIT_SUCCESS); }