#include "convolution.h" #include "util.h" #include #include static float *input, *output, *filter; static int N, C, H, W; static int K, R, S; static int OH, OW; static int pad; static int dilation; static int stride; static int mpi_rank, mpi_world_size; int num_threads = 100; void convolution( float *_input, float *_output, float *_filter, int _N, int _C, int _H, int _W, int _K, int _R, int _S, int _pad, int _dilation, int _stride) { int N_start[mpi_world_size]; int N_end[mpi_world_size]; MPI_Request request; MPI_Status status; for(int i=0; i= H || w < 0 || w >= W) continue; float i = input[n * C * H * W + c * H * W + h * W + w]; float f = filter[k * C * R * S + c * R * S + r * S + s]; o += i * f; } } } output[n * K * OH * OW + k * OH * OW + oh * OW + ow] = o; } } } } if(mpi_rank == 0 && mpi_world_size == 2){ MPI_Recv(&output[N_start[1]*K*OH*OW],(N_end[1]-N_start[1])*K*OH*OW, MPI_FLOAT,1,0,MPI_COMM_WORLD, &status); } else if(mpi_world_size == 2){ //MPI_Isend(&output[N_start[1]*K*OH*OW],(N_end[1]-N_start[1])*K*OH*OW, MPI_FLOAT,0,0,MPI_COMM_WORLD, &request); MPI_Isend(output,(N_end[1]-N_start[1])*K*OH*OW, MPI_FLOAT,0,0,MPI_COMM_WORLD, &request); } } void convolution_init( int _N, int _C, int _H, int _W, int _K, int _R, int _S, int _pad, int _dilation, int _stride) { N = _N; C = _C; H = _H; W = _W; K = _K; R = _R; S = _S; pad = _pad; dilation = _dilation; stride = _stride; MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); MPI_Comm_size(MPI_COMM_WORLD, &mpi_world_size); } void convolution_final( int _N, int _C, int _H, int _W, int _K, int _R, int _S, int _pad, int _dilation, int _stride) { }