static void free_peers(pcu_aa_tree* t) { if (pcu_aa_empty(*t)) return; free_peers(&((*t)->left)); free_peers(&((*t)->right)); pcu_msg_peer* peer; peer = (pcu_msg_peer*) *t; pcu_free_message(&(peer->message)); noto_free(peer); pcu_make_aa(t); }
/* 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; }
static void free_comm(pcu_msg* m) { free_peers(&(m->peers)); pcu_free_message(&(m->received)); }