Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Declare functions "const" in src/smpi/.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jul 2020 12:14:31 +0000 (14:14 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jul 2020 13:48:49 +0000 (15:48 +0200)
23 files changed:
src/smpi/include/smpi_actor.hpp
src/smpi/include/smpi_comm.hpp
src/smpi/include/smpi_datatype.hpp
src/smpi/include/smpi_errhandler.hpp
src/smpi/include/smpi_file.hpp
src/smpi/include/smpi_group.hpp
src/smpi/include/smpi_info.hpp
src/smpi/include/smpi_op.hpp
src/smpi/include/smpi_request.hpp
src/smpi/include/smpi_topo.hpp
src/smpi/include/smpi_win.hpp
src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_replay.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_errhandler.cpp
src/smpi/mpi/smpi_file.cpp
src/smpi/mpi/smpi_info.cpp
src/smpi/mpi/smpi_op.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/mpi/smpi_topo.cpp
src/smpi/mpi/smpi_win.cpp
src/smpi/plugins/load_balancer/load_balancer.hpp

index 61ae4bc..f4712d6 100644 (file)
@@ -53,36 +53,36 @@ public:
   ActorExt& operator=(const ActorExt&) = delete;
   ~ActorExt();
   void finalize();
-  int finalized();
-  int initializing();
-  int initialized();
+  int finalized() const;
+  int initializing() const;
+  int initialized() const;
   void mark_as_initialized();
   void set_replaying(bool value);
-  bool replaying();
+  bool replaying() const;
   void set_tracing_category(const std::string& category) { tracing_category_ = category; }
-  const std::string& get_tracing_category() { return tracing_category_; }
+  const std::string& get_tracing_category() const { return tracing_category_; }
   smpi_trace_call_location_t* call_location();
   void set_privatized_region(smpi_privatization_region_t region);
-  smpi_privatization_region_t privatized_region();
-  s4u::Mailbox* mailbox() { return mailbox_; }
-  s4u::Mailbox* mailbox_small() { return mailbox_small_; }
-  s4u::MutexPtr mailboxes_mutex();
+  smpi_privatization_region_t privatized_region() const;
+  s4u::Mailbox* mailbox() const { return mailbox_; }
+  s4u::Mailbox* mailbox_small() const { return mailbox_small_; }
+  s4u::MutexPtr mailboxes_mutex() const;
 #if HAVE_PAPI
-  int papi_event_set();
+  int papi_event_set() const;
   papi_counter_t& papi_counters();
 #endif
   xbt_os_timer_t timer();
   void simulated_start();
-  double simulated_elapsed();
-  MPI_Comm comm_world();
+  double simulated_elapsed() const;
+  MPI_Comm comm_world() const;
   MPI_Comm comm_self();
   MPI_Comm comm_intra();
   void set_comm_intra(MPI_Comm comm);
   void set_sampling(int s);
-  int sampling();
+  int sampling() const;
   static void init();
   s4u::ActorPtr get_actor();
-  int get_optind();
+  int get_optind() const;
   void set_optind(int optind);
   MPI_Info info_env();
   void bsend_buffer(void** buf, int* size);
index 61a4940..70fa4ec 100644 (file)
@@ -47,12 +47,12 @@ public:
   int dup(MPI_Comm* newcomm);
   int dup_with_info(MPI_Info info, MPI_Comm* newcomm);
   MPI_Group group();
-  MPI_Topology topo() { return topo_; }
+  MPI_Topology topo() const { return topo_; }
   void set_topo(MPI_Topology topo){topo_=topo;}
-  int size();
-  int rank();
-  int id();
-  void get_name(char* name, int* len);
+  int size() const;
+  int rank() const;
+  int id() const;
+  void get_name(char* name, int* len) const;
   void set_name(const char* name);
   MPI_Info info();
   void set_info( MPI_Info info);
@@ -60,14 +60,14 @@ public:
   void set_errhandler( MPI_Errhandler errhandler);
   void set_leaders_comm(MPI_Comm leaders);
   void set_intra_comm(MPI_Comm leaders) { intra_comm_ = leaders; };
-  int* get_non_uniform_map();
-  int* get_leaders_map();
-  MPI_Comm get_leaders_comm();
-  MPI_Comm get_intra_comm();
+  int* get_non_uniform_map() const;
+  int* get_leaders_map() const;
+  MPI_Comm get_leaders_comm() const;
+  MPI_Comm get_intra_comm() const;
   MPI_Comm find_intra_comm(int* leader);
-  bool is_uniform();
-  bool is_blocked();
-  bool is_smp_comm();
+  bool is_uniform() const;
+  bool is_blocked() const;
+  bool is_smp_comm() const;
   MPI_Comm split(int color, int key);
   void cleanup_smp();
   void ref();
index 470e760..bf01abb 100644 (file)
@@ -115,26 +115,26 @@ public:
   Datatype& operator=(const Datatype&) = delete;
   virtual ~Datatype();
 
-  char* name() { return name_; }
-  size_t size() { return size_; }
-  MPI_Aint lb() { return lb_; }
-  MPI_Aint ub() { return ub_; }
-  int flags() { return flags_; }
-  int refcount() { return refcount_; }
+  char* name() const { return name_; }
+  size_t size() const { return size_; }
+  MPI_Aint lb() const { return lb_; }
+  MPI_Aint ub() const { return ub_; }
+  int flags() const { return flags_; }
+  int refcount() const { return refcount_; }
 
   void ref();
   static void unref(MPI_Datatype datatype);
   void commit();
   int copy_attrs(Datatype* datatype);
-  bool is_valid();
-  bool is_basic();
+  bool is_valid() const;
+  bool is_basic() const;
   static const char* encode(const Datatype* dt) { return dt->id.c_str(); }
   static MPI_Datatype decode(const std::string& datatype_id);
-  bool is_replayable();
+  bool is_replayable() const;
   void addflag(int flag);
-  int extent(MPI_Aint* lb, MPI_Aint* extent);
-  MPI_Aint get_extent() { return ub_ - lb_; };
-  void get_name(char* name, int* length);
+  int extent(MPI_Aint* lb, MPI_Aint* extent) const;
+  MPI_Aint get_extent() const { return ub_ - lb_; };
+  void get_name(char* name, int* length) const;
   void set_name(const char* name);
   static int copy(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
                   MPI_Datatype recvtype);
@@ -146,11 +146,9 @@ public:
   static int keyval_free(int* keyval);
   int pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, const Comm* comm);
   int unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, const Comm* comm);
-  int get_contents(int max_integers, int max_addresses, 
-                   int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses, 
-                   MPI_Datatype *array_of_datatypes);
-  int get_envelope(int* num_integers, int* num_addresses, 
-                   int* num_datatypes, int* combiner);
+  int get_contents(int max_integers, int max_addresses, int max_datatypes, int* array_of_integers,
+                   MPI_Aint* array_of_addresses, MPI_Datatype* array_of_datatypes) const;
+  int get_envelope(int* num_integers, int* num_addresses, int* num_datatypes, int* combiner) const;
   static int create_contiguous(int count, MPI_Datatype old_type, MPI_Aint lb, MPI_Datatype* new_type);
   static int create_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type);
   static int create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type);
index 3030901..cc47cde 100644 (file)
@@ -25,9 +25,9 @@ class Errhandler: public F2C {
   explicit Errhandler(MPI_File_errhandler_fn *function):file_func_(function){};
   explicit Errhandler(MPI_Win_errhandler_fn *function):win_func_(function){};
   void ref();
-  void call(MPI_Comm comm, int errorcode);
-  void call(MPI_Win win, int errorcode);
-  void call(MPI_File file, int errorcode);
+  void call(MPI_Comm comm, int errorcode) const;
+  void call(MPI_Win win, int errorcode) const;
+  void call(MPI_File file, int errorcode) const;
   static void unref(Errhandler* errhandler);
   static Errhandler* f2c(int id);
 };
index ddd0cff..ad1a720 100644 (file)
@@ -37,16 +37,16 @@ class File : public F2C{
   File(const File&) = delete;
   File& operator=(const File&) = delete;
   ~File();
-  int size();
-  int get_position(MPI_Offset* offset);
-  int get_position_shared(MPI_Offset* offset);
-  int flags();
-  MPI_Comm comm();
+  int size() const;
+  int get_position(MPI_Offset* offset) const;
+  int get_position_shared(MPI_Offset* offset) const;
+  int flags() const;
+  MPI_Comm comm() const;
   int sync();
   int seek(MPI_Offset offset, int whence);
   int seek_shared(MPI_Offset offset, int whence);
   int set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, const Info* info);
-  int get_view(MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep);
+  int get_view(MPI_Offset* disp, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep) const;
   MPI_Info info();
   void set_info( MPI_Info info);
   static int read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
index 889dfa6..82c51c4 100644 (file)
@@ -37,7 +37,7 @@ public:
   int rank(s4u::Actor* process);
   void ref();
   static void unref(MPI_Group group);
-  int size() { return size_; }
+  int size() const { return size_; }
   int compare(MPI_Group group2);
   int incl(int n, const int* ranks, MPI_Group* newgroup);
   int excl(int n, const int* ranks, MPI_Group* newgroup);
index 280afa5..99664b5 100644 (file)
@@ -26,11 +26,11 @@ public:
   void ref();
   static void unref(MPI_Info info);
   void set(const char* key, const char* value) { map_[key] = value; }
-  int get(const char* key, int valuelen, char* value, int* flag);
+  int get(const char* key, int valuelen, char* value, int* flag) const;
   int remove(const char* key);
-  int get_nkeys(int* nkeys);
-  int get_nthkey(int n, char* key);
-  int get_valuelen(const char* key, int* valuelen, int* flag);
+  int get_nkeys(int* nkeys) const;
+  int get_nthkey(int n, char* key) const;
+  int get_valuelen(const char* key, int* valuelen, int* flag) const;
   static Info* f2c(int id);
 };
 
index 403b230..1b45884 100644 (file)
@@ -21,11 +21,11 @@ class Op : public F2C{
 
 public:
   Op(MPI_User_function* function, bool commutative, bool predefined=false) : func_(function), is_commutative_(commutative), predefined_(predefined) {}
-  bool is_commutative() { return is_commutative_; }
-  bool is_fortran_op() { return is_fortran_op_; }
+  bool is_commutative() const { return is_commutative_; }
+  bool is_fortran_op() const { return is_fortran_op_; }
   // tell that we were created from fortran, so we need to translate the type to fortran when called
   void set_fortran_op() { is_fortran_op_ = true; }
-  void apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype);
+  void apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype) const;
   static Op* f2c(int id);
   void ref();
   static void unref(MPI_Op* op);
index 925702e..091219e 100644 (file)
@@ -56,23 +56,23 @@ class Request : public F2C {
 public:
   Request() = default;
   Request(const void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags, MPI_Op op = MPI_REPLACE);
-  MPI_Comm comm() { return comm_; }
-  size_t size() { return size_; }
-  size_t real_size() { return real_size_; }
-  int src() { return src_; }
-  int dst() { return dst_; }
-  int tag() { return tag_; }
-  int flags() { return flags_; }
-  bool detached() { return detached_; }
-  MPI_Datatype type() { return old_type_; }
-  void print_request(const char* message);
+  MPI_Comm comm() const { return comm_; }
+  size_t size() const { return size_; }
+  size_t real_size() const { return real_size_; }
+  int src() const { return src_; }
+  int dst() const { return dst_; }
+  int tag() const { return tag_; }
+  int flags() const { return flags_; }
+  bool detached() const { return detached_; }
+  MPI_Datatype type() const { return old_type_; }
+  void print_request(const char* message) const;
   void start();
   void cancel();
   void init_buffer(int count);
   void ref();
   void set_nbc_requests(MPI_Request* reqs, int size);
-  int get_nbc_requests_size();
-  MPI_Request* get_nbc_requests();
+  int get_nbc_requests_size() const;
+  MPI_Request* get_nbc_requests() const;
   static void finish_wait(MPI_Request* request, MPI_Status* status);
   static void unref(MPI_Request* request);
   static int wait(MPI_Request* req, MPI_Status* status);
index 58c7576..e7354c6 100644 (file)
@@ -39,7 +39,7 @@ public:
   int get(int maxdims, int* dims, int* periods, int* coords);
   int rank(const int* coords, int* rank);
   int shift(int direction, int disp, int* rank_source, int* rank_dest);
-  int dim_get(int* ndims);
+  int dim_get(int* ndims) const;
   static int Dims_create(int nnodes, int ndims, int dims[]);
 };
 
index 84a3f82..595bfe8 100644 (file)
@@ -53,20 +53,20 @@ public:
   ~Win();
   int attach (void *base, MPI_Aint size);
   int detach (const void *base);
-  void get_name( char* name, int* length);
+  void get_name(char* name, int* length) const;
   void get_group( MPI_Group* group);
   void set_name(const char* name);
-  int rank();
-  int dynamic();
+  int rank() const;
+  int dynamic() const;
   int start(MPI_Group group, int assert);
   int post(MPI_Group group, int assert);
   int complete();
   MPI_Info info();
   void set_info( MPI_Info info);
   int wait();
-  MPI_Aint size();
-  void* base();
-  int disp_unit();
+  MPI_Aint size() const;
+  void* base() const;
+  int disp_unit() const;
   int fence(int assert);
   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);
index c29d787..c6f7164 100644 (file)
@@ -74,19 +74,19 @@ void ActorExt::finalize()
 }
 
 /** @brief Check if a process is finalized */
-int ActorExt::finalized()
+int ActorExt::finalized() const
 {
   return (state_ == SmpiProcessState::FINALIZED);
 }
 
 /** @brief Check if a process is partially initialized already */
-int ActorExt::initializing()
+int ActorExt::initializing() const
 {
   return (state_ == SmpiProcessState::INITIALIZING);
 }
 
 /** @brief Check if a process is initialized */
-int ActorExt::initialized()
+int ActorExt::initialized() const
 {
   // TODO cheinrich: Check if we still need this. This should be a global condition, not for a
   // single process ... ?
@@ -106,7 +106,7 @@ void ActorExt::set_replaying(bool value)
     replaying_ = value;
 }
 
-bool ActorExt::replaying()
+bool ActorExt::replaying() const
 {
   return replaying_;
 }
@@ -131,23 +131,23 @@ void ActorExt::set_privatized_region(smpi_privatization_region_t region)
   privatized_region_ = region;
 }
 
-smpi_privatization_region_t ActorExt::privatized_region()
+smpi_privatization_region_t ActorExt::privatized_region() const
 {
   return privatized_region_;
 }
 
-MPI_Comm ActorExt::comm_world()
+MPI_Comm ActorExt::comm_world() const
 {
   return comm_world_ == nullptr ? MPI_COMM_NULL : *comm_world_;
 }
 
-s4u::MutexPtr ActorExt::mailboxes_mutex()
+s4u::MutexPtr ActorExt::mailboxes_mutex() const
 {
   return mailboxes_mutex_;
 }
 
 #if HAVE_PAPI
-int ActorExt::papi_event_set()
+int ActorExt::papi_event_set() const
 {
   return papi_event_set_;
 }
@@ -168,7 +168,7 @@ void ActorExt::simulated_start()
   simulated_ = SIMIX_get_clock();
 }
 
-double ActorExt::simulated_elapsed()
+double ActorExt::simulated_elapsed() const
 {
   return SIMIX_get_clock() - simulated_;
 }
@@ -205,7 +205,7 @@ void ActorExt::set_sampling(int s)
   sampling_ = s;
 }
 
-int ActorExt::sampling()
+int ActorExt::sampling() const
 {
   return sampling_;
 }
@@ -243,7 +243,7 @@ void ActorExt::init()
   XBT_DEBUG("<%ld> SMPI process has been initialized: %p", ext->actor_->get_pid(), ext->actor_);
 }
 
-int ActorExt::get_optind()
+int ActorExt::get_optind() const
 {
   return optind_;
 }
index 84d2455..6e01ff4 100644 (file)
@@ -90,17 +90,14 @@ private:
 
 public:
     RequestStorage() {}
-    int size()
-    {
-      return store.size();
-    }
+    int size() const { return store.size(); }
 
     req_storage_t& get_store()
     {
       return store;
     }
 
-    void get_requests(std::vector<MPI_Request>& vec)
+    void get_requests(std::vector<MPI_Request>& vec) const
     {
       for (auto const& pair : store) {
         auto& req = pair.second;
index 64fd592..4d3dc3f 100644 (file)
@@ -125,26 +125,26 @@ MPI_Group Comm::group()
   return group_;
 }
 
-int Comm::size()
+int Comm::size() const
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->size();
   return group_->size();
 }
 
-int Comm::rank()
+int Comm::rank() const
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->rank();
   return group_->rank(s4u::Actor::self());
 }
 
-int Comm::id()
+int Comm::id() const
 {
   return id_;
 }
 
-void Comm::get_name (char* name, int* len)
+void Comm::get_name(char* name, int* len) const
 {
   if (this == MPI_COMM_UNINITIALIZED){
     smpi_process()->comm_world()->get_name(name, len);
@@ -179,45 +179,49 @@ void Comm::set_leaders_comm(MPI_Comm leaders){
   leaders_comm_=leaders;
 }
 
-int* Comm::get_non_uniform_map(){
+int* Comm::get_non_uniform_map() const
+{
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->get_non_uniform_map();
   return non_uniform_map_;
 }
 
-int* Comm::get_leaders_map(){
+int* Comm::get_leaders_map() const
+{
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->get_leaders_map();
   return leaders_map_;
 }
 
-MPI_Comm Comm::get_leaders_comm(){
+MPI_Comm Comm::get_leaders_comm() const
+{
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->get_leaders_comm();
   return leaders_comm_;
 }
 
-MPI_Comm Comm::get_intra_comm(){
+MPI_Comm Comm::get_intra_comm() const
+{
   if (this == MPI_COMM_UNINITIALIZED || this==MPI_COMM_WORLD)
     return smpi_process()->comm_intra();
   else return intra_comm_;
 }
 
-bool Comm::is_uniform()
+bool Comm::is_uniform() const
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_uniform();
   return is_uniform_ != 0;
 }
 
-bool Comm::is_blocked()
+bool Comm::is_blocked() const
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_blocked();
   return is_blocked_ != 0;
 }
 
-bool Comm::is_smp_comm()
+bool Comm::is_smp_comm() const
 {
   if (this == MPI_COMM_UNINITIALIZED)
     return smpi_process()->comm_world()->is_smp_comm();
index 782a4ce..c28c526 100644 (file)
@@ -224,16 +224,17 @@ void Datatype::commit()
   flags_ |= DT_FLAG_COMMITED;
 }
 
-bool Datatype::is_valid(){
+bool Datatype::is_valid() const
+{
   return (flags_ & DT_FLAG_COMMITED);
 }
 
-bool Datatype::is_basic()
+bool Datatype::is_basic() const
 {
   return (flags_ & DT_FLAG_BASIC);
 }
 
-bool Datatype::is_replayable()
+bool Datatype::is_replayable() const
 {
   return (simgrid::instr::trace_format == simgrid::instr::TraceFormat::Ti) &&
          ((this == MPI_BYTE) || (this == MPI_DOUBLE) || (this == MPI_INT) || (this == MPI_CHAR) ||
@@ -249,13 +250,15 @@ void Datatype::addflag(int flag){
   flags_ &= flag;
 }
 
-int Datatype::extent(MPI_Aint * lb, MPI_Aint * extent){
+int Datatype::extent(MPI_Aint* lb, MPI_Aint* extent) const
+{
   *lb = lb_;
   *extent = ub_ - lb_;
   return MPI_SUCCESS;
 }
 
-void Datatype::get_name(char* name, int* length){
+void Datatype::get_name(char* name, int* length) const
+{
   if(name_!=nullptr){
     *length = strlen(name_);
     strncpy(name, name_, *length+1);
@@ -288,9 +291,8 @@ int Datatype::unpack(const void* inbuf, int insize, int* position, void* outbuf,
   return MPI_SUCCESS;
 }
 
-int Datatype::get_contents (int max_integers, int max_addresses,
-                            int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
-                            MPI_Datatype *array_of_datatypes)
+int Datatype::get_contents(int max_integers, int max_addresses, int max_datatypes, int* array_of_integers,
+                           MPI_Aint* array_of_addresses, MPI_Datatype* array_of_datatypes) const
 {
   if(contents_==nullptr)
     return MPI_ERR_ARG;
@@ -307,8 +309,7 @@ int Datatype::get_contents (int max_integers, int max_addresses,
   return MPI_SUCCESS;
 }
 
-int Datatype::get_envelope (int* num_integers, int* num_addresses,
-                            int* num_datatypes, int* combiner)
+int Datatype::get_envelope(int* num_integers, int* num_addresses, int* num_datatypes, int* combiner) const
 {
   if(contents_==nullptr){
     *num_integers = 0;
index f62e638..abedcfa 100644 (file)
@@ -25,15 +25,18 @@ MPI_Errhandler Errhandler::f2c(int id) {
   }
 }
 
-void Errhandler::call(MPI_Comm comm, int errorcode){
+void Errhandler::call(MPI_Comm comm, int errorcode) const
+{
   comm_func_(&comm, &errorcode);
 }
 
-void Errhandler::call(MPI_Win win, int errorcode){
+void Errhandler::call(MPI_Win win, int errorcode) const
+{
   win_func_(&win, &errorcode);
 }
 
-void Errhandler::call(MPI_File file, int errorcode){
+void Errhandler::call(MPI_File file, int errorcode) const
+{
   file_func_(&file, &errorcode);
 }
 
index d482221..5e480d6 100644 (file)
@@ -103,12 +103,14 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::get_position(MPI_Offset* offset){
+  int File::get_position(MPI_Offset* offset) const
+  {
     *offset=file_->tell();
     return MPI_SUCCESS;
   }
 
-  int File::get_position_shared(MPI_Offset* offset){
+  int File::get_position_shared(MPI_Offset* offset) const
+  {
     shared_mutex_->lock();
     *offset=*shared_file_pointer_;
     shared_mutex_->unlock();
@@ -263,7 +265,7 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::get_view(MPI_Offset* /*disp*/, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep)
+  int File::get_view(MPI_Offset* /*disp*/, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep) const
   {
     *etype=etype_;
     *filetype=filetype_;
@@ -271,11 +273,13 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::size(){
+  int File::size() const
+  {
     return file_->size();
   }
 
-  int File::flags(){
+  int File::flags() const
+  {
     return flags_;
   }
 
@@ -301,7 +305,8 @@ namespace smpi{
       info_->ref();
   }
 
-  MPI_Comm File::comm(){
+  MPI_Comm File::comm() const
+  {
     return comm_;
   }
 
index 564b22f..446e6b9 100644 (file)
@@ -21,7 +21,8 @@ void Info::unref(Info* info){
   }
 }
 
-int Info::get(const char *key, int valuelen, char *value, int *flag){
+int Info::get(const char* key, int valuelen, char* value, int* flag) const
+{
   *flag=false;
   auto val = map_.find(key);
   if (val != map_.end()) {
@@ -42,12 +43,14 @@ int Info::remove(const char *key){
     return MPI_SUCCESS;
 }
 
-int Info::get_nkeys(int *nkeys){
+int Info::get_nkeys(int* nkeys) const
+{
   *nkeys = map_.size();
   return MPI_SUCCESS;
 }
 
-int Info::get_nthkey(int n, char *key){
+int Info::get_nthkey(int n, char* key) const
+{
   int num=0;
   for (auto const& elm : map_) {
     if (num == n) {
@@ -59,7 +62,8 @@ int Info::get_nthkey(int n, char *key){
   return MPI_ERR_ARG;
 }
 
-int Info::get_valuelen(const char *key, int *valuelen, int *flag){
+int Info::get_valuelen(const char* key, int* valuelen, int* flag) const
+{
   *flag=false;
   auto val = map_.find(key);
   if (val != map_.end()) {
index 84a3d82..3ae327d 100644 (file)
@@ -238,7 +238,7 @@ CREATE_MPI_OP(MPI_NO_OP, no_func)
 namespace simgrid{
 namespace smpi{
 
-void Op::apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype)
+void Op::apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype) const
 {
   if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
     // we need to switch as the called function may silently touch global variables
index 5018da9..a447e56 100644 (file)
@@ -165,7 +165,7 @@ bool Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl*)
   return match_common(req, ref, req);
 }
 
-void Request::print_request(const char *message)
+void Request::print_request(const char* message) const
 {
   XBT_VERB("%s  request %p  [buf = %p, size = %zu, src = %d, dst = %d, tag = %d, flags = %x]",
        message, this, buf_, size_, src_, dst_, tag_, flags_);
@@ -1197,13 +1197,14 @@ void Request::set_nbc_requests(MPI_Request* reqs, int size){
   }
 }
 
-int Request::get_nbc_requests_size(){
+int Request::get_nbc_requests_size() const
+{
   return nbc_requests_size_;
 }
 
-MPI_Request* Request::get_nbc_requests(){
+MPI_Request* Request::get_nbc_requests() const
+{
   return nbc_requests_;
 }
-
 }
 }
index 5928501..e25a214 100644 (file)
@@ -238,7 +238,8 @@ int Topo_Cart::shift(int direction, int disp, int* rank_source, int* rank_dest)
   return MPI_SUCCESS;
 }
 
-int Topo_Cart::dim_get(int *ndims) {
+int Topo_Cart::dim_get(int* ndims) const
+{
   *ndims =ndims_;
   return MPI_SUCCESS;
 }
index 58a6448..38ac955 100644 (file)
@@ -110,7 +110,8 @@ int Win::detach(const void* /*base*/)
   return MPI_SUCCESS;
 }
 
-void Win::get_name(char* name, int* length){
+void Win::get_name(char* name, int* length) const
+{
   if(name_==nullptr){
     *length=0;
     name=nullptr;
@@ -136,23 +137,28 @@ MPI_Info Win::info()
   return info_;
 }
 
-int Win::rank(){
+int Win::rank() const
+{
   return rank_;
 }
 
-MPI_Aint Win::size(){
+MPI_Aint Win::size() const
+{
   return size_;
 }
 
-void* Win::base(){
+void* Win::base() const
+{
   return base_;
 }
 
-int Win::disp_unit(){
+int Win::disp_unit() const
+{
   return disp_unit_;
 }
 
-int Win::dynamic(){
+int Win::dynamic() const
+{
   return dynamic_;
 }
 
index 4264966..50e03b4 100644 (file)
@@ -36,9 +36,9 @@ public:
     host_to_actors.insert({host, actor});
   }
 
-  s4u::Host* get_host(s4u::ActorPtr actor) { return actor_to_host[actor]; }
+  s4u::Host* get_host(s4u::ActorPtr actor) const { return actor_to_host.at(actor); }
 
-  unsigned int count_actors(s4u::Host* host)
+  unsigned int count_actors(s4u::Host* host) const
   {
     return host_to_actors.count(host); // TODO This is linear in the size of the map. Maybe replace by constant lookup through another map?
   }