#include "mpi.h" #include "fem.h" void MaxwellsRHS3d(Mesh *mesh, float frka, float frkb, float fdt){ /* registers and temporary */ register unsigned int k, n; /* mesh parameters */ const int K = mesh->K; float *vgeo = mesh->vgeo; float *surfinfo = mesh->surfinfo; float *f_Dr = mesh->f_Dr; float *f_Ds = mesh->f_Ds; float *f_Dt = mesh->f_Dt; float *f_LIFT = mesh->f_LIFT; float *f_Q = mesh->f_Q; float *f_rhsQ = mesh->f_rhsQ; float *f_resQ = mesh->f_resQ; float *f_inQ = mesh->f_inQ; float *f_outQ = mesh->f_outQ; int p; /* mpi request buffer */ MPI_Request *mpi_out_requests = (MPI_Request*) calloc(mesh->nprocs, sizeof(MPI_Request)); MPI_Request *mpi_in_requests = (MPI_Request*) calloc(mesh->nprocs, sizeof(MPI_Request)); /* buffer outgoing node data */ for(n=0;nparNtotalout;++n) mesh->f_outQ[n] = f_Q[mesh->parmapOUT[n]]; /* do sends */ int sk = 0, Nmess = 0; for(p=0;pnprocs;++p){ if(p!=mesh->procid){ int Nout = mesh->Npar[p]*p_Nfields*p_Nfp; if(Nout){ /* symmetric communications (different ordering) */ MPI_Isend(f_outQ+sk, Nout, MPI_FLOAT, p, 6666+p, MPI_COMM_WORLD, mpi_out_requests +Nmess); MPI_Irecv(f_inQ+sk, Nout, MPI_FLOAT, p, 6666+mesh->procid, MPI_COMM_WORLD, mpi_in_requests +Nmess); sk+=Nout; ++Nmess; } } } for(k=0;knprocs, sizeof(MPI_Status)); MPI_Waitall(Nmess, mpi_in_requests, instatus); free(instatus); for(k=0;knprocs, sizeof(MPI_Status)); MPI_Waitall(Nmess, mpi_out_requests, outstatus); free(outstatus); }