CHECK_COUNT(6, target_count)\
CHECK_TYPE(7, target_datatype)
-#define CHECK_TARGET_DISP(num)\
- if(win->dynamic()==0)\
+#define CHECK_TARGET_DISP(num) \
+ if (not win->dynamic()) \
CHECK_NEGATIVE((num), MPI_ERR_RMA_RANGE, target_disp)
/* PMPI User level calls */
void* ptr = xbt_malloc(size);
const SmpiBenchGuard suspend_bench;
*static_cast<void**>(base) = ptr;
- *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,1);
+ *win = new simgrid::smpi::Win(ptr, size, disp_unit, info, comm, true);
return MPI_SUCCESS;
}
simgrid::smpi::colls::bcast(&ptr, sizeof(void*), MPI_BYTE, 0, comm);
simgrid::smpi::colls::barrier(comm);
*static_cast<void**>(base) = (char*)ptr+rank*size;
- *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,rank==0);
+ *win = new simgrid::smpi::Win(ptr, size, disp_unit, info, comm, rank == 0);
return MPI_SUCCESS;
}
std::list<int> lockers_;
int rank_; // to identify owner for barriers in MPI_COMM_WORLD
int mode_ = 0; // exclusive or shared lock
- int allocated_;
- int dynamic_;
+ bool allocated_;
+ bool dynamic_;
MPI_Errhandler errhandler_ = MPI_ERRORS_ARE_FATAL;
public:
static std::unordered_map<int, smpi_key_elem> keyvals_;
static int keyval_id_;
- Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated = 0, int dynamic = 0);
- Win(MPI_Info info, MPI_Comm comm) : Win(MPI_BOTTOM, 0, 1, info, comm, 0, 1) {};
+ Win(void* base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, bool allocated = false,
+ bool dynamic = false);
+ Win(MPI_Info info, MPI_Comm comm) : Win(MPI_BOTTOM, 0, 1, info, comm, false, true){};
Win(const Win&) = delete;
Win& operator=(const Win&) = delete;
~Win() override;
void set_name(const char* name);
int rank() const;
MPI_Comm comm() const;
- int dynamic() const;
+ bool dynamic() const;
int start(MPI_Group group, int assert);
int post(MPI_Group group, int assert);
int complete();
return MPI_ERR_RMA_RANGE;\
}
-#define CHECK_WIN_LOCKED(win)\
- if(opened_==0){ /*check that post/start has been done*/\
- int locked=0;\
- for (auto const& it : win->lockers_)\
- if (it == comm_->rank())\
- locked = 1;\
- if(locked != 1)\
- return MPI_ERR_WIN;\
+#define CHECK_WIN_LOCKED(win) \
+ if (opened_ == 0) { /*check that post/start has been done*/ \
+ bool locked = std::any_of(begin(win->lockers_), end(win->lockers_), [this](int it) { return it == this->rank_; }); \
+ if (not locked) \
+ return MPI_ERR_WIN; \
}
namespace simgrid{
std::unordered_map<int, smpi_key_elem> Win::keyvals_;
int Win::keyval_id_=0;
-Win::Win(void* base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated, int dynamic)
+Win::Win(void* base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, bool allocated, bool dynamic)
: base_(base)
, size_(size)
, disp_unit_(disp_unit)
if (rank_ == 0)
delete bar_;
- if(allocated_ !=0)
+ if (allocated_)
xbt_free(base_);
F2C::free_f(this->f2c_id());
return disp_unit_;
}
-int Win::dynamic() const
+bool Win::dynamic() const
{
return dynamic_;
}
//get receiver pointer
Win* recv_win = connected_wins_[target_rank];
- if(opened_==0){//check that post/start has been done
- // no fence or start .. lock ok ?
- int locked=0;
- for (auto const& it : recv_win->lockers_)
- if (it == comm_->rank())
- locked = 1;
- if(locked != 1)
- return MPI_ERR_WIN;
- }
-
+ CHECK_WIN_LOCKED(recv_win)
CHECK_RMA_REMOTE_WIN("MPI_Put", recv_win)
void* recv_addr = static_cast<char*>(recv_win->base_) + target_disp * recv_win->disp_unit_;