int rank = comm->rank();
int system_tag=COLL_TAG_BARRIER-external;
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
if (rank > 0) {
auto* requests = new MPI_Request[2];
requests[0] = Request::isend (nullptr, 0, MPI_BYTE, 0,
int rank = comm->rank();
int system_tag=COLL_TAG_BCAST-external;
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
if (rank != root) {
auto* requests = new MPI_Request[1];
requests[0] = Request::irecv (buf, count, datatype, root,
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
// FIXME: check for errors
recvtype->extent(&lb, &recvext);
// Local copy from self
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
if(rank != root) {
auto* requests = new MPI_Request[1];
// Recv buffer from root
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
recvtype->extent(&lb, &recvext);
// Local copy from self
Datatype::copy(sendbuf, sendcount, sendtype,
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
sendtype->extent(&lb, &sendext);
recvtype->extent(&lb, &recvext);
/* simple optimization */
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
sendtype->extent(&lb, &sendext);
recvtype->extent(&lb, &recvext);
/* Local copy from self */
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
/* Local copy from self */
int err = (sendcounts[rank]>0 && recvcounts[rank]) ? Datatype::copy(static_cast<const char *>(sendbuf) + senddisps[rank], sendcounts[rank], sendtypes[rank],
static_cast<char *>(recvbuf) + recvdisps[rank], recvcounts[rank], recvtypes[rank]): MPI_SUCCESS;
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
if(rank != root) {
// Send buffer to root
auto* requests = new MPI_Request[1];
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
if (rank != root) {
// Send buffer to root
auto* requests = new MPI_Request[1];
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( nullptr, 0, MPI_BYTE,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
if(rank != root) {
// Recv buffer from root
auto* requests = new MPI_Request[1];
if(rank == root){
(*request) = new Request( recvbuf, count, datatype,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT, op);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC, op);
}
else
(*request) = new Request( nullptr, count, datatype,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC);
if(rank != root) {
// Send buffer to root
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( recvbuf, count, datatype,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT, op);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC, op);
// FIXME: check for errors
datatype->extent(&lb, &dataext);
// Local copy from self
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( recvbuf, count, datatype,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT, op);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC, op);
datatype->extent(&lb, &dataext);
// Local copy from self
int rank = comm->rank();
int size = comm->size();
(*request) = new Request( recvbuf, count, datatype,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT, op);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC, op);
datatype->extent(&lb, &dataext);
if(rank != 0)
memset(recvbuf, 0, count*dataext);
int size = comm->size();
int count=recvcounts[rank];
(*request) = new Request( recvbuf, count, datatype,
- rank,rank, system_tag, comm, MPI_REQ_PERSISTENT, op);
+ rank,rank, system_tag, comm, MPI_REQ_PERSISTENT|MPI_REQ_NBC, op);
datatype->extent(&lb, &dataext);
// Send/Recv buffers to/from others;
static int nsleeps = 1;
int ret = MPI_SUCCESS;
-
- // Are we testing a request meant for non blocking collectives ?
- // If so, test all the subrequests.
- if ((*request)->nbc_requests_size_>0){
- ret = testall((*request)->nbc_requests_size_, (*request)->nbc_requests_, flag, MPI_STATUSES_IGNORE);
- if(*flag){
- delete[] (*request)->nbc_requests_;
- (*request)->nbc_requests_size_=0;
- unref(request);
- }
- return ret;
- }
-
+
if(smpi_test_sleep > 0)
simgrid::s4u::this_actor::sleep_for(nsleeps * smpi_test_sleep);
xbt_assert(request == MPI_REQUEST_NULL);
}
+int Request::finish_nbc_requests(MPI_Request* request){
+ int ret = waitall((*request)->nbc_requests_size_, (*request)->nbc_requests_, MPI_STATUSES_IGNORE);
+ XBT_DEBUG("finish non blocking collective request with %d sub-requests", (*request)->nbc_requests_size_);
+ for (int i = 0; i < (*request)->nbc_requests_size_; i++) {
+ if((*request)->buf_!=nullptr && (*request)->nbc_requests_[i]!=MPI_REQUEST_NULL){//reduce case
+ void * buf=(*request)->nbc_requests_[i]->buf_;
+ if((*request)->old_type_->flags() & DT_FLAG_DERIVED)
+ buf=(*request)->nbc_requests_[i]->old_buf_;
+ if((*request)->nbc_requests_[i]->flags_ & MPI_REQ_RECV ){
+ if((*request)->op_!=MPI_OP_NULL){
+ int count=(*request)->size_/ (*request)->old_type_->size();
+ (*request)->op_->apply(buf, (*request)->buf_, &count, (*request)->old_type_);
+ }
+ smpi_free_tmp_buffer(static_cast<unsigned char*>(buf));
+ }
+ }
+ if((*request)->nbc_requests_[i]!=MPI_REQUEST_NULL)
+ Request::unref(&((*request)->nbc_requests_[i]));
+ }
+ delete[] (*request)->nbc_requests_;
+ (*request)->nbc_requests_size_=0;
+ return ret;
+}
+
void Request::finish_wait(MPI_Request* request, MPI_Status * status)
{
MPI_Request req = *request;
return;
}
+ if ((*request)->flags() & MPI_REQ_NBC){
+ int ret = finish_nbc_requests(request);
+ if (ret != MPI_SUCCESS)
+ xbt_die("error when finishing non blocking collective requests");
+ }
+
if ((req->flags_ & (MPI_REQ_PREPARED | MPI_REQ_GENERALIZED | MPI_REQ_FINISHED)) == 0) {
if (status != MPI_STATUS_IGNORE) {
if (req->src_== MPI_PROC_NULL || req->dst_== MPI_PROC_NULL){
(*request)=MPI_REQUEST_NULL;
return ret;
}
- // Are we waiting on a request meant for non blocking collectives ?
- // If so, wait for all the subrequests.
- if ((*request)->nbc_requests_size_>0){
- ret = waitall((*request)->nbc_requests_size_, (*request)->nbc_requests_, MPI_STATUSES_IGNORE);
- for (int i = 0; i < (*request)->nbc_requests_size_; i++) {
- if((*request)->buf_!=nullptr && (*request)->nbc_requests_[i]!=MPI_REQUEST_NULL){//reduce case
- void * buf=(*request)->nbc_requests_[i]->buf_;
- if((*request)->old_type_->flags() & DT_FLAG_DERIVED)
- buf=(*request)->nbc_requests_[i]->old_buf_;
- if((*request)->nbc_requests_[i]->flags_ & MPI_REQ_RECV ){
- if((*request)->op_!=MPI_OP_NULL){
- int count=(*request)->size_/ (*request)->old_type_->size();
- (*request)->op_->apply(buf, (*request)->buf_, &count, (*request)->old_type_);
- }
- smpi_free_tmp_buffer(static_cast<unsigned char*>(buf));
- }
- }
- if((*request)->nbc_requests_[i]!=MPI_REQUEST_NULL)
- Request::unref(&((*request)->nbc_requests_[i]));
- }
- delete[] (*request)->nbc_requests_;
- (*request)->nbc_requests_size_=0;
- unref(request);
- (*request)=MPI_REQUEST_NULL;
- return ret;
- }
(*request)->print_request("Waiting");
if ((*request)->flags_ & (MPI_REQ_PREPARED | MPI_REQ_FINISHED)) {