int DML_send_bytes(char *buf, size_t size, int tonode){ QMP_msgmem_t mm; QMP_msghandle_t mh; mm = QMP_declare_msgmem(buf, size); mh = QMP_declare_send_to(mm, tonode, 0); QMP_start(mh); QMP_wait(mh); QMP_free_msghandle(mh); QMP_free_msgmem(mm); return 0; }
/** * Declare a message handle for sending to a node displaced in (x,y,z,t) according to "displacement" */ MsgHandle *comm_declare_send_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_send_to(mh->mem, rank, 0); if (mh->handle == NULL) errorQuda("Unable to allocate QMP message handle"); return mh; }
void stupid_broadcast(void *send_buf, int count) { int node; int num_nodes = QMP_get_number_of_nodes(); QMP_msgmem_t request_msg = QMP_declare_msgmem(send_buf, count); QMP_msghandle_t request_mh; // Send to each node for(node=1; node < num_nodes; ++node) { if (QMP_get_node_number() == node) { request_mh = QMP_declare_receive_from(request_msg, 0, 0); if (QMP_start(request_mh) != QMP_SUCCESS) QMP_abort_string(1, "recvFromWait failed\n"); QMP_wait(request_mh); QMP_free_msghandle(request_mh); } if (QMP_is_primary_node()) { request_mh = QMP_declare_send_to(request_msg, node, 0); if (QMP_start(request_mh) != QMP_SUCCESS) QMP_abort_string(1, "sendToWait failed\n"); QMP_wait(request_mh); QMP_free_msghandle(request_mh); } } QMP_free_msgmem(request_msg); }