Skip to content
Snippets Groups Projects

Add an option to fix the message size

Merged Peter W. Draper requested to merge fixed-size into master
+ 20
5
@@ -38,6 +38,10 @@ static int verbose = 0;
/* Attempt to keep original injection time differences. */
static int usetics = 1;
/* Size of the messages we send. This overrides the logged values when not
* zero . */
static size_t messagesize = 0;
/* Integer types of send and recv tasks, must match log. */
static const int task_type_send = 22;
static const int task_type_recv = 23;
@@ -127,6 +131,7 @@ static void *inject_thread(void *arg) {
/* Differences to SWIFT: MPI_BYTE not the MPI_Type. */
int err = 0;
if (log->type == task_type_send) {
log->data = calloc(log->size, 1);
err = MPI_Isend(log->data, log->size, MPI_BYTE, log->otherrank, log->tag,
subtypeMPI_comms[log->subtype], &log->req);
@@ -136,6 +141,7 @@ static void *inject_thread(void *arg) {
atomic_inc(&todo_send);
} else {
log->data = calloc(log->size, 1);
err = MPI_Irecv(log->data, log->size, MPI_BYTE, log->otherrank, log->tag,
subtypeMPI_comms[log->subtype], &log->req);
@@ -325,7 +331,7 @@ static void pick_logs(void) {
nlogs, sizeof(struct mpiuse_log_entry *));
nr_reqs = 0;
sends_queue = (struct mpiuse_log_entry **)calloc(
nlogs, sizeof(struct mpiuse_log_entry *) * nlogs);
nlogs, sizeof(struct mpiuse_log_entry *));
nr_sends = 0;
recvs_queue = (struct mpiuse_log_entry **)calloc(
nlogs, sizeof(struct mpiuse_log_entry *));
@@ -336,10 +342,11 @@ static void pick_logs(void) {
if (log->rank == myrank && log->activation) {
if (log->type == task_type_send || log->type == task_type_recv) {
/* Allocate space for data. */
log->data = calloc(log->size, 1);
/* Override size if needed. */
if (messagesize > 0) log->size = messagesize;
/* And keep this log. */
log->data = NULL;
reqs_queue[nr_reqs] = log;
nr_reqs++;
@@ -366,7 +373,8 @@ static void pick_logs(void) {
static void usage(char *argv[]) {
fprintf(stderr, "Usage: %s [-vf] SWIFT_mpiuse-log-file.dat logfile.dat\n",
argv[0]);
fprintf(stderr, " options: -v verbose, -f fast injections\n");
fprintf(stderr, " options: -v verbose, -f fast injections, "
"-s message size (bytes)\n");
fflush(stderr);
}
@@ -392,7 +400,7 @@ int main(int argc, char *argv[]) {
/* Handle the command-line, we expect a mpiuse data file to read and various
* options. */
int opt;
while ((opt = getopt(argc, argv, "vf")) != -1) {
while ((opt = getopt(argc, argv, "vfs:")) != -1) {
switch (opt) {
case 'f':
usetics = 0;
@@ -400,6 +408,9 @@ int main(int argc, char *argv[]) {
case 'v':
verbose = 1;
break;
case 's':
messagesize = atoll(optarg);
break;
default:
if (myrank == 0) usage(argv);
return 1;
@@ -438,6 +449,10 @@ int main(int argc, char *argv[]) {
if (myrank == 0) {
message("Start of MPI tests");
message("==================");
if (messagesize > 0) {
message(" ");
message(" Using fixed message size of %zd", messagesize);
}
}
/* Make three threads, one for injecting tasks and two to check for
Loading