~ubuntu-branches/ubuntu/vivid/mpich/vivid-proposed

« back to all changes in this revision

Viewing changes to test/mpi/rma/manyrma2.c

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-04-01 20:24:20 UTC
  • mfrom: (5.2.4 sid)
  • Revision ID: package-import@ubuntu.com-20140401202420-t5ey1ia2klt5dkq3
Tags: 3.1-4
* [c3e3398] Disable test_primitives, which is unreliable on some platforms.
            (Closes: #743047)
* [265a699] Add minimal autotest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
/* This test is a simplification of the one in perf/manyrma.c that tests
8
8
   for correct handling of the case where many RMA operations occur between
9
9
   synchronization events.
10
 
   This is one of the ways that RMA may be used, and is used in the 
 
10
   This is one of the ways that RMA may be used, and is used in the
11
11
   reference implementation of the graph500 benchmark.
12
12
*/
13
13
#include "mpi.h"
16
16
#include <string.h>
17
17
 
18
18
#define MAX_COUNT 65536*4/16
19
 
#define MAX_RMA_SIZE 2 /* 16 in manyrma performance test */
 
19
#define MAX_RMA_SIZE 2  /* 16 in manyrma performance test */
20
20
#define MAX_RUNS 10
 
21
#define MAX_ITER_TIME  5.0      /* seconds */
21
22
 
22
 
typedef enum { SYNC_NONE=0, 
23
 
               SYNC_ALL=-1, SYNC_FENCE=1, SYNC_LOCK=2, SYNC_PSCW=4 } sync_t;
24
 
typedef enum { RMA_NONE=0, RMA_ALL=-1, RMA_PUT=1, RMA_ACC=2, RMA_GET=4 } rma_t;
 
23
typedef enum { SYNC_NONE = 0,
 
24
    SYNC_ALL = -1, SYNC_FENCE = 1, SYNC_LOCK = 2, SYNC_PSCW = 4
 
25
} sync_t;
 
26
typedef enum { RMA_NONE = 0, RMA_ALL = -1, RMA_PUT = 1, RMA_ACC = 2, RMA_GET = 4 } rma_t;
25
27
/* Note GET not yet implemented */
26
28
/* By default, run only a subset of the available tests, to keep the
27
29
   total runtime reasonably short.  Command line arguments may be used
31
33
 
32
34
static int verbose = 0;
33
35
 
34
 
void RunAccFence( MPI_Win win, int destRank, int cnt, int sz );
35
 
void RunAccLock( MPI_Win win, int destRank, int cnt, int sz );
36
 
void RunPutFence( MPI_Win win, int destRank, int cnt, int sz );
37
 
void RunPutLock( MPI_Win win, int destRank, int cnt, int sz );
38
 
void RunAccPSCW( MPI_Win win, int destRank, int cnt, int sz, 
39
 
                 MPI_Group exposureGroup, MPI_Group accessGroup );
40
 
void RunPutPSCW( MPI_Win win, int destRank, int cnt, int sz, 
41
 
                 MPI_Group exposureGroup, MPI_Group accessGroup );
 
36
void RunAccFence(MPI_Win win, int destRank, int cnt, int sz);
 
37
void RunAccLock(MPI_Win win, int destRank, int cnt, int sz);
 
38
void RunPutFence(MPI_Win win, int destRank, int cnt, int sz);
 
39
void RunPutLock(MPI_Win win, int destRank, int cnt, int sz);
 
40
void RunAccPSCW(MPI_Win win, int destRank, int cnt, int sz,
 
41
                MPI_Group exposureGroup, MPI_Group accessGroup);
 
42
void RunPutPSCW(MPI_Win win, int destRank, int cnt, int sz,
 
43
                MPI_Group exposureGroup, MPI_Group accessGroup);
42
44
 
43
 
int main( int argc, char *argv[] )
 
45
int main(int argc, char *argv[])
44
46
{
45
 
    int arraysize, i, cnt, sz, maxCount=MAX_COUNT, *arraybuffer;
 
47
    int arraysize, i, cnt, sz, maxCount = MAX_COUNT, *arraybuffer;
46
48
    int wrank, wsize, destRank, srcRank;
47
49
    MPI_Win win;
48
50
    MPI_Group wgroup, accessGroup, exposureGroup;
49
 
    int    maxSz = MAX_RMA_SIZE;
50
 
 
51
 
    MPI_Init( &argc, &argv );
52
 
 
53
 
    for (i=1; i<argc; i++) {
54
 
        if (strcmp( argv[i], "-put" ) == 0) {
55
 
            if (rmaChoice == RMA_ALL) rmaChoice = RMA_NONE;
56
 
            rmaChoice  |= RMA_PUT;
57
 
        }
58
 
        else if (strcmp( argv[i], "-acc" ) == 0) {
59
 
            if (rmaChoice == RMA_ALL) rmaChoice = RMA_NONE;
60
 
            rmaChoice  |= RMA_ACC;
61
 
        }
62
 
        else if (strcmp( argv[i], "-fence" ) == 0) {
63
 
            if (syncChoice == SYNC_ALL) syncChoice = SYNC_NONE;
64
 
            syncChoice |= SYNC_FENCE;
65
 
        }
66
 
        else if (strcmp( argv[i], "-lock" ) == 0) {
67
 
            if (syncChoice == SYNC_ALL) syncChoice = SYNC_NONE;
68
 
            syncChoice |= SYNC_LOCK;
69
 
        }
70
 
        else if (strcmp( argv[i], "-pscw" ) == 0) {
71
 
            if (syncChoice == SYNC_ALL) syncChoice = SYNC_NONE;
72
 
            syncChoice |= SYNC_PSCW;
73
 
        }
74
 
        else if (strcmp( argv[i], "-maxsz" ) == 0) {
75
 
            i++;
76
 
            maxSz = atoi( argv[i] );
77
 
        }
78
 
        else if (strcmp( argv[i], "-maxcount" ) == 0) {
79
 
            i++;
80
 
            maxCount = atoi( argv[i] );
81
 
        }
82
 
        else {
83
 
            fprintf( stderr, "Unrecognized argument %s\n", argv[i] );
84
 
            fprintf( stderr, "%s [ -put ] [ -acc ] [ -lock ] [ -fence ] [ -pscw ] [ -maxsz msgsize ]\n", argv[0] );
85
 
            MPI_Abort( MPI_COMM_WORLD, 1 );
86
 
        }
 
51
    int maxSz = MAX_RMA_SIZE;
 
52
    double start, end;
 
53
 
 
54
    MPI_Init(&argc, &argv);
 
55
 
 
56
    for (i = 1; i < argc; i++) {
 
57
        if (strcmp(argv[i], "-put") == 0) {
 
58
            if (rmaChoice == RMA_ALL)
 
59
                rmaChoice = RMA_NONE;
 
60
            rmaChoice |= RMA_PUT;
 
61
        }
 
62
        else if (strcmp(argv[i], "-acc") == 0) {
 
63
            if (rmaChoice == RMA_ALL)
 
64
                rmaChoice = RMA_NONE;
 
65
            rmaChoice |= RMA_ACC;
 
66
        }
 
67
        else if (strcmp(argv[i], "-fence") == 0) {
 
68
            if (syncChoice == SYNC_ALL)
 
69
                syncChoice = SYNC_NONE;
 
70
            syncChoice |= SYNC_FENCE;
 
71
        }
 
72
        else if (strcmp(argv[i], "-lock") == 0) {
 
73
            if (syncChoice == SYNC_ALL)
 
74
                syncChoice = SYNC_NONE;
 
75
            syncChoice |= SYNC_LOCK;
 
76
        }
 
77
        else if (strcmp(argv[i], "-pscw") == 0) {
 
78
            if (syncChoice == SYNC_ALL)
 
79
                syncChoice = SYNC_NONE;
 
80
            syncChoice |= SYNC_PSCW;
 
81
        }
 
82
        else if (strcmp(argv[i], "-maxsz") == 0) {
 
83
            i++;
 
84
            maxSz = atoi(argv[i]);
 
85
        }
 
86
        else if (strcmp(argv[i], "-maxcount") == 0) {
 
87
            i++;
 
88
            maxCount = atoi(argv[i]);
 
89
        }
 
90
        else {
 
91
            fprintf(stderr, "Unrecognized argument %s\n", argv[i]);
 
92
            fprintf(stderr,
 
93
                    "%s [ -put ] [ -acc ] [ -lock ] [ -fence ] [ -pscw ] [ -maxsz msgsize ]\n",
 
94
                    argv[0]);
 
95
            MPI_Abort(MPI_COMM_WORLD, 1);
 
96
        }
87
97
    }
88
 
    
89
 
    MPI_Comm_rank( MPI_COMM_WORLD, &wrank );
90
 
    MPI_Comm_size( MPI_COMM_WORLD, &wsize );
 
98
 
 
99
    MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
 
100
    MPI_Comm_size(MPI_COMM_WORLD, &wsize);
91
101
    destRank = wrank + 1;
92
 
    while (destRank >= wsize) destRank = destRank - wsize;
 
102
    while (destRank >= wsize)
 
103
        destRank = destRank - wsize;
93
104
    srcRank = wrank - 1;
94
 
    if (srcRank < 0) srcRank += wsize;
 
105
    if (srcRank < 0)
 
106
        srcRank += wsize;
95
107
 
96
108
    /* Create groups for PSCW */
97
 
    MPI_Comm_group( MPI_COMM_WORLD, &wgroup );
98
 
    MPI_Group_incl( wgroup, 1, &destRank, &accessGroup );
99
 
    MPI_Group_incl( wgroup, 1, &srcRank, &exposureGroup );
100
 
    MPI_Group_free( &wgroup );
 
109
    MPI_Comm_group(MPI_COMM_WORLD, &wgroup);
 
110
    MPI_Group_incl(wgroup, 1, &destRank, &accessGroup);
 
111
    MPI_Group_incl(wgroup, 1, &srcRank, &exposureGroup);
 
112
    MPI_Group_free(&wgroup);
101
113
 
102
114
    arraysize = maxSz * MAX_COUNT;
103
 
    arraybuffer = (int*)malloc( arraysize * sizeof(int) );
 
115
    arraybuffer = (int *) malloc(arraysize * sizeof(int));
104
116
    if (!arraybuffer) {
105
 
        fprintf( stderr, "Unable to allocate %d words\n", arraysize );
106
 
        MPI_Abort( MPI_COMM_WORLD, 1 );
 
117
        fprintf(stderr, "Unable to allocate %d words\n", arraysize);
 
118
        MPI_Abort(MPI_COMM_WORLD, 1);
107
119
    }
108
120
 
109
 
    MPI_Win_create( arraybuffer, arraysize*sizeof(int), (int)sizeof(int),
110
 
                    MPI_INFO_NULL, MPI_COMM_WORLD, &win );
 
121
    MPI_Win_create(arraybuffer, arraysize * sizeof(int), (int) sizeof(int),
 
122
                   MPI_INFO_NULL, MPI_COMM_WORLD, &win);
111
123
 
112
124
    if (maxCount > MAX_COUNT) {
113
 
        fprintf( stderr, "MaxCount must not exceed %d\n", MAX_COUNT );
114
 
        MPI_Abort( MPI_COMM_WORLD, 1 );
 
125
        fprintf(stderr, "MaxCount must not exceed %d\n", MAX_COUNT);
 
126
        MPI_Abort(MPI_COMM_WORLD, 1);
115
127
    }
116
128
 
117
129
    if ((syncChoice & SYNC_FENCE) && (rmaChoice & RMA_ACC)) {
118
 
        for (sz=1; sz<=maxSz; sz = sz + sz) {
119
 
            if (wrank == 0 && verbose) 
120
 
                printf( "Accumulate with fence, %d elements\n", sz );
121
 
            cnt = 1;
122
 
            while (cnt <= maxCount) {
123
 
                RunAccFence( win, destRank, cnt, sz );
124
 
                cnt = 2 * cnt;
125
 
            }
126
 
        }
 
130
        for (sz = 1; sz <= maxSz; sz = sz + sz) {
 
131
            if (wrank == 0 && verbose)
 
132
                printf("Accumulate with fence, %d elements\n", sz);
 
133
            for (cnt = 1; cnt <= maxCount; cnt *= 2) {
 
134
                start = MPI_Wtime();
 
135
                RunAccFence(win, destRank, cnt, sz);
 
136
                end = MPI_Wtime();
 
137
                if (end - start > MAX_ITER_TIME)
 
138
                    break;
 
139
            }
 
140
        }
127
141
    }
128
142
 
129
143
    if ((syncChoice & SYNC_LOCK) && (rmaChoice & RMA_ACC)) {
130
 
        for (sz=1; sz<=maxSz; sz = sz + sz) {
131
 
            if (wrank == 0 && verbose) 
132
 
                printf( "Accumulate with lock, %d elements\n", sz );
133
 
            cnt = 1;
134
 
            while (cnt <= maxCount) {
135
 
                RunAccLock( win, destRank, cnt, sz );
136
 
                cnt = 2 * cnt;
137
 
            }
138
 
        }
 
144
        for (sz = 1; sz <= maxSz; sz = sz + sz) {
 
145
            if (wrank == 0 && verbose)
 
146
                printf("Accumulate with lock, %d elements\n", sz);
 
147
            for (cnt = 1; cnt <= maxCount; cnt *= 2) {
 
148
                start = MPI_Wtime();
 
149
                RunAccLock(win, destRank, cnt, sz);
 
150
                end = MPI_Wtime();
 
151
                if (end - start > MAX_ITER_TIME)
 
152
                    break;
 
153
            }
 
154
        }
139
155
    }
140
156
 
141
157
    if ((syncChoice & SYNC_FENCE) && (rmaChoice & RMA_PUT)) {
142
 
        for (sz=1; sz<=maxSz; sz = sz + sz) {
143
 
            if (wrank == 0 && verbose) 
144
 
                printf( "Put with fence, %d elements\n", sz );
145
 
            cnt = 1;
146
 
            while (cnt <= maxCount) {
147
 
                RunPutFence( win, destRank, cnt, sz );
148
 
                cnt = 2 * cnt;
149
 
            }
150
 
        }
 
158
        for (sz = 1; sz <= maxSz; sz = sz + sz) {
 
159
            if (wrank == 0 && verbose)
 
160
                printf("Put with fence, %d elements\n", sz);
 
161
            for (cnt = 1; cnt <= maxCount; cnt *= 2) {
 
162
                start = MPI_Wtime();
 
163
                RunPutFence(win, destRank, cnt, sz);
 
164
                end = MPI_Wtime();
 
165
                if (end - start > MAX_ITER_TIME)
 
166
                    break;
 
167
            }
 
168
        }
151
169
    }
152
170
 
153
171
    if ((syncChoice & SYNC_LOCK) && (rmaChoice & RMA_PUT)) {
154
 
        for (sz=1; sz<=maxSz; sz = sz + sz) {
155
 
            if (wrank == 0 && verbose) 
156
 
                printf( "Put with lock, %d elements\n", sz );
157
 
            cnt = 1;
158
 
            while (cnt <= maxCount) {
159
 
                RunPutLock( win, destRank, cnt, sz );
160
 
                cnt = 2 * cnt;
161
 
            }
162
 
        }
 
172
        for (sz = 1; sz <= maxSz; sz = sz + sz) {
 
173
            if (wrank == 0 && verbose)
 
174
                printf("Put with lock, %d elements\n", sz);
 
175
            for (cnt = 1; cnt <= maxCount; cnt *= 2) {
 
176
                start = MPI_Wtime();
 
177
                RunPutLock(win, destRank, cnt, sz);
 
178
                end = MPI_Wtime();
 
179
                if (end - start > MAX_ITER_TIME)
 
180
                    break;
 
181
            }
 
182
        }
163
183
    }
164
184
 
165
185
    if ((syncChoice & SYNC_PSCW) && (rmaChoice & RMA_PUT)) {
166
 
        for (sz=1; sz<=maxSz; sz = sz + sz) {
167
 
            if (wrank == 0 && verbose) 
168
 
                printf( "Put with pscw, %d elements\n", sz );
169
 
            cnt = 1;
170
 
            while (cnt <= maxCount) {
171
 
                RunPutPSCW( win, destRank, cnt, sz, 
172
 
                            exposureGroup, accessGroup );
173
 
                cnt = 2 * cnt;
174
 
            }
175
 
        }
 
186
        for (sz = 1; sz <= maxSz; sz = sz + sz) {
 
187
            if (wrank == 0 && verbose)
 
188
                printf("Put with pscw, %d elements\n", sz);
 
189
            for (cnt = 1; cnt <= maxCount; cnt *= 2) {
 
190
                start = MPI_Wtime();
 
191
                RunPutPSCW(win, destRank, cnt, sz, exposureGroup, accessGroup);
 
192
                end = MPI_Wtime();
 
193
                if (end - start > MAX_ITER_TIME)
 
194
                    break;
 
195
            }
 
196
        }
176
197
    }
177
198
 
178
199
    if ((syncChoice & SYNC_PSCW) && (rmaChoice & RMA_ACC)) {
179
 
        for (sz=1; sz<=maxSz; sz = sz + sz) {
180
 
            if (wrank == 0 && verbose) 
181
 
                printf( "Accumulate with pscw, %d elements\n", sz );
182
 
            cnt = 1;
183
 
            while (cnt <= maxCount) {
184
 
                RunAccPSCW( win, destRank, cnt, sz, 
185
 
                            exposureGroup, accessGroup );
186
 
                cnt = 2 * cnt;
187
 
            }
188
 
        }
 
200
        for (sz = 1; sz <= maxSz; sz = sz + sz) {
 
201
            if (wrank == 0 && verbose)
 
202
                printf("Accumulate with pscw, %d elements\n", sz);
 
203
            for (cnt = 1; cnt <= maxCount; cnt *= 2) {
 
204
                start = MPI_Wtime();
 
205
                RunAccPSCW(win, destRank, cnt, sz, exposureGroup, accessGroup);
 
206
                end = MPI_Wtime();
 
207
                if (end - start > MAX_ITER_TIME)
 
208
                    break;
 
209
            }
 
210
        }
189
211
    }
190
212
 
191
 
    MPI_Win_free( &win );
 
213
    MPI_Win_free(&win);
192
214
 
193
 
    MPI_Group_free( &accessGroup );
194
 
    MPI_Group_free( &exposureGroup );
 
215
    MPI_Group_free(&accessGroup);
 
216
    MPI_Group_free(&exposureGroup);
195
217
 
196
218
    /* If we get here without timing out or failing, we succeeded */
197
 
    if (wrank == 0) printf( " No Errors\n" );
198
 
    
 
219
    if (wrank == 0)
 
220
        printf(" No Errors\n");
 
221
 
199
222
    MPI_Finalize();
200
223
    return 0;
201
224
}
202
225
 
203
226
 
204
 
void RunAccFence( MPI_Win win, int destRank, int cnt, int sz )
205
 
{
206
 
    int k, i, j, one = 1;
207
 
 
208
 
    for (k=0; k<MAX_RUNS; k++) {
209
 
        MPI_Barrier( MPI_COMM_WORLD );
210
 
        MPI_Win_fence( 0, win );
211
 
        j = 0;
212
 
        for (i=0; i<cnt; i++) {
213
 
            MPI_Accumulate( &one, sz, MPI_INT, destRank, 
214
 
                            j, sz, MPI_INT, MPI_SUM, win );
215
 
            j += sz;
216
 
        }
217
 
        MPI_Win_fence( 0, win );
218
 
    }
219
 
}
220
 
 
221
 
void RunAccLock( MPI_Win win, int destRank, int cnt, int sz )
222
 
{
223
 
    int k, i, j, one = 1;
224
 
 
225
 
    for (k=0; k<MAX_RUNS; k++) {
226
 
        MPI_Barrier( MPI_COMM_WORLD );
227
 
        MPI_Win_lock( MPI_LOCK_SHARED, destRank, 0, win );
228
 
        j = 0;
229
 
        for (i=0; i<cnt; i++) {
230
 
            MPI_Accumulate( &one, sz, MPI_INT, destRank, 
231
 
                            j, sz, MPI_INT, MPI_SUM, win );
232
 
            j += sz;
233
 
        }
234
 
        MPI_Win_unlock( destRank, win );
235
 
    }
236
 
}
237
 
 
238
 
void RunPutFence( MPI_Win win, int destRank, int cnt, int sz )
239
 
{
240
 
    int k, i, j, one = 1;
241
 
 
242
 
    for (k=0; k<MAX_RUNS; k++) {
243
 
        MPI_Barrier( MPI_COMM_WORLD );
244
 
        MPI_Win_fence( 0, win );
245
 
        j = 0;
246
 
        for (i=0; i<cnt; i++) {
247
 
            MPI_Put( &one, sz, MPI_INT, destRank, 
248
 
                            j, sz, MPI_INT, win );
249
 
            j += sz;
250
 
        }
251
 
        MPI_Win_fence( 0, win );
252
 
    }
253
 
}
254
 
 
255
 
void RunPutLock( MPI_Win win, int destRank, int cnt, int sz )
256
 
{
257
 
    int k, i, j, one = 1;
258
 
 
259
 
    for (k=0; k<MAX_RUNS; k++) {
260
 
        MPI_Barrier( MPI_COMM_WORLD );
261
 
        MPI_Win_lock( MPI_LOCK_SHARED, destRank, 0, win );
262
 
        j = 0;
263
 
        for (i=0; i<cnt; i++) {
264
 
            MPI_Put( &one, sz, MPI_INT, destRank, j, sz, MPI_INT, win );
265
 
            j += sz;
266
 
        }
267
 
        MPI_Win_unlock( destRank, win );
268
 
    }
269
 
}
270
 
 
271
 
void RunPutPSCW( MPI_Win win, int destRank, int cnt, int sz, 
272
 
                 MPI_Group exposureGroup, MPI_Group accessGroup )
273
 
{
274
 
    int k, i, j, one = 1;
275
 
 
276
 
    for (k=0; k<MAX_RUNS; k++) {
277
 
        MPI_Barrier( MPI_COMM_WORLD );
278
 
        MPI_Win_post( exposureGroup, 0, win );
279
 
        MPI_Win_start( accessGroup, 0, win );
280
 
        j = 0;
281
 
        for (i=0; i<cnt; i++) {
282
 
            MPI_Put( &one, sz, MPI_INT, destRank, j, sz, MPI_INT, win );
283
 
            j += sz;
284
 
        }
285
 
        MPI_Win_complete( win );
286
 
        MPI_Win_wait( win );
287
 
    }
288
 
}
289
 
 
290
 
void RunAccPSCW( MPI_Win win, int destRank, int cnt, int sz, 
291
 
                 MPI_Group exposureGroup, MPI_Group accessGroup )
292
 
{
293
 
    int k, i, j, one = 1;
294
 
 
295
 
    for (k=0; k<MAX_RUNS; k++) {
296
 
        MPI_Barrier( MPI_COMM_WORLD );
297
 
        MPI_Win_post( exposureGroup, 0, win );
298
 
        MPI_Win_start( accessGroup, 0, win );
299
 
        j = 0;
300
 
        for (i=0; i<cnt; i++) {
301
 
            MPI_Accumulate( &one, sz, MPI_INT, destRank, 
302
 
                            j, sz, MPI_INT, MPI_SUM, win );
303
 
            j += sz;
304
 
        }
305
 
        MPI_Win_complete( win );
306
 
        MPI_Win_wait( win );
 
227
void RunAccFence(MPI_Win win, int destRank, int cnt, int sz)
 
228
{
 
229
    int k, i, j, one = 1;
 
230
 
 
231
    for (k = 0; k < MAX_RUNS; k++) {
 
232
        MPI_Barrier(MPI_COMM_WORLD);
 
233
        MPI_Win_fence(0, win);
 
234
        j = 0;
 
235
        for (i = 0; i < cnt; i++) {
 
236
            MPI_Accumulate(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, MPI_SUM, win);
 
237
            j += sz;
 
238
        }
 
239
        MPI_Win_fence(0, win);
 
240
    }
 
241
}
 
242
 
 
243
void RunAccLock(MPI_Win win, int destRank, int cnt, int sz)
 
244
{
 
245
    int k, i, j, one = 1;
 
246
 
 
247
    for (k = 0; k < MAX_RUNS; k++) {
 
248
        MPI_Barrier(MPI_COMM_WORLD);
 
249
        MPI_Win_lock(MPI_LOCK_SHARED, destRank, 0, win);
 
250
        j = 0;
 
251
        for (i = 0; i < cnt; i++) {
 
252
            MPI_Accumulate(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, MPI_SUM, win);
 
253
            j += sz;
 
254
        }
 
255
        MPI_Win_unlock(destRank, win);
 
256
    }
 
257
}
 
258
 
 
259
void RunPutFence(MPI_Win win, int destRank, int cnt, int sz)
 
260
{
 
261
    int k, i, j, one = 1;
 
262
 
 
263
    for (k = 0; k < MAX_RUNS; k++) {
 
264
        MPI_Barrier(MPI_COMM_WORLD);
 
265
        MPI_Win_fence(0, win);
 
266
        j = 0;
 
267
        for (i = 0; i < cnt; i++) {
 
268
            MPI_Put(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, win);
 
269
            j += sz;
 
270
        }
 
271
        MPI_Win_fence(0, win);
 
272
    }
 
273
}
 
274
 
 
275
void RunPutLock(MPI_Win win, int destRank, int cnt, int sz)
 
276
{
 
277
    int k, i, j, one = 1;
 
278
 
 
279
    for (k = 0; k < MAX_RUNS; k++) {
 
280
        MPI_Barrier(MPI_COMM_WORLD);
 
281
        MPI_Win_lock(MPI_LOCK_SHARED, destRank, 0, win);
 
282
        j = 0;
 
283
        for (i = 0; i < cnt; i++) {
 
284
            MPI_Put(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, win);
 
285
            j += sz;
 
286
        }
 
287
        MPI_Win_unlock(destRank, win);
 
288
    }
 
289
}
 
290
 
 
291
void RunPutPSCW(MPI_Win win, int destRank, int cnt, int sz,
 
292
                MPI_Group exposureGroup, MPI_Group accessGroup)
 
293
{
 
294
    int k, i, j, one = 1;
 
295
 
 
296
    for (k = 0; k < MAX_RUNS; k++) {
 
297
        MPI_Barrier(MPI_COMM_WORLD);
 
298
        MPI_Win_post(exposureGroup, 0, win);
 
299
        MPI_Win_start(accessGroup, 0, win);
 
300
        j = 0;
 
301
        for (i = 0; i < cnt; i++) {
 
302
            MPI_Put(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, win);
 
303
            j += sz;
 
304
        }
 
305
        MPI_Win_complete(win);
 
306
        MPI_Win_wait(win);
 
307
    }
 
308
}
 
309
 
 
310
void RunAccPSCW(MPI_Win win, int destRank, int cnt, int sz,
 
311
                MPI_Group exposureGroup, MPI_Group accessGroup)
 
312
{
 
313
    int k, i, j, one = 1;
 
314
 
 
315
    for (k = 0; k < MAX_RUNS; k++) {
 
316
        MPI_Barrier(MPI_COMM_WORLD);
 
317
        MPI_Win_post(exposureGroup, 0, win);
 
318
        MPI_Win_start(accessGroup, 0, win);
 
319
        j = 0;
 
320
        for (i = 0; i < cnt; i++) {
 
321
            MPI_Accumulate(&one, sz, MPI_INT, destRank, j, sz, MPI_INT, MPI_SUM, win);
 
322
            j += sz;
 
323
        }
 
324
        MPI_Win_complete(win);
 
325
        MPI_Win_wait(win);
307
326
    }
308
327
}