def enter_main(self, context, comm, args): sendbuf, sendcount, sendtype, \ recvbuf, recvcount, recvtype, root = args check.check_rank(context, comm, root, 7, False, False) self.check_root(context, comm, root) rank = context.state.get_rank(comm) if self.root == rank: self.recvbuf = recvbuf self.recvtype = check.check_datatype(context, recvtype, 7) check.check_count(context, recvcount, 5) self.recvcount = recvcount self.sendtype = sendtype self.sendcount = sendcount assert self.buffers[rank] is None if sendbuf == consts.MPI_IN_PLACE: if rank != root: context.add_error_and_throw(errormsg.InvalidInPlace(context)) else: self.make_buffer_for_root( context, rank, comm, sendbuf, sendtype, sendcount)
def call_send(context, args, blocking, mode, persistent=False, return_request=False): context.state = context.state if blocking: data_ptr, count, datatype, target, tag, comm = args else: data_ptr, count, datatype, target, tag, comm, request_ptr = args check.check_rank(context, comm, target, 4, False, True) send_type = get_send_type( context.gcontext.generator, context.state, mode, datatype, count) request = SendRequest(context.state.new_request_id(send_type), send_type, comm, target, tag, data_ptr, datatype, count) if persistent: assert not blocking context.state.add_persistent_request(request) else: context.state.activate_request(context, request, blocking) if return_request: return request if blocking: context.state.set_wait((request.id,), immediate=True) else: context.controller.write_int(request_ptr, request.id) return blocking
def call_recv(context, args, blocking, persistent=False, return_request=False): data_ptr, count, datatype, source, tag, comm, ptr = args check.check_rank(context, comm, source, 4, True, True) if blocking: status_ptr = ptr else: request_ptr = ptr if blocking and source == consts.MPI_PROC_NULL: if status_ptr: context.controller.write_status(status_ptr, consts.MPI_PROC_NULL, consts.MPI_ANY_TAG, 0) return False request = ReceiveRequest( context.state.new_request_id(Request.TYPE_RECEIVE), comm, source, tag, data_ptr, datatype, count) if persistent: assert not blocking context.state.add_persistent_request(request) else: context.state.activate_request(context, request, blocking) if return_request: return request if blocking: context.state.set_wait((request.id,), None, status_ptr, immediate=True) else: context.controller.write_int(request_ptr, request.id) return blocking
def enter_main(self, context, comm, args): buffer, count, datatype, root = args check.check_rank(context, comm, root, 8) self.check_root(context, comm, root) rank = context.state.get_rank(comm) if self.root == rank: self.count = count self.make_buffer_for_all(context, rank, comm, buffer, datatype, count) else: self.recvbufs[rank] = buffer self.datatypes[rank] = datatype self.counts[rank] = count
def MPI_Probe(context, args): source, tag, comm, status_ptr = args check.check_rank(context, comm, source, 1, True, True) if source != consts.MPI_PROC_NULL: context.state.set_probe(comm, source, tag, None, status_ptr) return True else: if status_ptr: context.controller.write_status(status_ptr, consts.MPI_PROC_NULL, consts.MPI_ANY_TAG, 0) return False
def enter_main(self, context, comm, args): sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root = args check.check_rank(context, comm, root, 8) rank = context.state.get_rank(comm) self.check_root(context, comm, root) self.make_buffer_for_root(context, rank, comm, sendbuf, sendtype, sendcount) if root == rank: recvtype = check.check_datatype(context, recvtype, 7) self.recvtype = recvtype self.recvbuf = recvbuf self.recvcounts = context.controller.read_ints(recvcounts, self.process_count) self.displs = context.controller.read_ints(displs, self.process_count)
def enter_main(self, context, comm, args): sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root = args check.check_rank(context, comm, root, 8) self.check_root(context, comm, root) rank = context.state.get_rank(comm) self.recvbufs[rank] = recvbuf self.recvtypes[rank] = recvtype self.recvcounts[rank] = recvcount if self.root == rank: sendtype = check.check_datatype(context, sendtype, 4) self.sendtype = sendtype self.sendcounts = context.controller.read_ints(sendcounts, self.process_count) self.displs = context.controller.read_ints(displs, self.process_count) sendcount = max(s + d for s, d in zip(self.sendcounts, self.displs)) self.make_buffer_for_all(context, rank, comm, sendbuf, sendtype, sendcount)
def enter_main(self, context, comm, args): sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root = args check.check_rank(context, comm, root, 8) self.check_root(context, comm, root) rank = context.state.get_rank(comm) self.recvbufs[rank] = recvbuf self.recvtypes[rank] = recvtype self.recvcounts[rank] = recvcount if self.root == rank: check.check_count(context, sendcount, 2) sendtype = check.check_datatype(context, sendtype, 3) self.sendtype = sendtype self.sendcount = sendcount self.make_buffer_for_all(context, rank, comm, sendbuf, sendtype, sendcount * self.process_count) elif recvbuf == consts.MPI_IN_PLACE: context.add_error_and_throw(errormsg.InvalidInPlace(context))
def MPI_Iprobe(context, args): source, tag, comm, flag_ptr, status_ptr = args check.check_rank(context, comm, source, 1, True, True) if source != consts.MPI_PROC_NULL: context.state.set_probe(comm, source, tag, flag_ptr, status_ptr) else: context.controller.write_int(flag_ptr, 1) if status_ptr: context.controller.write_status(status_ptr, consts.MPI_PROC_NULL, consts.MPI_ANY_TAG, 0) # We cannot simply return False, because we need to create context.state # (with hash), to detect possible cyclic computation context.state.set_ready() return True
def enter_main(self, context, comm, args): sendbuf, recvbuf, count, datatype, op, root = args check.check_rank(context, comm, root, 6) if self.op is None: self.op = op self.count = count self.datatype = datatype else: assert self.op.fn_ptr == op.fn_ptr and self.count == count and self.datatype == datatype self.check_root(context, comm, root) rank = context.state.get_rank(comm) self.recvbuf = recvbuf assert self.buffers[rank] is None self.make_buffer_for_root(context, rank, comm, sendbuf, datatype, count)