diff --git a/swiftmpifakestepsim.c b/swiftmpifakestepsim.c index 9939f1a4854c2111c1d72e41559b9d8e87420902..2aa75cd9b89f5cf69852d2d95132238123b3b6ab 100644 --- a/swiftmpifakestepsim.c +++ b/swiftmpifakestepsim.c @@ -288,15 +288,15 @@ static void *recv_thread(void *arg) { /** * @brief Comparison function for logged times. */ -// static int cmp_logs(const void *p1, const void *p2) { -// struct mpiuse_log_entry *l1 = *(struct mpiuse_log_entry **)p1; -// struct mpiuse_log_entry *l2 = *(struct mpiuse_log_entry **)p2; -// -// /* Large unsigned values, so take care. */ -// if (l1->tic > l2->tic) return 1; -// if (l1->tic < l2->tic) return -1; -// return 0; -//} +static int cmp_logs(const void *p1, const void *p2) { + struct mpiuse_log_entry *l1 = *(struct mpiuse_log_entry **)p1; + struct mpiuse_log_entry *l2 = *(struct mpiuse_log_entry **)p2; + + /* Large unsigned values, so take care. */ + if (l1->tic > l2->tic) return 1; + if (l1->tic < l2->tic) return -1; + return 0; +} /** * @brief Pick out the relevant logging data for our rank, i.e. all @@ -304,7 +304,7 @@ static void *recv_thread(void *arg) { * The final list is sorted into increasing time of activation if required, * otherwise the order is randomized. * - * @param random randomize injection order, otherwise use order of thr + * @param random randomize injection order, otherwise use order of the * original logs. */ static void pick_logs(int random) { @@ -330,11 +330,13 @@ static void pick_logs(int random) { } } - /* Sort into increasing time. */ - // qsort(reqs_queue, nr_reqs, sizeof(struct mpiuse_log_entry *), cmp_logs); - - /* Randomize the order, so ranks do not all work in sequence. */ - mpiuse_shuffle_logs(reqs_queue, nr_reqs); + if (!random) { + /* Sort into increasing time. */ + qsort(reqs_queue, nr_reqs, sizeof(struct mpiuse_log_entry *), cmp_logs); + } else { + /* Randomize the order, so ranks do not all work in sequence. */ + mpiuse_shuffle_logs(reqs_queue, nr_reqs); + } /* Check. */ if (!random) {