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

Add the correct global communicators

parent 4de7da6b
No related branches found
No related tags found
No related merge requests found
......@@ -15,12 +15,16 @@
#include "error.h"
#include "mpiuse.h"
/* Global: Our rank for all to see. */
int myrank = -1;
/* Integer types of send and recv tasks, must match log. */
static int task_type_send = 22;
static int task_type_recv = 23;
static const int task_type_send = 22;
static const int task_type_recv = 23;
/* Our rank for all to see. */
int myrank = -1;
/* Global communicators for each of the subtypes. */
static const int task_subtype_count = 30; // Just some upper limit on subtype.
static MPI_Comm subtypeMPI_comms[30];
/* The local queues. */
static struct mpiuse_log_entry **volatile reqs_queue;
......@@ -53,7 +57,7 @@ static void *inject_thread(void *arg) {
int err = 0;
if (log->type == task_type_send) {
err = MPI_Isend(log->data, log->size, MPI_BYTE, log->otherrank,
log->tag, MPI_COMM_WORLD, &log->req);
log->tag, subtypeMPI_comms[log->subtype], &log->req);
/* Add a new send request. */
int ind = atomic_inc(&nr_sends);
......@@ -62,7 +66,7 @@ static void *inject_thread(void *arg) {
} else {
err = MPI_Irecv(log->data, log->size, MPI_BYTE, log->rank,
log->tag, MPI_COMM_WORLD, &log->req);
log->tag, subtypeMPI_comms[log->subtype], &log->req);
/* Add a new recv request. */
int ind = atomic_inc(&nr_recvs);
......@@ -223,6 +227,10 @@ int main(int argc, char *argv[]) {
if (res != MPI_SUCCESS)
error("Call to MPI_Comm_rank failed with error %i.", res);
/* Create communicators for each subtype of the tasks. */
for (int i = 0; i < task_subtype_count; i++) {
MPI_Comm_dup(MPI_COMM_WORLD, &subtypeMPI_comms[i]);
}
message("Starts");
/* Each rank requires its own queue, so extract them. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment