static bool receive_global(pcu_msg* m) { m->received.peer = MPI_ANY_SOURCE; while ( ! pcu_mpi_receive(&(m->received),pcu_user_comm)) { if (m->state == send_recv_state) if (done_sending_peers(m->peers)) { pcu_begin_barrier(&(m->coll)); m->state = recv_state; } if (m->state == recv_state) if (pcu_barrier_done(&(m->coll))) return false; } return true; }
/* tries to complete this communication step. Returns false if communication is not done, otherwise wraps up communication, merges if necessary, and returns true */ static bool end_coll_step(pcu_coll* c) { int action = c->pattern->action(c->bit); if (action == pcu_coll_idle) return true; if (action == pcu_coll_send) return pcu_mpi_done(&(c->message)); pcu_message incoming; pcu_make_message(&incoming); incoming.peer = c->pattern->peer(c->bit); if ( ! pcu_mpi_receive(&incoming,pcu_coll_comm)) return false; if (c->message.buffer.size != incoming.buffer.size) pcu_fail("collective not called by all ranks or pcu bug"); c->merge(c->message.buffer.start,incoming.buffer.start,incoming.buffer.size); pcu_free_message(&incoming); return true; }