Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
constify MPI_Win*
[simgrid.git] / src / smpi / include / smpi_win.hpp
index 8106b22..d067226 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2013-2017. The SimGrid Team.
+/* Copyright (c) 2010-2019. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,10 +7,10 @@
 #ifndef SMPI_WIN_HPP_INCLUDED
 #define SMPI_WIN_HPP_INCLUDED
 
+#include "simgrid/s4u/Barrier.hpp"
 #include "smpi_f2c.hpp"
 #include "smpi_keyvals.hpp"
 #include "xbt/synchro.h"
-#include <simgrid/msg.h>
 
 #include <vector>
 #include <list>
@@ -19,7 +19,6 @@ namespace simgrid{
 namespace smpi{
 
 class Win : public F2C, public Keyval {
-  private :
   void* base_;
   MPI_Aint size_;
   int disp_unit_;
@@ -27,15 +26,15 @@ class Win : public F2C, public Keyval {
   MPI_Info info_;
   MPI_Comm comm_;
   std::vector<MPI_Request> *requests_;
-  xbt_mutex_t mut_;
-  msg_bar_t bar_;
+  s4u::MutexPtr mut_;
+  s4u::Barrier* bar_;
   MPI_Win* connected_wins_;
   char* name_;
   int opened_;
   MPI_Group group_;
   int count_; //for ordering the accs
-  xbt_mutex_t lock_mut_;
-  xbt_mutex_t atomic_mut_;
+  s4u::MutexPtr lock_mut_;
+  s4u::MutexPtr atomic_mut_;
   std::list<int> lockers_;
   int rank_; // to identify owner for barriers in MPI_COMM_WORLD
   int mode_; // exclusive or shared lock
@@ -48,12 +47,14 @@ public:
 
   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(const Win&) = delete;
+  Win& operator=(const Win&) = delete;
   ~Win();
   int attach (void *base, MPI_Aint size);
-  int detach (void *base);
+  int detach (const void *base);
   void get_name( char* name, int* length);
   void get_group( MPI_Group* group);
-  void set_name( char* name);
+  void set_name(const char* name);
   int rank();
   int dynamic();
   int start(MPI_Group group, int assert);
@@ -66,16 +67,16 @@ public:
   void* base();
   int disp_unit();
   int fence(int assert);
-  int put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
+  int put(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request=nullptr);
   int get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request=nullptr);
-  int accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
+  int accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
               MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Request* request=nullptr);
-  int get_accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, void *result_addr,
+  int get_accumulate(const 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=nullptr);
-  int compare_and_swap(void *origin_addr, void *compare_addr,
+  int compare_and_swap(const void *origin_addr, void *compare_addr,
         void *result_addr, MPI_Datatype datatype, int target_rank,
         MPI_Aint target_disp);
   static Win* f2c(int id);
@@ -90,6 +91,7 @@ public:
   int flush_local_all();
   int finish_comms();
   int finish_comms(int rank);
+  int shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr);
 };