This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11 #include <shmem.h>
12 #include <stdio.h>
13
14 #if !defined(OSHMEM_SPEC_VERSION) || OSHMEM_SPEC_VERSION < 10200
15 #error This application uses API 1.2 and up
16 #endif
17
18 int main (int argc, char * argv[])
19 {
20 static int rbuf = -1;
21 int proc, nproc, next;
22 int message = 10;
23
24 shmem_init();
25 nproc = shmem_n_pes();
26 proc = shmem_my_pe();
27
28
29
30
31 next = (proc + 1) % nproc;
32
33 if(proc == 0)
34 {
35 printf("Process 0 puts message %d to %d (%d processes in ring)\n", message, next, nproc);
36 shmem_int_put(&rbuf, &message, 1, next);
37 }
38
39
40
41
42
43
44
45
46
47 while(message > 0) {
48 shmem_int_wait_until(&rbuf, SHMEM_CMP_EQ, message);
49 if(proc == 0) {
50 --message;
51 printf("Process 0 decremented value: %d\n", message);
52 }
53 shmem_int_put(&rbuf, &message, 1, next);
54 if(proc != 0) {
55 --message;
56 }
57 }
58 shmem_finalize();
59
60
61
62 printf("Process %d exiting\n", proc);
63
64 return 0;
65 }