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 (1000)
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 */
98 MPI_Datatype *sendtypes;
99 MPI_Datatype *recvtypes;
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 MPI_Datatype *sendtypes = NULL;
140 MPI_Datatype *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 char *buf_alias = (char *) buf;
420 MPI_Comm_rank(comm, &rank);
421 MPI_Comm_size(comm, &size);
423 /* these cases all correspond to cases in start_random_nonblocking */
424 switch (l->case_num) {
425 case 0: /* MPI_Ibcast */
426 for (i = 0; i < COUNT; ++i) {
428 printf("buf[%d]=%d i=%d\n", i, buf[i], i);
429 my_assert(buf[i] == i);
433 case 1: /* MPI_Ibcast (again, but designed to stress scatter/allgather impls) */
434 for (i = 0; i < PRIME; ++i) {
435 if (buf_alias[i] != i)
436 printf("buf_alias[%d]=%d i=%d\n", i, buf_alias[i], i);
437 my_assert(buf_alias[i] == i);
441 case 2: /* MPI_Ibarrier */
442 /* nothing to check */
445 case 3: /* MPI_Ireduce */
447 for (i = 0; i < COUNT; ++i) {
448 if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
449 printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
450 ((size * (size - 1) / 2) + (i * size)));
451 my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
456 case 4: /* same again, use a user op and free it before the wait */
458 for (i = 0; i < COUNT; ++i) {
459 if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
460 printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
461 ((size * (size - 1) / 2) + (i * size)));
462 my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
467 case 5: /* MPI_Iallreduce */
468 for (i = 0; i < COUNT; ++i) {
469 if (recvbuf[i] != ((size * (size - 1) / 2) + (i * size)))
470 printf("got recvbuf[%d]=%d, expected %d\n", i, recvbuf[i],
471 ((size * (size - 1) / 2) + (i * size)));
472 my_assert(recvbuf[i] == ((size * (size - 1) / 2) + (i * size)));
476 case 6: /* MPI_Ialltoallv (a weak test, neither irregular nor sparse) */
477 for (i = 0; i < size; ++i) {
478 for (j = 0; j < COUNT; ++j) {
479 /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */
480 my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
485 case 7: /* MPI_Igather */
487 for (i = 0; i < size; ++i) {
488 for (j = 0; j < COUNT; ++j) {
489 my_assert(recvbuf[i * COUNT + j] == i + j);
494 for (i = 0; i < size * COUNT; ++i) {
495 my_assert(recvbuf[i] == 0xdeadbeef);
500 case 8: /* same test again, just use a dup'ed datatype and free it before the wait */
502 for (i = 0; i < size; ++i) {
503 for (j = 0; j < COUNT; ++j) {
504 my_assert(recvbuf[i * COUNT + j] == i + j);
509 for (i = 0; i < size * COUNT; ++i) {
510 my_assert(recvbuf[i] == 0xdeadbeef);
515 case 9: /* MPI_Iscatter */
516 for (j = 0; j < COUNT; ++j) {
517 my_assert(recvbuf[j] == rank + j);
520 for (i = 0; i < size * COUNT; ++i) {
521 /* check we didn't corrupt the sendbuf somehow */
522 my_assert(buf[i] == 0xdeadbeef);
527 case 10: /* MPI_Iscatterv */
528 for (j = 0; j < COUNT; ++j) {
529 my_assert(recvbuf[j] == rank + j);
532 for (i = 0; i < size * COUNT; ++i) {
533 /* check we didn't corrupt the sendbuf somehow */
534 my_assert(buf[i] == 0xdeadbeef);
537 for (i = 1; i < size; ++i) {
538 for (j = 0; j < COUNT; ++j) {
539 /* check we didn't corrupt the rest of the recvbuf */
540 my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
545 case 11: /* MPI_Ireduce_scatter */
546 for (j = 0; j < COUNT; ++j) {
547 my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2));
549 for (i = 1; i < size; ++i) {
550 for (j = 0; j < COUNT; ++j) {
551 /* check we didn't corrupt the rest of the recvbuf */
552 my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
557 case 12: /* MPI_Ireduce_scatter_block */
558 for (j = 0; j < COUNT; ++j) {
559 my_assert(recvbuf[j] == (size * rank + ((size - 1) * size) / 2));
561 for (i = 1; i < size; ++i) {
562 for (j = 0; j < COUNT; ++j) {
563 /* check we didn't corrupt the rest of the recvbuf */
564 my_assert(recvbuf[i * COUNT + j] == 0xdeadbeef);
569 case 13: /* MPI_Igatherv */
571 for (i = 0; i < size; ++i) {
572 for (j = 0; j < COUNT; ++j) {
573 my_assert(recvbuf[i * COUNT + j] == i + j);
578 for (i = 0; i < size * COUNT; ++i) {
579 my_assert(recvbuf[i] == 0xdeadbeef);
584 case 14: /* MPI_Ialltoall */
585 for (i = 0; i < size; ++i) {
586 for (j = 0; j < COUNT; ++j) {
587 /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (i * j))); */
588 my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
593 case 15: /* MPI_Iallgather */
594 for (i = 0; i < size; ++i) {
595 for (j = 0; j < COUNT; ++j) {
596 my_assert(recvbuf[i * COUNT + j] == i + j);
601 case 16: /* MPI_Iallgatherv */
602 for (i = 0; i < size; ++i) {
603 for (j = 0; j < COUNT; ++j) {
604 my_assert(recvbuf[i * COUNT + j] == i + j);
609 case 17: /* MPI_Iscan */
610 for (i = 0; i < COUNT; ++i) {
611 my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1))));
615 case 18: /* MPI_Iexscan */
616 for (i = 0; i < COUNT; ++i) {
618 my_assert(recvbuf[i] == 0xdeadbeef);
620 my_assert(recvbuf[i] == ((rank * (rank + 1) / 2) + (i * (rank + 1)) - (rank + i)));
624 case 19: /* MPI_Ialltoallw (a weak test, neither irregular nor sparse) */
625 for (i = 0; i < size; ++i) {
626 for (j = 0; j < COUNT; ++j) {
627 /*printf("recvbuf[%d*COUNT+%d]=%d, expecting %d\n", i, j, recvbuf[i*COUNT+j], (i + (rank * j))); */
628 my_assert(recvbuf[i * COUNT + j] == (i + (rank * j)));
633 case 20: /* basic pt2pt MPI_Isend/MPI_Irecv pairing */
634 /* even ranks send to odd ranks, but only if we have a full pair */
635 if ((rank % 2 != 0) || (rank != size - 1)) {
636 for (j = 0; j < COUNT; ++j) {
637 /* only odd procs did a recv */
639 my_assert(recvbuf[j] == 0xdeadbeef);
643 printf("recvbuf[%d]=%d j=%d\n", j, recvbuf[j], j);
644 my_assert(recvbuf[j] == j);
651 printf("invalid case_num (%d) detected\n", l->case_num);
659 static void complete_something_somehow(unsigned int rndnum, int numreqs, MPI_Request reqs[],
660 int *outcount, int indices[])
664 #define COMPLETION_CASES (8)
665 switch (rand_range(rndnum, 0, COMPLETION_CASES)) {
667 MPI_Waitall(numreqs, reqs, MPI_STATUSES_IGNORE);
669 for (i = 0; i < numreqs; ++i) {
675 MPI_Testsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE);
676 if (*outcount == MPI_UNDEFINED) {
682 MPI_Waitsome(numreqs, reqs, outcount, indices, MPI_STATUS_IGNORE);
683 if (*outcount == MPI_UNDEFINED) {
689 MPI_Waitany(numreqs, reqs, &idx, MPI_STATUS_IGNORE);
690 if (idx == MPI_UNDEFINED) {
700 MPI_Testany(numreqs, reqs, &idx, &flag, MPI_STATUS_IGNORE);
701 if (idx == MPI_UNDEFINED) {
711 MPI_Testall(numreqs, reqs, &flag, MPI_STATUSES_IGNORE);
714 for (i = 0; i < numreqs; ++i) {
724 /* select a new random index and wait on it */
725 rndnum = gen_prn(rndnum);
726 idx = rand_range(rndnum, 0, numreqs);
727 MPI_Wait(&reqs[idx], MPI_STATUS_IGNORE);
733 /* select a new random index and wait on it */
734 rndnum = gen_prn(rndnum);
735 idx = rand_range(rndnum, 0, numreqs);
736 MPI_Test(&reqs[idx], &flag, MPI_STATUS_IGNORE);
737 *outcount = (flag ? 1 : 0);
745 #undef COMPLETION_CASES
748 int main(int argc, char **argv)
750 int i, num_posted, num_completed;
752 unsigned int seed = 0x10bc;
753 unsigned int post_seq, complete_seq;
754 struct laundry larr[WINDOW];
755 MPI_Request reqs[WINDOW];
758 MPI_Comm comms[NUM_COMMS];
761 MPI_Init(&argc, &argv);
762 MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
763 MPI_Comm_size(MPI_COMM_WORLD, &wsize);
765 /* it is critical that all processes in the communicator start with a
766 * consistent value for "post_seq" */
767 post_seq = complete_seq = gen_prn(seed);
772 /* construct all of the communicators, just dups of comm world for now */
773 for (i = 0; i < NUM_COMMS; ++i) {
774 MPI_Comm_dup(MPI_COMM_WORLD, &comms[i]);
777 /* fill the entire window of ops */
778 for (i = 0; i < WINDOW; ++i) {
779 reqs[i] = MPI_REQUEST_NULL;
780 memset(&larr[i], 0, sizeof(struct laundry));
781 larr[i].case_num = -1;
783 /* randomly select a comm, using a new seed to avoid correlating
784 * particular kinds of NBC ops with particular communicators */
785 comm = comms[rand_range(gen_prn(post_seq), 0, NUM_COMMS)];
787 start_random_nonblocking(comm, post_seq, &reqs[i], &larr[i]);
789 post_seq = gen_prn(post_seq);
792 /* now loop repeatedly, completing ops with "random" completion functions,
793 * until we've posted and completed MAIN_ITERATIONS ops */
794 while (num_completed < MAIN_ITERATIONS) {
795 complete_something_somehow(complete_seq, WINDOW, reqs, &outcount, indices);
796 complete_seq = gen_prn(complete_seq);
797 for (i = 0; i < outcount; ++i) {
798 int idx = indices[i];
799 // assert(reqs[idx] == MPI_REQUEST_NULL);
800 if (larr[idx].case_num != -1) {
801 check_after_completion(&larr[idx]);
802 cleanup_laundry(&larr[idx]);
804 if (num_posted < MAIN_ITERATIONS) {
805 comm = comms[rand_range(gen_prn(post_seq), 0, NUM_COMMS)];
806 start_random_nonblocking(comm, post_seq, &reqs[idx], &larr[idx]);
808 post_seq = gen_prn(post_seq);
813 /* "randomly" and infrequently introduce some jitter into the system */
814 if (0 == rand_range(gen_prn(complete_seq + wrank), 0, CHANCE_OF_SLEEP)) {
815 usleep(JITTER_DELAY); /* take a short nap */
819 for (i = 0; i < NUM_COMMS; ++i) {
820 MPI_Comm_free(&comms[i]);
825 printf("found %d errors\n", errs);
827 printf(" No errors\n");