Skip to content
Snippets Groups Projects
Commit f26ba2de authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Add option to randomize sends and recvs independently

parent ea3fbee7
No related branches found
No related tags found
1 merge request!6Version with faked data
......@@ -304,8 +304,9 @@ static int cmp_logs(const void *p1, const void *p2) {
* 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 the
* original logs.
* @param random randomize injection order of sends or sends and recvs,
* otherwise use order of the original logs. Just sends
* are randomized when 1, 2 randomizes both, 0 neither.
*/
static void pick_logs(int random) {
size_t nlogs = mpiuse_nr_logs();
......@@ -321,30 +322,65 @@ static void pick_logs(int random) {
nlogs, sizeof(struct mpiuse_log_entry *));
nr_recvs = 0;
for (int k = 0; k < nlogs; k++) {
struct mpiuse_log_entry *log = mpiuse_get_log(k);
if (log->rank == myrank && log->activation) {
log->data = NULL;
reqs_queue[nr_reqs] = log;
nr_reqs++;
if (random == 0 || random == 2) {
for (int k = 0; k < nlogs; k++) {
struct mpiuse_log_entry *log = mpiuse_get_log(k);
if (log->rank == myrank && log->activation) {
log->data = NULL;
reqs_queue[nr_reqs] = log;
nr_reqs++;
}
}
if (random == 0) {
/* 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);
}
}
if (!random) {
/* Sort into increasing time. */
qsort(reqs_queue, nr_reqs, sizeof(struct mpiuse_log_entry *), cmp_logs);
/* Check. */
if (random == 0) {
for (int k = 0; k < nr_reqs - 1; k++) {
if (reqs_queue[k]->tic > reqs_queue[k + 1]->tic)
message("reqs_queue: %lld > %lld", reqs_queue[k]->tic,
reqs_queue[k + 1]->tic);
}
}
} else {
/* Randomize the order, so ranks do not all work in sequence. */
mpiuse_shuffle_logs(reqs_queue, nr_reqs);
}
/* Check. */
if (!random) {
for (int k = 0; k < nr_reqs - 1; k++) {
if (reqs_queue[k]->tic > reqs_queue[k + 1]->tic)
message("reqs_queue: %lld > %lld", reqs_queue[k]->tic,
reqs_queue[k + 1]->tic);
/* Randomizing the sends, but injecting the recvs first. */
/* Get recvs. */
int nrecv = 0;
for (int k = 0; k < nlogs; k++) {
struct mpiuse_log_entry *log = mpiuse_get_log(k);
if (log->rank == myrank && log->activation && log->type == RECV_TYPE) {
log->data = NULL;
reqs_queue[nr_reqs] = log;
nr_reqs++;
nrecv++;
}
}
/* These are sorted into log time order. */
qsort(reqs_queue, nrecv, sizeof(struct mpiuse_log_entry *), cmp_logs);
/* Now the sends. */
int nsend = 0;
for (int k = 0; k < nlogs; k++) {
struct mpiuse_log_entry *log = mpiuse_get_log(k);
if (log->rank == myrank && log->activation && log->type == SEND_TYPE) {
log->data = NULL;
reqs_queue[nr_reqs] = log;
nr_reqs++;
nsend++;
}
}
/* These are randomized. */
mpiuse_shuffle_logs(&reqs_queue[nrecv], nsend);
}
}
......@@ -395,7 +431,7 @@ int main(int argc, char *argv[]) {
char *odata = NULL;
int opt;
unsigned int seed = default_seed;
while ((opt = getopt(argc, argv, "vds:rgx:c:o:f")) != -1) {
while ((opt = getopt(argc, argv, "vds:rgx:c:o:f:")) != -1) {
switch (opt) {
case 'd':
datacheck = 1;
......@@ -404,7 +440,7 @@ int main(int argc, char *argv[]) {
cdf = optarg;
break;
case 'f':
randomorder = 1;
randomorder = atoi(optarg);
break;
case 'g':
uniform = 0;
......@@ -481,6 +517,12 @@ int main(int argc, char *argv[]) {
}
/* Each rank requires its own queue, so extract them. */
if (verbose && myrank == 0) {
if (randomorder == 0) message("Message order same as generated");
if (randomorder == 1) message("Message send order randomized");
if (randomorder == 2) message("Message send and recv order randomized");
}
pick_logs(randomorder);
/* Time to start time. Try to make it synchronous across the ranks. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment