/** * Declare a message handle for receiving from a node displaced in (x,y,z,t) according to "displacement" */ MsgHandle *comm_declare_receive_displaced(void *buffer, const int displacement[], size_t nbytes) { Topology *topo = comm_default_topology(); int rank = comm_rank_displaced(topo, displacement); int tag = rank; MsgHandle *mh = (MsgHandle *)safe_malloc(sizeof(MsgHandle)); MPI_CHECK( MPI_Recv_init(buffer, nbytes, MPI_BYTE, rank, tag, MPI_COMM_WORLD, &(mh->request)) ); return mh; }
/** * Declare a message handle for receiving from a node displaced in (x,y,z,t) according to "displacement" */ MsgHandle *comm_declare_receive_displaced(void *buffer, const int displacement[], size_t nbytes) { Topology *topo = comm_default_topology(); int rank = comm_rank_displaced(topo, displacement); MsgHandle *mh = (MsgHandle *)safe_malloc(sizeof(MsgHandle)); mh->mem = QMP_declare_msgmem(buffer, nbytes); if (mh->mem == NULL) errorQuda("Unable to allocate QMP message memory"); mh->handle = QMP_declare_receive_from(mh->mem, rank, 0); if (mh->handle == NULL) errorQuda("Unable to allocate QMP message handle"); return mh; }
/** * Declare a message handle for strided sending to a node displaced in * (x,y,z,t) according to "displacement" */ MsgHandle *comm_declare_strided_send_displaced(void *buffer, const int displacement[], size_t blksize, int nblocks, size_t stride) { Topology *topo = comm_default_topology(); int rank = comm_rank_displaced(topo, displacement); MsgHandle *mh = (MsgHandle *)safe_malloc(sizeof(MsgHandle)); mh->mem = QMP_declare_strided_msgmem(buffer, blksize, nblocks, stride); if (mh->mem == NULL) errorQuda("Unable to allocate QMP message memory"); mh->handle = QMP_declare_send_to(mh->mem, rank, 0); if (mh->handle == NULL) errorQuda("Unable to allocate QMP message handle"); return mh; }
/** * Declare a message handle for receiving from a node displaced in (x,y,z,t) according to "displacement" */ MsgHandle *comm_declare_strided_receive_displaced(void *buffer, const int displacement[], size_t blksize, int nblocks, size_t stride) { Topology *topo = comm_default_topology(); int rank = comm_rank_displaced(topo, displacement); int tag = rank; MsgHandle *mh = (MsgHandle *)safe_malloc(sizeof(MsgHandle)); // create a new strided MPI type MPI_CHECK( MPI_Type_vector(nblocks, blksize, stride, MPI_BYTE, &(mh->datatype)) ); MPI_CHECK( MPI_Type_commit(&(mh->datatype)) ); MPI_CHECK( MPI_Recv_init(buffer, 1, mh->datatype, rank, tag, MPI_COMM_WORLD, &(mh->request)) ); return mh; }
void comm_finalize(void) { Topology *topo = comm_default_topology(); comm_destroy_topology(topo); comm_set_default_topology(NULL); }
int comm_coord(int dim) { Topology *topo = comm_default_topology(); return comm_coords(topo)[dim]; }