-/* Copyright (c) 2007-2017. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include "private.h"
-#include <vector>
+#include "src/smpi/private.h"
+#include "src/smpi/smpi_coll.hpp"
+#include "src/smpi/smpi_comm.hpp"
+#include "src/smpi/smpi_datatype.hpp"
+#include "src/smpi/smpi_info.hpp"
+#include "src/smpi/smpi_keyvals.hpp"
+#include "src/smpi/smpi_process.hpp"
+#include "src/smpi/smpi_request.hpp"
+#include "src/smpi/smpi_win.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_rma, smpi, "Logging specific to SMPI (RMA operations)");
}
int Win::attach (void *base, MPI_Aint size){
- if (!(base_ == MPI_BOTTOM || base_ == 0))
+ if (not(base_ == MPI_BOTTOM || base_ == 0))
return MPI_ERR_ARG;
base_=0;//actually the address will be given in the RMA calls, as being the disp.
size_+=size;
comm_->group()->index(target_rank), smpi_process()->index(), SMPI_RMA_TAG+2, comm_,
MPI_OP_NULL);
- //start the send, with another process than us as sender.
+ //start the send, with another process than us as sender.
sreq->start();
//push request to receiver's win
xbt_mutex_acquire(send_win->mut_);
if(locked != 1)
return MPI_ERR_WIN;
}
- //FIXME: local version
+ //FIXME: local version
if(target_count*target_datatype->get_extent()>recv_win->size_)
return MPI_ERR_ARG;
return MPI_SUCCESS;
}
-int Win::get_accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
- int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
+int Win::get_accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
+ int result_count, MPI_Datatype result_datatype, int target_rank, MPI_Aint target_disp, int target_count,
MPI_Datatype target_datatype, MPI_Op op, MPI_Request* request){
//get sender pointer
target_disp, 1, datatype, &req);
if (req != MPI_REQUEST_NULL)
Request::wait(&req, MPI_STATUS_IGNORE);
- if(! memcmp (result_addr, compare_addr, datatype->get_extent() )){
+ if (not memcmp(result_addr, compare_addr, datatype->get_extent())) {
put(origin_addr, 1, datatype, target_rank,
target_disp, 1, datatype);
}
if(lock_type == MPI_LOCK_SHARED){//the window used to be exclusive, it's now shared.
xbt_mutex_release(target_win->lock_mut_);
}
- } else if(!(target_win->mode_==MPI_LOCK_SHARED && lock_type == MPI_LOCK_EXCLUSIVE))
- target_win->mode_+= lock_type; // don't set to exclusive if it's already shared
+ } else if (not(target_win->mode_ == MPI_LOCK_SHARED && lock_type == MPI_LOCK_EXCLUSIVE))
+ target_win->mode_ += lock_type; // don't set to exclusive if it's already shared
target_win->lockers_.push_back(comm_->rank());
- int finished = finish_comms();
+ int finished = finish_comms(rank);
XBT_DEBUG("Win_lock %d - Finished %d RMA calls", rank, finished);
-
+ finished = target_win->finish_comms(rank_);
+ XBT_DEBUG("Win_lock target %d - Finished %d RMA calls", rank, finished);
return MPI_SUCCESS;
}
xbt_mutex_release(target_win->lock_mut_);
}
- int finished = finish_comms();
+ int finished = finish_comms(rank);
XBT_DEBUG("Win_unlock %d - Finished %d RMA calls", rank, finished);
-
+ finished = target_win->finish_comms(rank_);
+ XBT_DEBUG("Win_unlock target %d - Finished %d RMA calls", rank, finished);
return MPI_SUCCESS;
}
int size = static_cast<int>(reqqs->size());
if (size > 0) {
size = 0;
- std::vector<MPI_Request>* myreqqs = new std::vector<MPI_Request>();
+ std::vector<MPI_Request> myreqqs;
std::vector<MPI_Request>::iterator iter = reqqs->begin();
while (iter != reqqs->end()){
- if(((*iter)->src() == rank) || ((*iter)->dst() == rank)){
- myreqqs->push_back(*iter);
- iter = reqqs->erase(iter);
- size++;
+ if(((*iter)!=MPI_REQUEST_NULL) && (((*iter)->src() == rank) || ((*iter)->dst() == rank))){
+ myreqqs.push_back(*iter);
+ iter = reqqs->erase(iter);
+ size++;
} else {
++iter;
}
}
if(size >0){
- MPI_Request* treqs = &(*myreqqs)[0];
+ MPI_Request* treqs = &myreqqs[0];
Request::waitall(size, treqs, MPI_STATUSES_IGNORE);
- myreqqs->clear();
- delete myreqqs;
+ myreqqs.clear();
}
}
xbt_mutex_release(mut_);