int main (void) { int me, npes; long *dest; { time_t now; time (&now); srand (now + getpid ()); } start_pes (0); me = shmem_my_pe (); npes = shmem_n_pes (); dest = (long *) shmalloc (sizeof (*dest)); *dest = 9L; shmem_barrier_all (); if (me == 0) { int i; for (i = 0; i < 4; i += 1) { long src = 9L; shmem_long_put (dest, &src, 1, 1); fprintf (stderr, "PE %d put %d\n", me, src); } fprintf (stderr, "----------------------------\n"); for (i = 0; i < 1000; i += 1) { long src = rand () % 10; shmem_long_put (dest, &src, 1, 1); fprintf (stderr, "PE %d put %d\n", me, src); if (src != 9L) break; } } shmem_barrier_all (); if (me == 1) { shmem_long_wait (dest, 9L); fprintf (stderr, "PE %d finished wait, got %d\n", me, *dest); } shmem_barrier_all (); return 0; }
void FORTRANIFY (shmem_wait) (long *ivar, long *cmp_value) { shmem_long_wait (ivar, *cmp_value); }
void shmem_wait (long *ivar, long cmp_value) { shmem_long_wait (ivar, cmp_value); }