Skip to content

Instantly share code, notes, and snippets.

@zhengyang92
Created June 17, 2020 20:03
Show Gist options
  • Save zhengyang92/98a848c550b9fd6619f0ded09713642d to your computer and use it in GitHub Desktop.
Save zhengyang92/98a848c550b9fd6619f0ded09713642d to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<assert.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include "mpi.h"
#include "accl_util.h"
#include "cuda_runtime_api.h"
#define CUDACHECK(cmd) do { \
cudaError_t e = cmd; \
if( e != cudaSuccess ) { \
printf("Failed: Cuda error %s:%d '%s'\n", \
__FILE__,__LINE__,cudaGetErrorString(e)); \
exit(1); \
} \
} while(0)
extern "C" void ACCL_Allreduce(const int *sendbuf, int *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
void ACCL_Allreduce(const int *sendbuf, int *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) {
assert(datatype == MPI_INT);
assert(op == MPI_SUM);
assert(comm == MPI_COMM_WORLD);
int size;
MPI_Comm_size(comm, &size);
assert(4 == size);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
switch(rank){
case 0:
;
recvbuf[0] = sendbuf[0];
recvbuf[1] = sendbuf[1];
recvbuf[2] = sendbuf[2];
recvbuf[3] = sendbuf[3];
int step_0_rank_0_idx_0_sum;
int step_0_rank_0_idx_1_sum;
int step_0_rank_0_idx_2_sum;
int step_0_rank_0_idx_3_sum;
step_0_rank_0_idx_0_sum = 0;
step_0_rank_0_idx_1_sum = 0;
step_0_rank_0_idx_2_sum = 0;
step_0_rank_0_idx_3_sum = 0;
int step_0_node_0_recv_2_from_1;
MPI_Request req_step_0_node_0_recv_2_from_1;
MPI_Irecv(&step_0_node_0_recv_2_from_1, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_0_node_0_recv_2_from_1);
int step_0_node_0_recv_3_from_2;
MPI_Request req_step_0_node_0_recv_3_from_2;
MPI_Irecv(&step_0_node_0_recv_3_from_2, 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_0_node_0_recv_3_from_2);
int step_0_node_0_recv_1_from_3;
MPI_Request req_step_0_node_0_recv_1_from_3;
MPI_Irecv(&step_0_node_0_recv_1_from_3, 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_0_node_0_recv_1_from_3);
int step_0_node_0_recv_0_from_3;
MPI_Request req_step_0_node_0_recv_0_from_3;
MPI_Irecv(&step_0_node_0_recv_0_from_3, 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_0_node_0_recv_0_from_3);
MPI_Request req_step_0_node_0_send_2_to_1;
MPI_Isend(&recvbuf[2], 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_0_node_0_send_2_to_1);
MPI_Request req_step_0_node_0_send_3_to_2;
MPI_Isend(&recvbuf[3], 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_0_node_0_send_3_to_2);
MPI_Request req_step_0_node_0_send_1_to_3;
MPI_Isend(&recvbuf[1], 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_0_node_0_send_1_to_3);
MPI_Request req_step_0_node_0_send_0_to_3;
MPI_Isend(&recvbuf[0], 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_0_node_0_send_0_to_3);
MPI_Wait(&req_step_0_node_0_recv_2_from_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_0_recv_3_from_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_0_recv_1_from_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_0_recv_0_from_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_0_send_2_to_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_0_send_3_to_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_0_send_1_to_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_0_send_0_to_3, MPI_STATUS_IGNORE);
step_0_rank_0_idx_2_sum += step_0_node_0_recv_2_from_1;
step_0_rank_0_idx_3_sum += step_0_node_0_recv_3_from_2;
step_0_rank_0_idx_1_sum += step_0_node_0_recv_1_from_3;
step_0_rank_0_idx_0_sum += step_0_node_0_recv_0_from_3;
recvbuf[0] += step_0_rank_0_idx_0_sum;
recvbuf[1] += step_0_rank_0_idx_1_sum;
recvbuf[2] += step_0_rank_0_idx_2_sum;
recvbuf[3] += step_0_rank_0_idx_3_sum;
int step_1_rank_0_idx_0_sum;
int step_1_rank_0_idx_1_sum;
int step_1_rank_0_idx_2_sum;
int step_1_rank_0_idx_3_sum;
step_1_rank_0_idx_0_sum = 0;
step_1_rank_0_idx_1_sum = 0;
step_1_rank_0_idx_2_sum = 0;
step_1_rank_0_idx_3_sum = 0;
int step_1_node_0_recv_0_from_1;
MPI_Request req_step_1_node_0_recv_0_from_1;
MPI_Irecv(&step_1_node_0_recv_0_from_1, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_1_node_0_recv_0_from_1);
int step_1_node_0_recv_1_from_2;
MPI_Request req_step_1_node_0_recv_1_from_2;
MPI_Irecv(&step_1_node_0_recv_1_from_2, 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_1_node_0_recv_1_from_2);
int step_1_node_0_recv_2_from_3;
MPI_Request req_step_1_node_0_recv_2_from_3;
MPI_Irecv(&step_1_node_0_recv_2_from_3, 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_1_node_0_recv_2_from_3);
int step_1_node_0_recv_3_from_3;
MPI_Request req_step_1_node_0_recv_3_from_3;
MPI_Irecv(&step_1_node_0_recv_3_from_3, 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_1_node_0_recv_3_from_3);
MPI_Request req_step_1_node_0_send_0_to_1;
MPI_Isend(&recvbuf[0], 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_1_node_0_send_0_to_1);
MPI_Request req_step_1_node_0_send_0_to_2;
MPI_Isend(&recvbuf[0], 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_1_node_0_send_0_to_2);
MPI_Request req_step_1_node_0_send_2_to_3;
MPI_Isend(&recvbuf[2], 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_1_node_0_send_2_to_3);
MPI_Request req_step_1_node_0_send_3_to_3;
MPI_Isend(&recvbuf[3], 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_1_node_0_send_3_to_3);
MPI_Wait(&req_step_1_node_0_recv_0_from_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_0_recv_1_from_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_0_recv_2_from_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_0_recv_3_from_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_0_send_0_to_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_0_send_0_to_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_0_send_2_to_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_0_send_3_to_3, MPI_STATUS_IGNORE);
step_1_rank_0_idx_0_sum += step_1_node_0_recv_0_from_1;
step_1_rank_0_idx_1_sum += step_1_node_0_recv_1_from_2;
step_1_rank_0_idx_2_sum += step_1_node_0_recv_2_from_3;
step_1_rank_0_idx_3_sum += step_1_node_0_recv_3_from_3;
recvbuf[0] += step_1_rank_0_idx_0_sum;
recvbuf[1] += step_1_rank_0_idx_1_sum;
recvbuf[2] += step_1_rank_0_idx_2_sum;
recvbuf[3] += step_1_rank_0_idx_3_sum;
break;
case 1:
;
recvbuf[0] = sendbuf[0];
recvbuf[1] = sendbuf[1];
recvbuf[2] = sendbuf[2];
recvbuf[3] = sendbuf[3];
int step_0_rank_1_idx_0_sum;
int step_0_rank_1_idx_1_sum;
int step_0_rank_1_idx_2_sum;
int step_0_rank_1_idx_3_sum;
step_0_rank_1_idx_0_sum = 0;
step_0_rank_1_idx_1_sum = 0;
step_0_rank_1_idx_2_sum = 0;
step_0_rank_1_idx_3_sum = 0;
MPI_Request req_step_0_node_1_send_2_to_0;
MPI_Isend(&recvbuf[2], 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_0_node_1_send_2_to_0);
int step_0_node_1_recv_2_from_0;
MPI_Request req_step_0_node_1_recv_2_from_0;
MPI_Irecv(&step_0_node_1_recv_2_from_0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_0_node_1_recv_2_from_0);
int step_0_node_1_recv_0_from_2;
MPI_Request req_step_0_node_1_recv_0_from_2;
MPI_Irecv(&step_0_node_1_recv_0_from_2, 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_0_node_1_recv_0_from_2);
int step_0_node_1_recv_1_from_2;
MPI_Request req_step_0_node_1_recv_1_from_2;
MPI_Irecv(&step_0_node_1_recv_1_from_2, 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_0_node_1_recv_1_from_2);
int step_0_node_1_recv_2_from_3;
MPI_Request req_step_0_node_1_recv_2_from_3;
MPI_Irecv(&step_0_node_1_recv_2_from_3, 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_0_node_1_recv_2_from_3);
MPI_Request req_step_0_node_1_send_0_to_2;
MPI_Isend(&recvbuf[0], 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_0_node_1_send_0_to_2);
MPI_Request req_step_0_node_1_send_1_to_2;
MPI_Isend(&recvbuf[1], 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_0_node_1_send_1_to_2);
MPI_Request req_step_0_node_1_send_3_to_3;
MPI_Isend(&recvbuf[3], 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_0_node_1_send_3_to_3);
MPI_Wait(&req_step_0_node_1_send_2_to_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_1_recv_2_from_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_1_recv_0_from_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_1_recv_1_from_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_1_recv_2_from_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_1_send_0_to_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_1_send_1_to_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_1_send_3_to_3, MPI_STATUS_IGNORE);
step_0_rank_1_idx_2_sum += step_0_node_1_recv_2_from_0;
step_0_rank_1_idx_0_sum += step_0_node_1_recv_0_from_2;
step_0_rank_1_idx_1_sum += step_0_node_1_recv_1_from_2;
step_0_rank_1_idx_2_sum += step_0_node_1_recv_2_from_3;
recvbuf[0] += step_0_rank_1_idx_0_sum;
recvbuf[1] += step_0_rank_1_idx_1_sum;
recvbuf[2] += step_0_rank_1_idx_2_sum;
recvbuf[3] += step_0_rank_1_idx_3_sum;
int step_1_rank_1_idx_0_sum;
int step_1_rank_1_idx_1_sum;
int step_1_rank_1_idx_2_sum;
int step_1_rank_1_idx_3_sum;
step_1_rank_1_idx_0_sum = 0;
step_1_rank_1_idx_1_sum = 0;
step_1_rank_1_idx_2_sum = 0;
step_1_rank_1_idx_3_sum = 0;
MPI_Request req_step_1_node_1_send_0_to_0;
MPI_Isend(&recvbuf[0], 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_1_node_1_send_0_to_0);
int step_1_node_1_recv_0_from_0;
MPI_Request req_step_1_node_1_recv_0_from_0;
MPI_Irecv(&step_1_node_1_recv_0_from_0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_1_node_1_recv_0_from_0);
int step_1_node_1_recv_2_from_2;
MPI_Request req_step_1_node_1_recv_2_from_2;
MPI_Irecv(&step_1_node_1_recv_2_from_2, 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_1_node_1_recv_2_from_2);
int step_1_node_1_recv_3_from_2;
MPI_Request req_step_1_node_1_recv_3_from_2;
MPI_Irecv(&step_1_node_1_recv_3_from_2, 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_1_node_1_recv_3_from_2);
int step_1_node_1_recv_1_from_3;
MPI_Request req_step_1_node_1_recv_1_from_3;
MPI_Irecv(&step_1_node_1_recv_1_from_3, 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_1_node_1_recv_1_from_3);
MPI_Request req_step_1_node_1_send_2_to_2;
MPI_Isend(&recvbuf[2], 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_1_node_1_send_2_to_2);
MPI_Request req_step_1_node_1_send_3_to_2;
MPI_Isend(&recvbuf[3], 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_1_node_1_send_3_to_2);
MPI_Request req_step_1_node_1_send_1_to_3;
MPI_Isend(&recvbuf[1], 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_1_node_1_send_1_to_3);
MPI_Wait(&req_step_1_node_1_send_0_to_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_1_recv_0_from_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_1_recv_2_from_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_1_recv_3_from_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_1_recv_1_from_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_1_send_2_to_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_1_send_3_to_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_1_send_1_to_3, MPI_STATUS_IGNORE);
step_1_rank_1_idx_0_sum += step_1_node_1_recv_0_from_0;
step_1_rank_1_idx_2_sum += step_1_node_1_recv_2_from_2;
step_1_rank_1_idx_3_sum += step_1_node_1_recv_3_from_2;
step_1_rank_1_idx_1_sum += step_1_node_1_recv_1_from_3;
recvbuf[0] += step_1_rank_1_idx_0_sum;
recvbuf[1] += step_1_rank_1_idx_1_sum;
recvbuf[2] += step_1_rank_1_idx_2_sum;
recvbuf[3] += step_1_rank_1_idx_3_sum;
break;
case 2:
;
recvbuf[0] = sendbuf[0];
recvbuf[1] = sendbuf[1];
recvbuf[2] = sendbuf[2];
recvbuf[3] = sendbuf[3];
int step_0_rank_2_idx_0_sum;
int step_0_rank_2_idx_1_sum;
int step_0_rank_2_idx_2_sum;
int step_0_rank_2_idx_3_sum;
step_0_rank_2_idx_0_sum = 0;
step_0_rank_2_idx_1_sum = 0;
step_0_rank_2_idx_2_sum = 0;
step_0_rank_2_idx_3_sum = 0;
MPI_Request req_step_0_node_2_send_3_to_0;
MPI_Isend(&recvbuf[3], 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_0_node_2_send_3_to_0);
MPI_Request req_step_0_node_2_send_0_to_1;
MPI_Isend(&recvbuf[0], 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_0_node_2_send_0_to_1);
MPI_Request req_step_0_node_2_send_1_to_1;
MPI_Isend(&recvbuf[1], 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_0_node_2_send_1_to_1);
int step_0_node_2_recv_3_from_0;
MPI_Request req_step_0_node_2_recv_3_from_0;
MPI_Irecv(&step_0_node_2_recv_3_from_0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_0_node_2_recv_3_from_0);
int step_0_node_2_recv_0_from_1;
MPI_Request req_step_0_node_2_recv_0_from_1;
MPI_Irecv(&step_0_node_2_recv_0_from_1, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_0_node_2_recv_0_from_1);
int step_0_node_2_recv_1_from_1;
MPI_Request req_step_0_node_2_recv_1_from_1;
MPI_Irecv(&step_0_node_2_recv_1_from_1, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_0_node_2_recv_1_from_1);
int step_0_node_2_recv_3_from_3;
MPI_Request req_step_0_node_2_recv_3_from_3;
MPI_Irecv(&step_0_node_2_recv_3_from_3, 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_0_node_2_recv_3_from_3);
MPI_Request req_step_0_node_2_send_2_to_3;
MPI_Isend(&recvbuf[2], 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_0_node_2_send_2_to_3);
MPI_Wait(&req_step_0_node_2_send_3_to_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_2_send_0_to_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_2_send_1_to_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_2_recv_3_from_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_2_recv_0_from_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_2_recv_1_from_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_2_recv_3_from_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_2_send_2_to_3, MPI_STATUS_IGNORE);
step_0_rank_2_idx_3_sum += step_0_node_2_recv_3_from_0;
step_0_rank_2_idx_0_sum += step_0_node_2_recv_0_from_1;
step_0_rank_2_idx_1_sum += step_0_node_2_recv_1_from_1;
step_0_rank_2_idx_3_sum += step_0_node_2_recv_3_from_3;
recvbuf[0] += step_0_rank_2_idx_0_sum;
recvbuf[1] += step_0_rank_2_idx_1_sum;
recvbuf[2] += step_0_rank_2_idx_2_sum;
recvbuf[3] += step_0_rank_2_idx_3_sum;
int step_1_rank_2_idx_0_sum;
int step_1_rank_2_idx_1_sum;
int step_1_rank_2_idx_2_sum;
int step_1_rank_2_idx_3_sum;
step_1_rank_2_idx_0_sum = 0;
step_1_rank_2_idx_1_sum = 0;
step_1_rank_2_idx_2_sum = 0;
step_1_rank_2_idx_3_sum = 0;
MPI_Request req_step_1_node_2_send_1_to_0;
MPI_Isend(&recvbuf[1], 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_1_node_2_send_1_to_0);
MPI_Request req_step_1_node_2_send_2_to_1;
MPI_Isend(&recvbuf[2], 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_1_node_2_send_2_to_1);
MPI_Request req_step_1_node_2_send_3_to_1;
MPI_Isend(&recvbuf[3], 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_1_node_2_send_3_to_1);
int step_1_node_2_recv_0_from_0;
MPI_Request req_step_1_node_2_recv_0_from_0;
MPI_Irecv(&step_1_node_2_recv_0_from_0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_1_node_2_recv_0_from_0);
int step_1_node_2_recv_2_from_1;
MPI_Request req_step_1_node_2_recv_2_from_1;
MPI_Irecv(&step_1_node_2_recv_2_from_1, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_1_node_2_recv_2_from_1);
int step_1_node_2_recv_3_from_1;
MPI_Request req_step_1_node_2_recv_3_from_1;
MPI_Irecv(&step_1_node_2_recv_3_from_1, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_1_node_2_recv_3_from_1);
int step_1_node_2_recv_1_from_3;
MPI_Request req_step_1_node_2_recv_1_from_3;
MPI_Irecv(&step_1_node_2_recv_1_from_3, 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_1_node_2_recv_1_from_3);
MPI_Request req_step_1_node_2_send_0_to_3;
MPI_Isend(&recvbuf[0], 1, MPI_INT, 3, 0, MPI_COMM_WORLD, &req_step_1_node_2_send_0_to_3);
MPI_Wait(&req_step_1_node_2_send_1_to_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_2_send_2_to_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_2_send_3_to_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_2_recv_0_from_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_2_recv_2_from_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_2_recv_3_from_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_2_recv_1_from_3, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_2_send_0_to_3, MPI_STATUS_IGNORE);
step_1_rank_2_idx_0_sum += step_1_node_2_recv_0_from_0;
step_1_rank_2_idx_2_sum += step_1_node_2_recv_2_from_1;
step_1_rank_2_idx_3_sum += step_1_node_2_recv_3_from_1;
step_1_rank_2_idx_1_sum += step_1_node_2_recv_1_from_3;
recvbuf[0] += step_1_rank_2_idx_0_sum;
recvbuf[1] += step_1_rank_2_idx_1_sum;
recvbuf[2] += step_1_rank_2_idx_2_sum;
recvbuf[3] += step_1_rank_2_idx_3_sum;
break;
case 3:
;
recvbuf[0] = sendbuf[0];
recvbuf[1] = sendbuf[1];
recvbuf[2] = sendbuf[2];
recvbuf[3] = sendbuf[3];
int step_0_rank_3_idx_0_sum;
int step_0_rank_3_idx_1_sum;
int step_0_rank_3_idx_2_sum;
int step_0_rank_3_idx_3_sum;
step_0_rank_3_idx_0_sum = 0;
step_0_rank_3_idx_1_sum = 0;
step_0_rank_3_idx_2_sum = 0;
step_0_rank_3_idx_3_sum = 0;
MPI_Request req_step_0_node_3_send_1_to_0;
MPI_Isend(&recvbuf[1], 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_0_node_3_send_1_to_0);
MPI_Request req_step_0_node_3_send_0_to_0;
MPI_Isend(&recvbuf[0], 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_0_node_3_send_0_to_0);
MPI_Request req_step_0_node_3_send_2_to_1;
MPI_Isend(&recvbuf[2], 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_0_node_3_send_2_to_1);
MPI_Request req_step_0_node_3_send_3_to_2;
MPI_Isend(&recvbuf[3], 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_0_node_3_send_3_to_2);
int step_0_node_3_recv_1_from_0;
MPI_Request req_step_0_node_3_recv_1_from_0;
MPI_Irecv(&step_0_node_3_recv_1_from_0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_0_node_3_recv_1_from_0);
int step_0_node_3_recv_0_from_0;
MPI_Request req_step_0_node_3_recv_0_from_0;
MPI_Irecv(&step_0_node_3_recv_0_from_0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_0_node_3_recv_0_from_0);
int step_0_node_3_recv_3_from_1;
MPI_Request req_step_0_node_3_recv_3_from_1;
MPI_Irecv(&step_0_node_3_recv_3_from_1, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_0_node_3_recv_3_from_1);
int step_0_node_3_recv_2_from_2;
MPI_Request req_step_0_node_3_recv_2_from_2;
MPI_Irecv(&step_0_node_3_recv_2_from_2, 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_0_node_3_recv_2_from_2);
MPI_Wait(&req_step_0_node_3_send_1_to_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_3_send_0_to_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_3_send_2_to_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_3_send_3_to_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_3_recv_1_from_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_3_recv_0_from_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_3_recv_3_from_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_0_node_3_recv_2_from_2, MPI_STATUS_IGNORE);
step_0_rank_3_idx_1_sum += step_0_node_3_recv_1_from_0;
step_0_rank_3_idx_0_sum += step_0_node_3_recv_0_from_0;
step_0_rank_3_idx_3_sum += step_0_node_3_recv_3_from_1;
step_0_rank_3_idx_2_sum += step_0_node_3_recv_2_from_2;
recvbuf[0] += step_0_rank_3_idx_0_sum;
recvbuf[1] += step_0_rank_3_idx_1_sum;
recvbuf[2] += step_0_rank_3_idx_2_sum;
recvbuf[3] += step_0_rank_3_idx_3_sum;
int step_1_rank_3_idx_0_sum;
int step_1_rank_3_idx_1_sum;
int step_1_rank_3_idx_2_sum;
int step_1_rank_3_idx_3_sum;
step_1_rank_3_idx_0_sum = 0;
step_1_rank_3_idx_1_sum = 0;
step_1_rank_3_idx_2_sum = 0;
step_1_rank_3_idx_3_sum = 0;
MPI_Request req_step_1_node_3_send_2_to_0;
MPI_Isend(&recvbuf[2], 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_1_node_3_send_2_to_0);
MPI_Request req_step_1_node_3_send_3_to_0;
MPI_Isend(&recvbuf[3], 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_1_node_3_send_3_to_0);
MPI_Request req_step_1_node_3_send_1_to_1;
MPI_Isend(&recvbuf[1], 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_1_node_3_send_1_to_1);
MPI_Request req_step_1_node_3_send_1_to_2;
MPI_Isend(&recvbuf[1], 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_1_node_3_send_1_to_2);
int step_1_node_3_recv_2_from_0;
MPI_Request req_step_1_node_3_recv_2_from_0;
MPI_Irecv(&step_1_node_3_recv_2_from_0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_1_node_3_recv_2_from_0);
int step_1_node_3_recv_3_from_0;
MPI_Request req_step_1_node_3_recv_3_from_0;
MPI_Irecv(&step_1_node_3_recv_3_from_0, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_step_1_node_3_recv_3_from_0);
int step_1_node_3_recv_1_from_1;
MPI_Request req_step_1_node_3_recv_1_from_1;
MPI_Irecv(&step_1_node_3_recv_1_from_1, 1, MPI_INT, 1, 0, MPI_COMM_WORLD, &req_step_1_node_3_recv_1_from_1);
int step_1_node_3_recv_0_from_2;
MPI_Request req_step_1_node_3_recv_0_from_2;
MPI_Irecv(&step_1_node_3_recv_0_from_2, 1, MPI_INT, 2, 0, MPI_COMM_WORLD, &req_step_1_node_3_recv_0_from_2);
MPI_Wait(&req_step_1_node_3_send_2_to_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_3_send_3_to_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_3_send_1_to_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_3_send_1_to_2, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_3_recv_2_from_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_3_recv_3_from_0, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_3_recv_1_from_1, MPI_STATUS_IGNORE);
MPI_Wait(&req_step_1_node_3_recv_0_from_2, MPI_STATUS_IGNORE);
step_1_rank_3_idx_2_sum += step_1_node_3_recv_2_from_0;
step_1_rank_3_idx_3_sum += step_1_node_3_recv_3_from_0;
step_1_rank_3_idx_1_sum += step_1_node_3_recv_1_from_1;
step_1_rank_3_idx_0_sum += step_1_node_3_recv_0_from_2;
recvbuf[0] += step_1_rank_3_idx_0_sum;
recvbuf[1] += step_1_rank_3_idx_1_sum;
recvbuf[2] += step_1_rank_3_idx_2_sum;
recvbuf[3] += step_1_rank_3_idx_3_sum;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment