/* * ======== Comm_get ======== */ Int Comm_get(Comm_Handle comm, Comm_Msg *msg, UInt timeout) { Comm_Msg tmp; Int len; Assert_isTrue(curInit > 0, (Assert_Id)NULL); Log_print3(Diags_ENTRY, "[+E] Comm_get> " "Enter(comm=0x%x, msg=0x%x, timeout=%d)", (IArg)comm, (IArg)msg, (IArg)timeout); *msg = NULL; if (Comm_alloc(0, &tmp, MSGSIZE) == Comm_EOK) { do { len = msgrcv(comm->id, tmp, MSGSIZE - sizeof(long), MSGTYPE, 0); if (len >= 0) { tmp->size = MSGSIZE; *msg = tmp; return (Comm_EOK); } } while (errno == EINTR); perror("Comm_get"); Comm_free(tmp); } return (Comm_EFAIL); }
void SAMRAI_MPI::freeCommunicator() { #ifdef HAVE_MPI if (d_comm != MPI_COMM_NULL) { TBOX_ASSERT(SAMRAI_MPI::usingMPI()); Comm_free(&d_comm); // d_comm is now set to MPI_COMM_NULL; } #else d_comm = MPI_COMM_NULL; #endif d_rank = 0; d_size = 1; }
/* * ======== Comm_put ======== */ Int Comm_put(Comm_Id msgqId, Comm_Msg msg) { Assert_isTrue(curInit > 0, (Assert_Id)NULL); Log_print2(Diags_ENTRY, "[+E] Comm_put> Enter(msgqId=0x%x, msg=0x%x)", (IArg)msgqId, (IArg)msg); if (msgsnd(msgqId, msg, msg->size - sizeof(long), IPC_NOWAIT) < 0) { perror("Comm_put"); return (Comm_EFAIL); } Comm_free(msg); return (Comm_EOK); }