Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill all trailling whitespaces
[simgrid.git] / teshsuite / smpi / isp / umpire / collective-exhaustive-byte-int-mismatch.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov) Thu Oct 17 2002 */
3 /* collective-exhaustive-byte-int-mismatch.c -- do many collective */
4 /* operations with simple type mismatches whenever possible (i.e., */
5 /* MPI_INT does not match MPI_BYTE, despite many thinking it does) */
6
7 #ifndef lint
8 static char *rcsid =
9   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/collective-exhaustive-byte-int-mismatch.c,v 1.1 2002/10/24 17:04:54 bronis Exp $";
10 #endif
11
12 #include <stdio.h>
13 #include <string.h>
14 #include <assert.h>
15 #include "mpi.h"
16
17
18 #define RUN_BARRIER
19 #define RUN_BCAST
20 #define RUN_GATHER
21 #define RUN_GATHERV
22 #define RUN_SCATTER
23 #define RUN_SCATTERV
24 #define RUN_ALLGATHER
25 #define RUN_ALLGATHERV
26 #define RUN_ALLTOALL
27 #define RUN_ALLTOALLV
28 #define RUN_REDUCE
29 #define RUN_ALLREDUCE
30 #define RUN_REDUCE_SCATTER
31 #define RUN_SCAN
32
33
34 #define RUN_MAX
35 #define RUN_MIN
36 #define RUN_SUM
37 #define RUN_PROD
38 #define RUN_LAND
39 #define RUN_BAND
40 #define RUN_LOR
41 #define RUN_BOR
42 #define RUN_LXOR
43 #define RUN_BXOR
44 #define RUN_USEROP
45
46
47 #define buf_size 128
48 #define OP_COUNT 1
49
50
51 #ifdef RUN_USEROP
52 typedef struct {
53   double real, imag;
54 } complex_t;
55
56 void
57 complex_prod (void *inp, void *inoutp, int *len, MPI_Datatype *dptr)
58 {
59   int i, stop;
60   complex_t c;
61   complex_t *in = (complex_t *) inp;
62   complex_t *inout = (complex_t *) inoutp;
63
64   if (*dptr == MPI_BYTE)
65     stop = (*len)/(2 * sizeof(double));
66   else
67     stop = *len;
68
69   for (i = 0; i < stop; i++) {
70     c.real = inout->real * in->real - inout->imag * in->imag;
71     c.imag = inout->real * in->imag + inout->imag * in->real;
72     *inout = c;
73     in++;
74     inout++;
75   }
76
77   return;
78 }
79 #endif
80
81
82 int
83 main (int argc, char **argv)
84 {
85   int i, nprocs = -1;
86   int rank = -1;
87   MPI_Comm comm = MPI_COMM_WORLD;
88   char processor_name[128];
89   int namelen = 128;
90   int *buf0, *buf1, *displs, *counts, *rcounts, *alltoallvcounts;
91 #ifdef RUN_USEROP
92   MPI_Op user_op;
93   complex_t *a, *answer;
94   MPI_Datatype ctype;
95 #endif
96
97   /* init */
98   MPI_Init (&argc, &argv);
99   MPI_Comm_size (comm, &nprocs);
100   MPI_Comm_rank (comm, &rank);
101   MPI_Get_processor_name (processor_name, &namelen);
102   printf ("(%d) is alive on %s\n", rank, processor_name);
103   fflush (stdout);
104
105   buf0 = (int *) malloc (buf_size * nprocs * sizeof(int));
106   assert (buf0);
107   for (i = 0; i < buf_size * nprocs; i++)
108     buf0[i] = rank;
109
110 #ifdef RUN_ALLTOALLV
111   alltoallvcounts = (int *) malloc (nprocs * sizeof(int));
112   assert (alltoallvcounts);
113 #endif
114
115 #ifdef RUN_USEROP
116   a = (complex_t *) malloc (buf_size * nprocs * sizeof(complex_t));
117   for (i = 0; i < buf_size * nprocs; i++) {
118     a[i].real = ((double) rank)/((double) nprocs);
119     a[i].imag = ((double) (-rank))/((double) nprocs);
120   }
121
122   MPI_Type_contiguous (2, MPI_DOUBLE, &ctype);
123   MPI_Type_commit (&ctype);
124
125   MPI_Op_create (complex_prod, 1 /* TRUE */, &user_op);
126 #endif
127
128   if (rank == 0) {
129     buf1 = (int *) malloc (buf_size * nprocs * sizeof(int));
130     assert (buf1);
131     for (i = 0; i < buf_size * nprocs; i++)
132       buf1[i] = i;
133
134     displs = (int *) malloc (nprocs * sizeof(int));
135     counts = (int *) malloc (nprocs * sizeof(int));
136     rcounts = (int *) malloc (nprocs * sizeof(int));
137     assert (displs && counts && rcounts);
138     for (i = 0; i < nprocs; i++) {
139       displs[i] = i * buf_size;
140       if (i < buf_size)
141         rcounts[i] = counts[i] = i;
142       else
143         rcounts[i] = counts[i] = buf_size;
144       if ((i + rank) < buf_size)
145         alltoallvcounts[i] = i + rank;
146       else
147         alltoallvcounts[i] = buf_size;
148     }
149
150 #ifdef RUN_USEROP
151     answer = (complex_t *) malloc (buf_size * nprocs * sizeof(complex_t));
152 #endif
153
154 #ifdef RUN_BARRIER
155     for (i = 0; i < OP_COUNT; i++)
156       MPI_Barrier (comm);
157 #endif
158
159 #ifdef RUN_BCAST
160     for (i = 0; i < OP_COUNT; i++)
161       MPI_Bcast (buf0, buf_size, MPI_INT, 0, comm);
162 #endif
163
164 #ifdef RUN_GATHER
165     for (i = 0; i < OP_COUNT; i++)
166       MPI_Gather (&buf0[rank*buf_size], buf_size,
167                   MPI_INT, buf1, buf_size, MPI_INT, 0, comm);
168 #endif
169
170 #ifdef RUN_SCATTER
171     for (i = 0; i < OP_COUNT; i++)
172       MPI_Scatter (buf1, buf_size, MPI_INT, buf0, buf_size, MPI_INT, 0, comm);
173 #endif
174
175 #ifdef RUN_GATHERV
176     for (i = 0; i < OP_COUNT; i++)
177       MPI_Gatherv (&buf0[rank*buf_size],
178                    (rank < buf_size) ? rank : buf_size,
179                    MPI_INT, buf1, rcounts, displs, MPI_INT, 0, comm);
180 #endif
181
182 #ifdef RUN_SCATTERV
183     for (i = 0; i < OP_COUNT; i++)
184       MPI_Scatterv (buf1, counts, displs, MPI_INT, buf0,
185                     (rank < buf_size) ? rank : buf_size, MPI_INT, 0, comm);
186 #endif
187
188 #ifdef RUN_REDUCE
189 #ifdef RUN_MAX
190     for (i = 0; i < OP_COUNT; i++)
191       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_MAX, 0, comm);
192 #endif
193
194 #ifdef RUN_MIN
195     for (i = 0; i < OP_COUNT; i++)
196       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_MIN, 0, comm);
197 #endif
198
199 #ifdef RUN_SUM
200     for (i = 0; i < OP_COUNT; i++)
201       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_SUM, 0, comm);
202 #endif
203
204 #ifdef RUN_PROD
205     for (i = 0; i < OP_COUNT; i++)
206       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_PROD, 0, comm);
207 #endif
208
209 #ifdef RUN_LAND
210     for (i = 0; i < OP_COUNT; i++)
211       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_LAND, 0, comm);
212 #endif
213
214 #ifdef RUN_BAND
215     for (i = 0; i < OP_COUNT; i++)
216       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_BAND, 0, comm);
217 #endif
218
219 #ifdef RUN_LOR
220     for (i = 0; i < OP_COUNT; i++)
221       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_LOR, 0, comm);
222 #endif
223
224 #ifdef RUN_BOR
225     for (i = 0; i < OP_COUNT; i++)
226       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_BOR, 0, comm);
227 #endif
228
229 #ifdef RUN_LXOR
230     for (i = 0; i < OP_COUNT; i++)
231       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_LXOR, 0, comm);
232 #endif
233
234 #ifdef RUN_BXOR
235     for (i = 0; i < OP_COUNT; i++)
236       MPI_Reduce (buf0, buf1, buf_size, MPI_INT, MPI_BXOR, 0, comm);
237 #endif
238
239 #ifdef RUN_USEROP
240     for (i = 0; i < OP_COUNT; i++)
241       MPI_Reduce (a, answer, buf_size, ctype, user_op, 0, comm);
242 #endif
243 #endif
244
245 #ifdef RUN_ALLGATHER
246     for (i = 0; i < OP_COUNT; i++)
247       MPI_Allgather (buf0, buf_size, MPI_INT, buf1, buf_size, MPI_INT, comm);
248 #endif
249
250 #ifdef RUN_ALLTOALL
251     for (i = 0; i < OP_COUNT; i++)
252       MPI_Alltoall (buf1, buf_size, MPI_INT, buf0, buf_size, MPI_INT, comm);
253 #endif
254
255 #ifdef RUN_ALLGATHERV
256     for (i = 0; i < OP_COUNT; i++)
257       MPI_Allgatherv (buf0,
258                       (rank < buf_size) ? rank : buf_size,
259                       MPI_INT, buf1, rcounts, displs, MPI_INT, comm);
260 #endif
261
262 #ifdef RUN_ALLTOALLV
263     for (i = 0; i < OP_COUNT; i++)
264       MPI_Alltoallv (buf1, alltoallvcounts, displs, MPI_INT,
265                      buf0, alltoallvcounts, displs, MPI_INT, comm);
266 #endif
267
268 #ifdef RUN_ALLREDUCE
269 #ifdef RUN_MAX
270     for (i = 0; i < OP_COUNT; i++)
271       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_MAX, comm);
272 #endif
273
274 #ifdef RUN_MIN
275     for (i = 0; i < OP_COUNT; i++)
276       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_MIN, comm);
277 #endif
278
279 #ifdef RUN_SUM
280     for (i = 0; i < OP_COUNT; i++)
281       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_SUM, comm);
282 #endif
283
284 #ifdef RUN_PROD
285     for (i = 0; i < OP_COUNT; i++)
286       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_PROD, comm);
287 #endif
288
289 #ifdef RUN_LAND
290     for (i = 0; i < OP_COUNT; i++)
291       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_LAND, comm);
292 #endif
293
294 #ifdef RUN_BAND
295     for (i = 0; i < OP_COUNT; i++)
296       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_BAND, comm);
297 #endif
298
299 #ifdef RUN_LOR
300     for (i = 0; i < OP_COUNT; i++)
301       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_LOR, comm);
302 #endif
303
304 #ifdef RUN_BOR
305     for (i = 0; i < OP_COUNT; i++)
306       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_BOR, comm);
307 #endif
308
309 #ifdef RUN_LXOR
310     for (i = 0; i < OP_COUNT; i++)
311       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_LXOR, comm);
312 #endif
313
314 #ifdef RUN_BXOR
315     for (i = 0; i < OP_COUNT; i++)
316       MPI_Allreduce (buf0, buf1, buf_size, MPI_INT, MPI_BXOR, comm);
317 #endif
318
319 #ifdef RUN_USEROP
320     for (i = 0; i < OP_COUNT; i++)
321       MPI_Allreduce (a, answer, buf_size, ctype, user_op, comm);
322 #endif
323 #endif
324
325 #ifdef RUN_REDUCE_SCATTER
326 #ifdef RUN_MAX
327     for (i = 0; i < OP_COUNT; i++)
328       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_MAX, comm);
329 #endif
330
331 #ifdef RUN_MIN
332     for (i = 0; i < OP_COUNT; i++)
333       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_MIN, comm);
334 #endif
335
336 #ifdef RUN_SUM
337     for (i = 0; i < OP_COUNT; i++)
338       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_SUM, comm);
339 #endif
340
341 #ifdef RUN_PROD
342     for (i = 0; i < OP_COUNT; i++)
343       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_PROD, comm);
344 #endif
345
346 #ifdef RUN_LAND
347     for (i = 0; i < OP_COUNT; i++)
348       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_LAND, comm);
349 #endif
350
351 #ifdef RUN_BAND
352     for (i = 0; i < OP_COUNT; i++)
353       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_BAND, comm);
354 #endif
355
356 #ifdef RUN_LOR
357     for (i = 0; i < OP_COUNT; i++)
358       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_LOR, comm);
359 #endif
360
361 #ifdef RUN_BOR
362     for (i = 0; i < OP_COUNT; i++)
363       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_BOR, comm);
364 #endif
365
366 #ifdef RUN_LXOR
367     for (i = 0; i < OP_COUNT; i++)
368       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_LXOR, comm);
369 #endif
370
371 #ifdef RUN_BXOR
372     for (i = 0; i < OP_COUNT; i++)
373       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_INT, MPI_BXOR, comm);
374 #endif
375
376 #ifdef RUN_USEROP
377     for (i = 0; i < OP_COUNT; i++)
378       MPI_Reduce_scatter (a, answer, rcounts, ctype, user_op, comm);
379 #endif
380 #endif
381
382 #ifdef RUN_SCAN
383 #ifdef RUN_MAX
384     for (i = 0; i < OP_COUNT; i++)
385       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_MAX, comm);
386 #endif
387
388 #ifdef RUN_MIN
389     for (i = 0; i < OP_COUNT; i++)
390       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_MIN, comm);
391 #endif
392
393 #ifdef RUN_SUM
394     for (i = 0; i < OP_COUNT; i++)
395       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_SUM, comm);
396 #endif
397
398 #ifdef RUN_PROD
399     for (i = 0; i < OP_COUNT; i++)
400       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_PROD, comm);
401 #endif
402
403 #ifdef RUN_LAND
404     for (i = 0; i < OP_COUNT; i++)
405       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_LAND, comm);
406 #endif
407
408 #ifdef RUN_BAND
409     for (i = 0; i < OP_COUNT; i++)
410       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_BAND, comm);
411 #endif
412
413 #ifdef RUN_LOR
414     for (i = 0; i < OP_COUNT; i++)
415       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_LOR, comm);
416 #endif
417
418 #ifdef RUN_BOR
419     for (i = 0; i < OP_COUNT; i++)
420       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_BOR, comm);
421 #endif
422
423 #ifdef RUN_LXOR
424     for (i = 0; i < OP_COUNT; i++)
425       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_LXOR, comm);
426 #endif
427
428 #ifdef RUN_BXOR
429     for (i = 0; i < OP_COUNT; i++)
430       MPI_Scan (buf0, buf1, buf_size, MPI_INT, MPI_BXOR, comm);
431 #endif
432
433 #ifdef RUN_USEROP
434     for (i = 0; i < OP_COUNT; i++)
435       MPI_Scan (a, answer, buf_size, ctype, user_op, comm);
436 #endif
437 #endif
438   }
439   else {
440     int *ricounts, *rdcounts;
441
442 #ifdef RUN_BARRIER
443     for (i = 0; i < OP_COUNT; i++)
444       MPI_Barrier (comm);
445 #endif
446
447 #ifdef RUN_BCAST
448     for (i = 0; i < OP_COUNT; i++)
449       MPI_Bcast (buf0, buf_size * sizeof(int), MPI_BYTE, 0, comm);
450 #endif
451
452 #ifdef RUN_GATHER
453     for (i = 0; i < OP_COUNT; i++)
454       MPI_Gather (&buf0[rank*buf_size], buf_size * sizeof(int),
455                   MPI_BYTE, buf1, buf_size * sizeof(int), MPI_BYTE, 0, comm);
456 #endif
457
458 #ifdef RUN_SCATTER
459     for (i = 0; i < OP_COUNT; i++)
460       MPI_Scatter (buf1, buf_size * sizeof(int), MPI_BYTE,
461                    buf0, buf_size * sizeof(int), MPI_BYTE, 0, comm);
462 #endif
463
464 #ifdef RUN_GATHERV
465     for (i = 0; i < OP_COUNT; i++)
466       MPI_Gatherv (&buf0[rank*buf_size],
467                    ((rank < buf_size) ? rank : buf_size) * sizeof(int),
468                    MPI_BYTE, buf1, rcounts, displs, MPI_BYTE, 0, comm);
469 #endif
470
471 #ifdef RUN_SCATTERV
472     for (i = 0; i < OP_COUNT; i++)
473       MPI_Scatterv (buf1, counts, displs, MPI_BYTE, buf0,
474                     ((rank < buf_size) ? rank : buf_size) * sizeof(int),
475                     MPI_BYTE, 0, comm);
476 #endif
477
478 #ifdef RUN_REDUCE
479 #ifdef RUN_MAX
480     for (i = 0; i < OP_COUNT; i++)
481       MPI_Reduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_MAX, 0, comm);
482 #endif
483
484 #ifdef RUN_MIN
485     for (i = 0; i < OP_COUNT; i++)
486       MPI_Reduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_MIN, 0, comm);
487 #endif
488
489 #ifdef RUN_SUM
490     for (i = 0; i < OP_COUNT; i++)
491       MPI_Reduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_SUM, 0, comm);
492 #endif
493
494 #ifdef RUN_PROD
495     for (i = 0; i < OP_COUNT; i++)
496       MPI_Reduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_PROD, 0, comm);
497 #endif
498
499 #ifdef RUN_LAND
500     for (i = 0; i < OP_COUNT; i++)
501       MPI_Reduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_LAND, 0, comm);
502 #endif
503
504 #ifdef RUN_BAND
505     for (i = 0; i < OP_COUNT; i++)
506       MPI_Reduce (buf0, buf1,
507                   buf_size * sizeof(int), MPI_BYTE, MPI_BAND, 0, comm);
508 #endif
509
510 #ifdef RUN_LOR
511     for (i = 0; i < OP_COUNT; i++)
512       MPI_Reduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_LOR, 0, comm);
513 #endif
514
515 #ifdef RUN_BOR
516     for (i = 0; i < OP_COUNT; i++)
517       MPI_Reduce (buf0, buf1,
518                   buf_size * sizeof(int), MPI_BYTE, MPI_BOR, 0, comm);
519 #endif
520
521 #ifdef RUN_LXOR
522     for (i = 0; i < OP_COUNT; i++)
523       MPI_Reduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_LXOR, 0, comm);
524 #endif
525
526 #ifdef RUN_BXOR
527     for (i = 0; i < OP_COUNT; i++)
528       MPI_Reduce (buf0, buf1,
529                   buf_size * sizeof(int), MPI_BYTE, MPI_BXOR, 0, comm);
530 #endif
531
532 #ifdef RUN_USEROP
533     for (i = 0; i < OP_COUNT; i++)
534       MPI_Reduce (a, answer,
535                   buf_size * 2 * sizeof(double), MPI_BYTE, user_op, 0, comm);
536 #endif
537 #endif
538
539     buf1 = (int *) malloc (buf_size * nprocs * sizeof(int));
540     assert (buf1);
541     for (i = 0; i < buf_size * nprocs; i++)
542       buf1[i] = i;
543
544     displs = (int *) malloc (nprocs * sizeof(int));
545     counts = (int *) malloc (nprocs * sizeof(int));
546     rcounts = (int *) malloc (nprocs * sizeof(int));
547     ricounts = (int *) malloc (nprocs * sizeof(int));
548     rdcounts = (int *) malloc (nprocs * sizeof(int));
549     assert (displs && counts && rcounts);
550     for (i = 0; i < nprocs; i++) {
551       displs[i] = i * buf_size * sizeof(int);
552       if (i < buf_size) {
553         rcounts[i] = counts[i] = i * sizeof(int);
554         ricounts[i] = i;
555         rdcounts[i] = i * 2 * sizeof(double);
556       }
557       else {
558         rcounts[i] = counts[i] = buf_size * sizeof(int);
559         ricounts[i] = buf_size;
560         rdcounts[i] = buf_size * 2 * sizeof(double);
561       }
562       if ((i + rank) < buf_size)
563         alltoallvcounts[i] = i + rank * sizeof(int);
564       else
565         alltoallvcounts[i] = buf_size * sizeof(int);
566     }
567
568 #ifdef RUN_USEROP
569     answer = (complex_t *) malloc (buf_size * nprocs * sizeof(complex_t));
570 #endif
571
572 #ifdef RUN_ALLGATHER
573     for (i = 0; i < OP_COUNT; i++)
574       MPI_Allgather (buf0, buf_size * sizeof(int), MPI_BYTE,
575                      buf1, buf_size * sizeof(int), MPI_BYTE, comm);
576 #endif
577
578 #ifdef RUN_ALLTOALL
579     for (i = 0; i < OP_COUNT; i++)
580       MPI_Alltoall (buf1, buf_size * sizeof(int), MPI_BYTE,
581                     buf0, buf_size * sizeof(int), MPI_BYTE, comm);
582 #endif
583
584 #ifdef RUN_ALLGATHERV
585     for (i = 0; i < OP_COUNT; i++)
586       MPI_Allgatherv (buf0,
587                       ((rank < buf_size) ? rank : buf_size) * sizeof(int),
588                       MPI_BYTE, buf1, rcounts, displs, MPI_BYTE, comm);
589 #endif
590
591 #ifdef RUN_ALLTOALLV
592     for (i = 0; i < OP_COUNT; i++)
593       MPI_Alltoallv (buf1, alltoallvcounts, displs, MPI_BYTE,
594                      buf0, alltoallvcounts, displs, MPI_BYTE, comm);
595 #endif
596
597 #ifdef RUN_ALLREDUCE
598 #ifdef RUN_MAX
599     for (i = 0; i < OP_COUNT; i++)
600       MPI_Allreduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_MAX, comm);
601 #endif
602
603 #ifdef RUN_MIN
604     for (i = 0; i < OP_COUNT; i++)
605       MPI_Allreduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_MIN, comm);
606 #endif
607
608 #ifdef RUN_SUM
609     for (i = 0; i < OP_COUNT; i++)
610       MPI_Allreduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_SUM, comm);
611 #endif
612
613 #ifdef RUN_PROD
614     for (i = 0; i < OP_COUNT; i++)
615       MPI_Allreduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_PROD, comm);
616 #endif
617
618 #ifdef RUN_LAND
619     for (i = 0; i < OP_COUNT; i++)
620       MPI_Allreduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_LAND, comm);
621 #endif
622
623 #ifdef RUN_BAND
624     for (i = 0; i < OP_COUNT; i++)
625       MPI_Allreduce (buf0, buf1,
626                      buf_size * sizeof (int), MPI_BYTE, MPI_BAND, comm);
627 #endif
628
629 #ifdef RUN_LOR
630     for (i = 0; i < OP_COUNT; i++)
631       MPI_Allreduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_LOR, comm);
632 #endif
633
634 #ifdef RUN_BOR
635     for (i = 0; i < OP_COUNT; i++)
636       MPI_Allreduce (buf0, buf1,
637                      buf_size * sizeof (int), MPI_BYTE, MPI_BOR, comm);
638 #endif
639
640 #ifdef RUN_LXOR
641     for (i = 0; i < OP_COUNT; i++)
642       MPI_Allreduce (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_LXOR, comm);
643 #endif
644
645 #ifdef RUN_BXOR
646     for (i = 0; i < OP_COUNT; i++)
647       MPI_Allreduce (buf0, buf1,
648                      buf_size * sizeof (int), MPI_BYTE, MPI_BXOR, comm);
649 #endif
650
651 #ifdef RUN_USEROP
652     for (i = 0; i < OP_COUNT; i++)
653       MPI_Allreduce (a, answer,
654                      buf_size * 2 * sizeof (double), MPI_BYTE, user_op, comm);
655 #endif
656 #endif
657
658 #ifdef RUN_REDUCE_SCATTER
659 #ifdef RUN_MAX
660     for (i = 0; i < OP_COUNT; i++)
661       MPI_Reduce_scatter (buf0, buf1, ricounts, MPI_UNSIGNED, MPI_MAX, comm);
662 #endif
663
664 #ifdef RUN_MIN
665     for (i = 0; i < OP_COUNT; i++)
666       MPI_Reduce_scatter (buf0, buf1, ricounts, MPI_UNSIGNED, MPI_MIN, comm);
667 #endif
668
669 #ifdef RUN_SUM
670     for (i = 0; i < OP_COUNT; i++)
671       MPI_Reduce_scatter (buf0, buf1, ricounts, MPI_UNSIGNED, MPI_SUM, comm);
672 #endif
673
674 #ifdef RUN_PROD
675     for (i = 0; i < OP_COUNT; i++)
676       MPI_Reduce_scatter (buf0, buf1, ricounts, MPI_UNSIGNED, MPI_PROD, comm);
677 #endif
678
679 #ifdef RUN_LAND
680     for (i = 0; i < OP_COUNT; i++)
681       MPI_Reduce_scatter (buf0, buf1, ricounts, MPI_UNSIGNED, MPI_LAND, comm);
682 #endif
683
684 #ifdef RUN_BAND
685     for (i = 0; i < OP_COUNT; i++)
686       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_BYTE, MPI_BAND, comm);
687 #endif
688
689 #ifdef RUN_LOR
690     for (i = 0; i < OP_COUNT; i++)
691       MPI_Reduce_scatter (buf0, buf1, ricounts, MPI_UNSIGNED, MPI_LOR, comm);
692 #endif
693
694 #ifdef RUN_BOR
695     for (i = 0; i < OP_COUNT; i++)
696       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_BYTE, MPI_BOR, comm);
697 #endif
698
699 #ifdef RUN_LXOR
700     for (i = 0; i < OP_COUNT; i++)
701       MPI_Reduce_scatter (buf0, buf1, ricounts, MPI_UNSIGNED, MPI_LXOR, comm);
702 #endif
703
704 #ifdef RUN_BXOR
705     for (i = 0; i < OP_COUNT; i++)
706       MPI_Reduce_scatter (buf0, buf1, rcounts, MPI_BYTE, MPI_BXOR, comm);
707 #endif
708
709 #ifdef RUN_USEROP
710     for (i = 0; i < OP_COUNT; i++)
711       MPI_Reduce_scatter (a, answer, rdcounts, MPI_BYTE, user_op, comm);
712 #endif
713 #endif
714
715 #ifdef RUN_SCAN
716 #ifdef RUN_MAX
717     for (i = 0; i < OP_COUNT; i++)
718       MPI_Scan (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_MAX, comm);
719 #endif
720
721 #ifdef RUN_MIN
722     for (i = 0; i < OP_COUNT; i++)
723       MPI_Scan (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_MIN, comm);
724 #endif
725
726 #ifdef RUN_SUM
727     for (i = 0; i < OP_COUNT; i++)
728       MPI_Scan (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_SUM, comm);
729 #endif
730
731 #ifdef RUN_PROD
732     for (i = 0; i < OP_COUNT; i++)
733       MPI_Scan (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_PROD, comm);
734 #endif
735
736 #ifdef RUN_LAND
737     for (i = 0; i < OP_COUNT; i++)
738       MPI_Scan (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_LAND, comm);
739 #endif
740
741 #ifdef RUN_BAND
742     for (i = 0; i < OP_COUNT; i++)
743       MPI_Scan (buf0, buf1, buf_size * sizeof(int), MPI_BYTE, MPI_BAND, comm);
744 #endif
745
746 #ifdef RUN_LOR
747     for (i = 0; i < OP_COUNT; i++)
748       MPI_Scan (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_LOR, comm);
749 #endif
750
751 #ifdef RUN_BOR
752     for (i = 0; i < OP_COUNT; i++)
753       MPI_Scan (buf0, buf1, buf_size * sizeof(int), MPI_BYTE, MPI_BOR, comm);
754 #endif
755
756 #ifdef RUN_LXOR
757     for (i = 0; i < OP_COUNT; i++)
758       MPI_Scan (buf0, buf1, buf_size, MPI_UNSIGNED, MPI_LXOR, comm);
759 #endif
760
761 #ifdef RUN_BXOR
762     for (i = 0; i < OP_COUNT; i++)
763       MPI_Scan (buf0, buf1, buf_size * sizeof(int), MPI_BYTE, MPI_BXOR, comm);
764 #endif
765
766 #ifdef RUN_USEROP
767     for (i = 0; i < OP_COUNT; i++)
768       MPI_Scan (a, answer,
769                 buf_size * 2 * sizeof(double), MPI_BYTE, user_op, comm);
770 #endif
771 #endif
772   }
773
774 #ifdef RUN_BARRIER
775   MPI_Barrier (comm);
776 #endif
777
778 #ifdef RUN_USEROP
779   free (a);
780   free (answer);
781   MPI_Op_free (&user_op);
782   MPI_Type_free (&ctype);
783 #endif
784
785 #ifdef RUN_ALLTOALLV
786   free (alltoallvcounts);
787 #endif
788
789   free (buf0);
790   free (buf1);
791   free (displs);
792   free (counts);
793   free (rcounts);
794
795   MPI_Finalize ();
796   printf ("(%d) Finished normally\n", rank);
797
798   return 0;
799 }
800
801 /* EOF */