1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
3 * (C) 2011 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
7 /* This test attempts to execute multiple simultaneous nonblocking collective
8 * (NBC) MPI routines at the same time, and manages their completion with a
9 * variety of routines (MPI_{Wait,Test}{,_all,_any,_some}). It also throws a
10 * few point-to-point operations into the mix.
12 * Possible improvements:
13 * - post operations on multiple comms from multiple threads
28 /* Constants that control the high level test harness behavior. */
29 /* MAIN_ITERATIONS is how many NBC ops the test will attempt to issue. */
30 #define MAIN_ITERATIONS (100000)
31 /* WINDOW is the maximum number of outstanding NBC requests at any given time */
33 /* we sleep with probability 1/CHANCE_OF_SLEEP */
34 #define CHANCE_OF_SLEEP (1000)
35 /* JITTER_DELAY is denominated in microseconds (us) */
36 #define JITTER_DELAY (50000) /* 0.05 seconds */
37 /* NUM_COMMS is the number of communicators on which ops will be posted */
40 /* Constants that control behavior of the individual testing operations.
41 * Altering these can help to explore the testing space, but increasing them too
42 * much can consume too much memory (often O(n^2) usage). */
43 /* FIXME is COUNT==10 too limiting? should we try a larger count too (~500)? */
47 #define my_assert(cond_) \
52 fprintf(stderr, "assertion (%s) failed on line %d\n", #cond_, __LINE__); \
57 /* Intended to act like "rand_r", but we can be sure that it will exist and be
58 * consistent across all of comm world. Returns a number in the range
60 #define GEN_PRN_MAX (4294967291-1)
61 static unsigned int gen_prn(unsigned int x)
63 /* a simple "multiplicative congruential method" PRNG, with parameters:
64 * m=4294967291, largest 32-bit prime
65 * a=279470273, good primitive root of m from "TABLES OF LINEAR
66 * CONGRUENTIAL GENERATORS OF DIFFERENT SIZES AND GOOD
67 * LATTICE STRUCTURE", by Pierre L’Ecuyer */
68 return (279470273UL * (unsigned long) x) % 4294967291UL;
71 /* given a random unsigned int value "rndval_" from gen_prn, this evaluates to a
72 * value in the range [min_,max_) */
73 #define rand_range(rndval_,min_,max_) \
74 ((unsigned int)((min_) + ((rndval_) * (1.0 / (GEN_PRN_MAX+1.0)) * ((max_) - (min_)))))
77 static void sum_fn(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype)
81 int *inout = inoutvec;
82 for (i = 0; i < *len; ++i) {
83 inout[i] = in[i] + inout[i];
87 /* used to keep track of buffers that should be freed after the corresponding
88 * operation has completed */
90 int case_num; /* which test case initiated this req/laundry */
102 static void cleanup_laundry(struct laundry *l)
105 l->comm = MPI_COMM_NULL;
124 /* Starts a "random" operation on "comm" corresponding to "rndnum" and returns
125 * in (*req) a request handle corresonding to that operation. This call should
126 * be considered collective over comm (with a consistent value for "rndnum"),
127 * even though the operation may only be a point-to-point request. */
128 static void start_random_nonblocking(MPI_Comm comm, unsigned int rndnum, MPI_Request * req,
135 int *sendcounts = NULL;
136 int *recvcounts = NULL;
139 int *sendtypes = NULL;
140 int *recvtypes = NULL;
141 signed char *buf_alias = NULL;
143 MPI_Comm_rank(comm, &rank);
144 MPI_Comm_size(comm, &size);
146 *req = MPI_REQUEST_NULL;
151 l->buf = buf = malloc(COUNT * size * sizeof(int));
152 l->recvbuf = recvbuf = malloc(COUNT * size * sizeof(int));
153 l->sendcounts = sendcounts = malloc(size * sizeof(int));
154 l->recvcounts = recvcounts = malloc(size * sizeof(int));
155 l->sdispls = sdispls = malloc(size * sizeof(int));
156 l->rdispls = rdispls = malloc(size * sizeof(int));
157 l->sendtypes = sendtypes = malloc(size * sizeof(MPI_Datatype));
158 l->recvtypes = recvtypes = malloc(size * sizeof(MPI_Datatype));
160 #define NUM_CASES (21)
161 l->case_num = rand_range(rndnum, 0, NUM_CASES);
162 switch (l->case_num) {
163 case 0: /* MPI_Ibcast */
164 for (i = 0; i < COUNT; ++i) {
172 MPI_Ibcast(buf, COUNT, MPI_INT, 0, comm, req);
175 case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */
176 /* FIXME fiddle with PRIME and buffer allocation s.t. PRIME is much larger (1021?) */
177 buf_alias = (signed char *) buf;
178 my_assert(COUNT * size * sizeof(int) > PRIME); /* sanity */
179 for (i = 0; i < PRIME; ++i) {
185 for (i = PRIME; i < COUNT * size * sizeof(int); ++i) {
188 MPI_Ibcast(buf_alias, PRIME, MPI_SIGNED_CHAR, 0, comm, req);
191 case 2: /* MPI_Ibarrier */
192 MPI_Ibarrier(comm, req);
195 case 3: /* MPI_Ireduce */
196 for (i = 0; i < COUNT; ++i) {
198 recvbuf[i] = 0xdeadbeef;
200 MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, 0, comm, req);
203 case 4: /* same again, use a user op and free it before the wait */
205 MPI_Op op = MPI_OP_NULL;
206 MPI_Op_create(sum_fn, /*commute= */ 1, &op);
207 for (i = 0; i < COUNT; ++i) {
209 recvbuf[i] = 0xdeadbeef;
211 MPI_Ireduce(buf, recvbuf, COUNT, MPI_INT, op, 0, comm, req);
216 case 5: /* MPI_Iallreduce */
217 for (i = 0; i < COUNT; ++i) {
219 recvbuf[i] = 0xdeadbeef;
221 MPI_Iallreduce(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
224 case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */
225 for (i = 0; i < size; ++i) {
226 sendcounts[i] = COUNT;
227 recvcounts[i] = COUNT;
228 sdispls[i] = COUNT * i;
229 rdispls[i] = COUNT * i;
230 for (j = 0; j < COUNT; ++j) {
231 buf[i * COUNT + j] = rank + (i * j);
232 recvbuf[i * COUNT + j] = 0xdeadbeef;
235 MPI_Ialltoallv(buf, sendcounts, sdispls, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT,
239 case 7: /* MPI_Igather */
240 for (i = 0; i < size * COUNT; ++i) {
242 recvbuf[i] = 0xdeadbeef;
244 MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req);
247 case 8: /* same test again, just use a dup'ed datatype and free it before the wait */
249 MPI_Datatype type = MPI_DATATYPE_NULL;
250 MPI_Type_dup(MPI_INT, &type);
251 for (i = 0; i < size * COUNT; ++i) {
253 recvbuf[i] = 0xdeadbeef;
255 MPI_Igather(buf, COUNT, MPI_INT, recvbuf, COUNT, type, 0, comm, req);
256 MPI_Type_free(&type); /* should cause implementations that don't refcount
257 * correctly to blow up or hang in the wait */
261 case 9: /* MPI_Iscatter */
262 for (i = 0; i < size; ++i) {
263 for (j = 0; j < COUNT; ++j) {
265 buf[i * COUNT + j] = i + j;
267 buf[i * COUNT + j] = 0xdeadbeef;
268 recvbuf[i * COUNT + j] = 0xdeadbeef;
271 MPI_Iscatter(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req);
274 case 10: /* MPI_Iscatterv */
275 for (i = 0; i < size; ++i) {
276 /* weak test, just test the regular case where all counts are equal */
277 sendcounts[i] = COUNT;
278 sdispls[i] = i * COUNT;
279 for (j = 0; j < COUNT; ++j) {
281 buf[i * COUNT + j] = i + j;
283 buf[i * COUNT + j] = 0xdeadbeef;
284 recvbuf[i * COUNT + j] = 0xdeadbeef;
287 MPI_Iscatterv(buf, sendcounts, sdispls, MPI_INT, recvbuf, COUNT, MPI_INT, 0, comm, req);
290 case 11: /* MPI_Ireduce_scatter */
291 for (i = 0; i < size; ++i) {
292 recvcounts[i] = COUNT;
293 for (j = 0; j < COUNT; ++j) {
294 buf[i * COUNT + j] = rank + i;
295 recvbuf[i * COUNT + j] = 0xdeadbeef;
298 MPI_Ireduce_scatter(buf, recvbuf, recvcounts, MPI_INT, MPI_SUM, comm, req);
301 case 12: /* MPI_Ireduce_scatter_block */
302 for (i = 0; i < size; ++i) {
303 for (j = 0; j < COUNT; ++j) {
304 buf[i * COUNT + j] = rank + i;
305 recvbuf[i * COUNT + j] = 0xdeadbeef;
308 MPI_Ireduce_scatter_block(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
311 case 13: /* MPI_Igatherv */
312 for (i = 0; i < size * COUNT; ++i) {
314 recvbuf[i] = 0xdeadbeef;
316 for (i = 0; i < COUNT; ++i) {
319 for (i = 0; i < size; ++i) {
320 recvcounts[i] = COUNT;
321 rdispls[i] = i * COUNT;
323 MPI_Igatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, 0, comm, req);
326 case 14: /* MPI_Ialltoall */
327 for (i = 0; i < size; ++i) {
328 for (j = 0; j < COUNT; ++j) {
329 buf[i * COUNT + j] = rank + (i * j);
330 recvbuf[i * COUNT + j] = 0xdeadbeef;
333 MPI_Ialltoall(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req);
336 case 15: /* MPI_Iallgather */
337 for (i = 0; i < size * COUNT; ++i) {
339 recvbuf[i] = 0xdeadbeef;
341 MPI_Iallgather(buf, COUNT, MPI_INT, recvbuf, COUNT, MPI_INT, comm, req);
344 case 16: /* MPI_Iallgatherv */
345 for (i = 0; i < size; ++i) {
346 for (j = 0; j < COUNT; ++j) {
347 recvbuf[i * COUNT + j] = 0xdeadbeef;
349 recvcounts[i] = COUNT;
350 rdispls[i] = i * COUNT;
352 for (i = 0; i < COUNT; ++i)
354 MPI_Iallgatherv(buf, COUNT, MPI_INT, recvbuf, recvcounts, rdispls, MPI_INT, comm, req);
357 case 17: /* MPI_Iscan */
358 for (i = 0; i < COUNT; ++i) {
360 recvbuf[i] = 0xdeadbeef;
362 MPI_Iscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
365 case 18: /* MPI_Iexscan */
366 for (i = 0; i < COUNT; ++i) {
368 recvbuf[i] = 0xdeadbeef;
370 MPI_Iexscan(buf, recvbuf, COUNT, MPI_INT, MPI_SUM, comm, req);
373 case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */
374 for (i = 0; i < size; ++i) {
375 sendcounts[i] = COUNT;
376 recvcounts[i] = COUNT;
377 sdispls[i] = COUNT * i * sizeof(int);
378 rdispls[i] = COUNT * i * sizeof(int);
379 sendtypes[i] = MPI_INT;
380 recvtypes[i] = MPI_INT;
381 for (j = 0; j < COUNT; ++j) {
382 buf[i * COUNT + j] = rank + (i * j);
383 recvbuf[i * COUNT + j] = 0xdeadbeef;
386 MPI_Ialltoallw(buf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes,
390 case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */
391 /* even ranks send to odd ranks, but only if we have a full pair */
392 if ((rank % 2 != 0) || (rank != size - 1)) {
393 for (j = 0; j < COUNT; ++j) {
395 recvbuf[j] = 0xdeadbeef;
398 MPI_Isend(buf, COUNT, MPI_INT, rank + 1, 5, comm, req);
400 MPI_Irecv(recvbuf, COUNT, MPI_INT, rank - 1, 5, comm, req);
405 fprintf(stderr, "unexpected value for l->case_num=%d)\n", (l->case_num));
411 static void check_after_completion(struct laundry *l)
415 MPI_Comm comm = l->comm;
417 int *recvbuf = l->recvbuf;
418 int *sendcounts = l->sendcounts;
419 int *recvcounts = l->recvcounts;
420 int *sdispls = l->sdispls;
421 int *rdispls = l->rdispls;
422 int *sendtypes = l->sendtypes;
423 int *recvtypes = l->recvtypes;
424 char *buf_alias = (char *) buf;
426 MPI_Comm_rank(comm, &rank);
427 MPI_Comm_size(comm, &size);
429 /* these cases all correspond to cases in start_random_nonblocking */
430 switch (l->case_num) {
431 case 0: /* MPI_Ibcast */
432 for (i = 0; i < COUNT; ++i) {
434 printf("buf[%d]=%d i=%d\n", i, buf[i], i);
435 my_assert(buf[i] == i);
439 case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */
440 for (i = 0; i < PRIME; ++i) {
441 if (buf_alias[i] != i)
442 printf("buf_alias[%d]=%d i=%d\n", i, buf_alias[i], i);
443 my_assert(buf_alias[i] == i);
447 case 2: /* MPI_Ibarrier */
448 /* nothing to check */
451 case 3: /* MPI_Ireduce */
453 for (i = 0; i < COUNT; ++i) {
454 if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
455 printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
456 ((size * (size - 1) / 2) + (i * size)));
457 my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
462 case 4: /* same again, use a user op and free it before the wait */
464 for (i = 0; i < COUNT; ++i) {
465 if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
466 printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
467 ((size * (size - 1) / 2) + (i * size)));
468 my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
473 case 5: /* MPI_Iallreduce */
474 for (i = 0; i < COUNT; ++i) {
475 if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
476 printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
477 ((size * (size - 1) / 2) + (i * size)));
478 my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
482 case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */
483 for (i = 0; i < size; ++i) {
484 for (j = 0; j < COUNT; ++j) {
485 /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */
486 my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
491 case 7: /* MPI_Igather */
493 for (i = 0; i < size; ++i) {
494 for (j = 0; j < COUNT; ++j) {
495 my_assert(recvbuf[i * COUNT + j] == i + j);
500 for (i = 0; i < size * COUNT; ++i) {
501 my_assert(recvbuf[i] == 0xdeadbeef);
506 case 8: /* same test again, just use a dup'ed datatype and free it before the wait */
508 for (i = 0; i < size; ++i) {
509 for (j = 0; j < COUNT; ++j) {
510 my_assert(recvbuf[i * COUNT + j] == i + j);
515 for (i = 0; i < size * COUNT; ++i) {
516 my_assert(recvbuf[i] == 0xdeadbeef);
521 case 9: /* MPI_Iscatter */
522 for (j = 0; j < COUNT; ++j) {
523 my_assert(recvbuf[j] == rank + j);
526 for (i = 0; i < size * COUNT; ++i) {
527 /* check we didn't corrupt the sendbuf somehow */
528 my_assert(buf[i] == 0xdeadbeef);
533 case 10: /* MPI_Iscatterv */
534 for (j = 0; j < COUNT; ++j) {
535 my_assert(recvbuf[j] == rank + j);
538 for (i = 0; i < size * COUNT; ++i) {
539 /* check we didn't corrupt the sendbuf somehow */
540 my_assert(buf[i] == 0xdeadbeef);
543 for (i = 1; i < size; ++i) {
544 for (j = 0; j < COUNT; ++j) {
545 /* check we didn't corrupt the rest of the recvbuf */
546 my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
551 case 11: /* MPI_Ireduce_scatter */
552 for (j = 0; j < COUNT; ++j) {
553 my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2));
555 for (i = 1; i < size; ++i) {
556 for (j = 0; j < COUNT; ++j) {
557 /* check we didn't corrupt the rest of the recvbuf */
558 my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
563 case 12: /* MPI_Ireduce_scatter_block */
564 for (j = 0; j < COUNT; ++j) {
565 my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2));
567 for (i = 1; i < size; ++i) {
568 for (j = 0; j < COUNT; ++j) {
569 /* check we didn't corrupt the rest of the recvbuf */
570 my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
575 case 13: /* MPI_Igatherv */
577 for (i = 0; i < size; ++i) {
578 for (j = 0; j < COUNT; ++j) {
579 my_assert(recvbuf[i * COUNT + j] == i + j);
584 for (i = 0; i < size * COUNT; ++i) {
585 my_assert(recvbuf[i] == 0xdeadbeef);
590 case 14: /* MPI_Ialltoall */
591 for (i = 0; i < size; ++i) {
592 for (j = 0; j < COUNT; ++j) {
593 /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j))); */
594 my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
599 case 15: /* MPI_Iallgather */
600 for (i = 0; i < size; ++i) {
601 for (j = 0; j < COUNT; ++j) {
602 my_assert(recvbuf[i * COUNT + j] == i + j);
607 case 16: /* MPI_Iallgatherv */
608 for (i = 0; i < size; ++i) {
609 for (j = 0; j < COUNT; ++j) {
610 my_assert(recvbuf[i * COUNT + j] == i + j);
615 case 17: /* MPI_Iscan */
616 for (i = 0; i < COUNT; ++i) {
617 my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1))));
621 case 18: /* MPI_Iexscan */
622 for (i = 0; i < COUNT; ++i) {
624 my_assert(recvbuf[i] == 0xdeadbeef);
626 my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1)) - (rank + i)));
630 case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */
631 for (i = 0; i < size; ++i) {
632 for (j = 0; j < COUNT; ++j) {
633 /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */
634 my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
639 case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */
640 /* even ranks send to odd ranks, but only if we have a full pair */
641 if ((rank % 2 != 0) || (rank != size - 1)) {
642 for (j = 0; j < COUNT; ++j) {
643 /* only odd procs did a recv */
645 my_assert(recvbuf[j] == 0xdeadbeef);
649 printf("recvbuf[%d]=%d j=%d\n", j, recvbuf[j], j);
650 my_assert(recvbuf[j] == j);
657 printf("invalid case_num (%d) detected\n", l->case_num);
665 static void complete_something_somehow(unsigned int rndnum, int numreqs, MPI_Request reqs[],
666 int *outcount, int indices[])
670 #define COMPLETION_CASES (8)
671 switch (rand_range(rndnum, 0, COMPLETION_CASES)) {
673 MPI_Waitall(numreqs, reqs, MPI_STATUSES_IGNORE);
675 for (i = 0; i < numreqs; ++i) {
681 MPI_Testsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE);
682 if (*outcount == MPI_UNDEFINED) {
688 MPI_Waitsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE);
689 if (*outcount == MPI_UNDEFINED) {
695 MPI_Waitany(numreqs, reqs, &idx, MPI_STATUS_IGNORE);
696 if (idx == MPI_UNDEFINED) {
706 MPI_Testany(numreqs, reqs, &idx, &flag, MPI_STATUS_IGNORE);
707 if (idx == MPI_UNDEFINED) {
717 MPI_Testall(numreqs, reqs, &flag, MPI_STATUSES_IGNORE);
720 for (i = 0; i < numreqs; ++i) {
730 /* select a new random index and wait on it */
731 rndnum = gen_prn(rndnum);
732 idx = rand_range(rndnum, 0, numreqs);
733 MPI_Wait(&reqs[idx], MPI_STATUS_IGNORE);
739 /* select a new random index and wait on it */
740 rndnum = gen_prn(rndnum);
741 idx = rand_range(rndnum, 0, numreqs);
742 MPI_Test(&reqs[idx], &flag, MPI_STATUS_IGNORE);
743 *outcount = (flag ? 1 : 0);
751 #undef COMPLETION_CASES
754 int main(int argc, char **argv)
756 int i, num_posted, num_completed;
758 unsigned int seed = 0x10bc;
759 unsigned int post_seq, complete_seq;
760 struct laundry larr[WINDOW];
761 MPI_Request reqs[WINDOW];
764 MPI_Comm comms[NUM_COMMS];
767 MPI_Init(&argc, &argv);
768 MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
769 MPI_Comm_size(MPI_COMM_WORLD, &wsize);
771 /* it is critical that all processes in the communicator start with a
772 * consistent value for "post_seq" */
773 post_seq = complete_seq = gen_prn(seed);
778 /* construct all of the communicators, just dups of comm world for now */
779 for (i = 0; i < NUM_COMMS; ++i) {
780 MPI_Comm_dup(MPI_COMM_WORLD, &comms[i]);
783 /* fill the entire window of ops */
784 for (i = 0; i < WINDOW; ++i) {
785 reqs[i] = MPI_REQUEST_NULL;
786 memset(&larr[i], 0, sizeof(struct laundry));
787 larr[i].case_num = -1;
789 /* randomly select a comm, using a new seed to avoid correlating
790 * particular kinds of NBC ops with particular communicators */
791 comm = comms[rand_range(gen_prn(post_seq), 0, NUM_COMMS)];
793 start_random_nonblocking(comm, post_seq, &reqs[i], &larr[i]);
795 post_seq = gen_prn(post_seq);
798 /* now loop repeatedly, completing ops with "random" completion functions,
799 * until we've posted and completed MAIN_ITERATIONS ops */
800 while (num_completed < MAIN_ITERATIONS) {
801 complete_something_somehow(complete_seq, WINDOW, reqs, &outcount, indices);
802 complete_seq = gen_prn(complete_seq);
803 for (i = 0; i < outcount; ++i) {
804 int idx = indices[i];
805 assert(reqs[idx] == MPI_REQUEST_NULL);
806 if (larr[idx].case_num != -1) {
807 check_after_completion(&larr[idx]);
808 cleanup_laundry(&larr[idx]);
810 if (num_posted < MAIN_ITERATIONS) {
811 comm = comms[rand_range(gen_prn(post_seq), 0, NUM_COMMS)];
812 start_random_nonblocking(comm, post_seq, &reqs[idx], &larr[idx]);
814 post_seq = gen_prn(post_seq);
819 /* "randomly" and infrequently introduce some jitter into the system */
820 if (0 == rand_range(gen_prn(complete_seq + wrank), 0, CHANCE_OF_SLEEP)) {
821 usleep(JITTER_DELAY); /* take a short nap */
825 for (i = 0; i < NUM_COMMS; ++i) {
826 MPI_Comm_free(&comms[i]);
831 printf("found %d errors\n", errs);
833 printf(" No errors\n");