Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference parameters in src/smpi/.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 29 Dec 2019 20:56:46 +0000 (21:56 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 29 Dec 2019 22:06:55 +0000 (23:06 +0100)
25 files changed:
include/simgrid/smpi/replay.hpp
include/smpi/smpi.h
src/instr/instr_smpi.hpp
src/smpi/include/smpi_comm.hpp
src/smpi/include/smpi_datatype.hpp
src/smpi/include/smpi_file.hpp
src/smpi/include/smpi_info.hpp
src/smpi/include/smpi_keyvals.hpp
src/smpi/include/smpi_request.hpp
src/smpi/include/smpi_status.hpp
src/smpi/include/smpi_win.hpp
src/smpi/internals/instr_smpi.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/internals/smpi_replay.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_file.cpp
src/smpi/mpi/smpi_keyvals.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/mpi/smpi_status.cpp
src/smpi/mpi/smpi_topo.cpp
src/smpi/mpi/smpi_win.cpp
src/smpi/plugins/load_balancer/LoadBalancer.cpp
src/smpi/plugins/load_balancer/load_balancer.hpp

index 715f52e..1a0d2a5 100644 (file)
@@ -34,7 +34,7 @@
 XBT_PRIVATE unsigned char* smpi_get_tmp_sendbuffer(size_t size);
 XBT_PRIVATE unsigned char* smpi_get_tmp_recvbuffer(size_t size);
 
-XBT_PRIVATE void log_timed_action(simgrid::xbt::ReplayAction& action, double clock);
+XBT_PRIVATE void log_timed_action(const simgrid::xbt::ReplayAction& action, double clock);
 
 namespace simgrid {
 namespace smpi {
index 3ec0953..141a231 100644 (file)
@@ -1002,9 +1002,9 @@ XBT_PUBLIC void smpi_comm_set_copy_data_callback(void (*callback)(smx_activity_t
  */
 XBT_PUBLIC void smpi_trace_set_call_location(const char* file, int line);
 /** Fortran binding **/
-XBT_PUBLIC void smpi_trace_set_call_location_(const char* file, int* line);
+XBT_PUBLIC void smpi_trace_set_call_location_(const char* file, const int* line);
 /** Fortran binding + -fsecond-underscore **/
-XBT_PUBLIC void smpi_trace_set_call_location__(const char* file, int* line);
+XBT_PUBLIC void smpi_trace_set_call_location__(const char* file, const int* line);
 
 #define SMPI_ITER_NAME1(line) _XBT_CONCAT(iter_count, line)
 #define SMPI_ITER_NAME(line) SMPI_ITER_NAME1(line)
index f5f7f9f..5414c53 100644 (file)
@@ -12,7 +12,7 @@
 
 /* Helper functions */
 XBT_PRIVATE container_t smpi_container(int rank);
-XBT_PRIVATE void TRACE_smpi_setup_container(int rank, sg_host_t host);
+XBT_PRIVATE void TRACE_smpi_setup_container(int rank, const_sg_host_t host);
 
 XBT_PRIVATE void TRACE_smpi_computing_init(int rank);
 XBT_PRIVATE void TRACE_smpi_computing_out(int rank);
index 9a416d6..8c312ee 100644 (file)
@@ -84,7 +84,7 @@ public:
   void add_rma_win(MPI_Win win);
   void remove_rma_win(MPI_Win win);
   void finish_rma_calls();
-  MPI_Comm split_type(int type, int key, MPI_Info info);
+  MPI_Comm split_type(int type, int key, const Info* info);
 };
 
 } // namespace smpi
index 196ab80..b55f3aa 100644 (file)
@@ -114,7 +114,7 @@ public:
   void commit();
   bool is_valid();
   bool is_basic();
-  static const char* encode(MPI_Datatype dt) { return dt->id.c_str(); }
+  static const char* encode(const Datatype* dt) { return dt->id.c_str(); }
   static MPI_Datatype decode(const std::string& datatype_id);
   bool is_replayable();
   void addflag(int flag);
@@ -129,8 +129,8 @@ public:
   static int keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
                            void* extra_state);
   static int keyval_free(int* keyval);
-  int pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, MPI_Comm comm);
-  int unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Comm comm);
+  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);
 
   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);
index 95e3d99..3e38aa4 100644 (file)
@@ -45,7 +45,7 @@ class File{
   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, MPI_Info info);
+  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);
   MPI_Info info();
   void set_info( MPI_Info info);
@@ -57,7 +57,7 @@ class File{
   static int write_ordered(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
   template <int (*T)(MPI_File, void *, int, MPI_Datatype, MPI_Status *)> int op_all(void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
   static int close(MPI_File *fh);
-  static int del(const char *filename, MPI_Info info);
+  static int del(const char* filename, const Info* info);
   MPI_Errhandler errhandler();
   void set_errhandler( MPI_Errhandler errhandler);
 };
index 1fb206a..9799a97 100644 (file)
@@ -21,7 +21,7 @@ class Info : public F2C{
 
 public:
   Info() = default;
-  explicit Info(Info* orig) : map_(orig->map_) {}
+  explicit Info(const Info* orig) : map_(orig->map_) {}
   ~Info() = default;
   void ref();
   static void unref(MPI_Info info);
index a9af670..38c6ae5 100644 (file)
@@ -56,7 +56,8 @@ class Keyval{
     template <typename T> int attr_delete(int keyval);
     template <typename T> int attr_get(int keyval, void* attr_value, int* flag);
     template <typename T> int attr_put(int keyval, void* attr_value);
-    template <typename T> static int call_deleter(T* obj, smpi_key_elem elem, int keyval, void * value, int* flag);
+    template <typename T>
+    static int call_deleter(T* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* flag);
     template <typename T> void cleanup_attr();
 };
 
index 9634cbf..5c9fccb 100644 (file)
@@ -117,7 +117,7 @@ public:
 
   static int grequest_start( MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn, MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request);
   static int grequest_complete( MPI_Request request);
-  static int get_status(MPI_Request req, int* flag, MPI_Status * status);
+  static int get_status(const Request* req, int* flag, MPI_Status* status);
 
   static void free_f(int id);
   static Request* f2c(int);
index b5c6736..b85a561 100644 (file)
@@ -19,7 +19,7 @@ public:
 static void empty(MPI_Status * status);
 static int cancelled (const MPI_Status * status);
 static void set_cancelled (MPI_Status * status, int flag);
-static void set_elements (MPI_Status * status, MPI_Datatype , int count);
+static void set_elements(MPI_Status* status, const Datatype*, int count);
 static int get_count(const MPI_Status * status, MPI_Datatype datatype);
 };
 
index 242c7ef..ff217b9 100644 (file)
@@ -78,9 +78,8 @@ public:
   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(const void *origin_addr, void *compare_addr,
-        void *result_addr, MPI_Datatype datatype, int target_rank,
-        MPI_Aint target_disp);
+  int compare_and_swap(const void* origin_addr, const void* compare_addr, void* result_addr, MPI_Datatype datatype,
+                       int target_rank, MPI_Aint target_disp);
   static Win* f2c(int id);
 
   int lock(int lock_type, int rank, int assert);
index 5c0f4e9..8a728cf 100644 (file)
@@ -136,7 +136,7 @@ static std::string TRACE_smpi_get_key(int src, int dst, int tag, int send)
   return key;
 }
 
-void TRACE_smpi_setup_container(int rank, sg_host_t host)
+void TRACE_smpi_setup_container(int rank, const_sg_host_t host)
 {
   container_t father = simgrid::instr::Container::get_root();
   if (TRACE_smpi_is_grouped()) {
index c52478a..b7315d3 100644 (file)
@@ -474,13 +474,13 @@ void smpi_trace_set_call_location(const char* file, const int line)
 }
 
 /** Required for Fortran bindings */
-void smpi_trace_set_call_location_(const char* file, int* line)
+void smpi_trace_set_call_location_(const char* file, const int* line)
 {
   smpi_trace_set_call_location(file, *line);
 }
 
 /** Required for Fortran if -fsecond-underscore is activated */
-void smpi_trace_set_call_location__(const char* file, int* line)
+void smpi_trace_set_call_location__(const char* file, const int* line)
 {
   smpi_trace_set_call_location(file, *line);
 }
index 3922c63..3c3c90a 100644 (file)
@@ -132,13 +132,14 @@ void smpi_comm_set_copy_data_callback(void (*callback) (smx_activity_t, void*, s
   };
 }
 
-static void memcpy_private(void* dest, const void* src, std::vector<std::pair<size_t, size_t>>& private_blocks)
+static void memcpy_private(void* dest, const void* src, const std::vector<std::pair<size_t, size_t>>& private_blocks)
 {
   for (auto const& block : private_blocks)
     memcpy((uint8_t*)dest+block.first, (uint8_t*)src+block.first, block.second-block.first);
 }
 
-static void check_blocks(std::vector<std::pair<size_t, size_t>> &private_blocks, size_t buff_size) {
+static void check_blocks(const std::vector<std::pair<size_t, size_t>>& private_blocks, size_t buff_size)
+{
   for (auto const& block : private_blocks)
     xbt_assert(block.first <= block.second && block.second <= buff_size, "Oops, bug in shared malloc.");
 }
@@ -557,7 +558,7 @@ int smpi_main(const char* executable, int argc, char* argv[])
 
   /* This is a ... heavy way to count the MPI ranks */
   int rank_counts = 0;
-  simgrid::s4u::Actor::on_creation.connect([&rank_counts](simgrid::s4u::Actor& actor) {
+  simgrid::s4u::Actor::on_creation.connect([&rank_counts](const simgrid::s4u::Actor& actor) {
     if (not actor.is_daemon())
       rank_counts++;
   });
index 27f4605..3e0124e 100644 (file)
@@ -64,7 +64,7 @@ public:
 typedef std::tuple</*sender*/ int, /* receiver */ int, /* tag */ int> req_key_t;
 typedef std::unordered_map<req_key_t, MPI_Request, hash_tuple::hash<std::tuple<int,int,int>>> req_storage_t;
 
-void log_timed_action(simgrid::xbt::ReplayAction& action, double clock)
+void log_timed_action(const simgrid::xbt::ReplayAction& action, double clock)
 {
   if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){
     std::string s = boost::algorithm::join(action, " ");
@@ -754,7 +754,7 @@ void smpi_replay_init(const char* instance_id, int rank, double start_delay_flop
   TRACE_smpi_comm_in(my_proc_id, "smpi_replay_run_init", new simgrid::instr::NoOpTIData("init"));
   TRACE_smpi_comm_out(my_proc_id);
   xbt_replay_action_register("init", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::InitAction().execute(action); });
-  xbt_replay_action_register("finalize", [](simgrid::xbt::ReplayAction&) { /* nothing to do */ });
+  xbt_replay_action_register("finalize", [](simgrid::xbt::ReplayAction const&) { /* nothing to do */ });
   xbt_replay_action_register("comm_size", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); });
   xbt_replay_action_register("comm_split",[](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); });
   xbt_replay_action_register("comm_dup",  [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::CommunicatorAction().execute(action); });
index 4fe6185..c35d2f1 100644 (file)
@@ -571,7 +571,7 @@ void Comm::set_errhandler(MPI_Errhandler errhandler)
     errhandler_->ref();
 }
 
-MPI_Comm Comm::split_type(int type, int /*key*/, MPI_Info)
+MPI_Comm Comm::split_type(int type, int /*key*/, const Info*)
 {
   //MPI_UNDEFINED can be given to some nodes... but we need them to still perform the smp part which is collective
   if(type != MPI_COMM_TYPE_SHARED && type != MPI_UNDEFINED){
index 8a7773c..c086161 100644 (file)
@@ -256,7 +256,7 @@ void Datatype::set_name(const char* name){
   name_ = xbt_strdup(name);
 }
 
-int Datatype::pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, MPI_Comm)
+int Datatype::pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, const Comm*)
 {
   if (outcount - *position < incount*static_cast<int>(size_))
     return MPI_ERR_OTHER;
@@ -265,7 +265,7 @@ int Datatype::pack(const void* inbuf, int incount, void* outbuf, int outcount, i
   return MPI_SUCCESS;
 }
 
-int Datatype::unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Comm)
+int Datatype::unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, const Comm*)
 {
   if (outcount*static_cast<int>(size_)> insize)
     return MPI_ERR_OTHER;
index 4c73765..3cf7e0d 100644 (file)
@@ -91,7 +91,7 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::del(const char* filename, MPI_Info)
+  int File::del(const char* filename, const Info*)
   {
     //get the file with MPI_MODE_DELETE_ON_CLOSE and then close it
     File* f = new File(MPI_COMM_SELF,filename,MPI_MODE_DELETE_ON_CLOSE|MPI_MODE_RDWR, nullptr);
@@ -248,7 +248,7 @@ namespace smpi{
     return ret;
   }
 
-  int File::set_view(MPI_Offset /*disp*/, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, MPI_Info)
+  int File::set_view(MPI_Offset /*disp*/, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, const Info*)
   {
     etype_=etype;
     filetype_=filetype;
index 33badb3..7ddedb6 100644 (file)
@@ -14,7 +14,8 @@ std::unordered_map<int, void*>* Keyval::attributes(){
   return &attributes_;
 }
 
-template <> int Keyval::call_deleter<Comm>(Comm* obj, smpi_key_elem elem, int keyval, void* value, int* /*flag*/)
+template <>
+int Keyval::call_deleter<Comm>(Comm* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* /*flag*/)
 {
   int ret = MPI_SUCCESS;
   if(elem->delete_fn.comm_delete_fn!=MPI_NULL_DELETE_FN)
@@ -24,7 +25,8 @@ template <> int Keyval::call_deleter<Comm>(Comm* obj, smpi_key_elem elem, int ke
   return ret;
 }
 
-template <> int Keyval::call_deleter<Win>(Win* obj, smpi_key_elem elem, int keyval, void* value, int* /*flag*/)
+template <>
+int Keyval::call_deleter<Win>(Win* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* /*flag*/)
 {
   int ret = MPI_SUCCESS;
   if(elem->delete_fn.win_delete_fn!=MPI_NULL_DELETE_FN)
@@ -35,7 +37,7 @@ template <> int Keyval::call_deleter<Win>(Win* obj, smpi_key_elem elem, int keyv
 }
 
 template <>
-int Keyval::call_deleter<Datatype>(Datatype* obj, smpi_key_elem elem, int keyval, void* value, int* /*flag*/)
+int Keyval::call_deleter<Datatype>(Datatype* obj, const s_smpi_key_elem_t* elem, int keyval, void* value, int* /*flag*/)
 {
   int ret = MPI_SUCCESS;
   if(elem->delete_fn.type_delete_fn!=MPI_NULL_DELETE_FN)
index b9ac2b3..18173a3 100644 (file)
@@ -1111,7 +1111,7 @@ void Request::free_f(int id)
   }
 }
 
-int Request::get_status(MPI_Request req, int* flag, MPI_Status* status)
+int Request::get_status(const Request* req, int* flag, MPI_Status* status)
 {
   *flag=0;
 
index 7c8d6e1..2d0f92e 100644 (file)
@@ -32,7 +32,8 @@ void Status::set_cancelled(MPI_Status * status, int flag)
   status->cancelled=flag;
 }
 
-void Status::set_elements (MPI_Status * status, MPI_Datatype , int count){
+void Status::set_elements(MPI_Status* status, const Datatype*, int count)
+{
   status->count=count;
 }
 
index 2dbbcd4..5219fc6 100644 (file)
@@ -12,7 +12,7 @@
 #include <vector>
 
 /* static functions */
-static int assignnodes(int ndim, int nfactor, int *pfacts,int **pdims);
+static int assignnodes(int ndim, int nfactor, const int* pfacts, int** pdims);
 static int getfactors(int num, int *nfators, int **factors);
 
 
@@ -349,7 +349,7 @@ int Topo_Cart::Dims_create(int nnodes, int ndims, int dims[])
  *          - ptr to array of dimensions (returned value)
  *  Returns:    - 0 or ERROR
  */
-static int assignnodes(int ndim, int nfactor, int *pfacts, int **pdims)
+static int assignnodes(int ndim, int nfactor, const int* pfacts, int** pdims)
 {
   int *pmin;
 
index 1dfda94..41c17e7 100644 (file)
@@ -414,9 +414,9 @@ int Win::get_accumulate(const void* origin_addr, int origin_count, MPI_Datatype
   return MPI_SUCCESS;
 }
 
-int Win::compare_and_swap(const void *origin_addr, void *compare_addr,
-        void *result_addr, MPI_Datatype datatype, int target_rank,
-        MPI_Aint target_disp){
+int Win::compare_and_swap(const void* origin_addr, const void* compare_addr, void* result_addr, MPI_Datatype datatype,
+                          int target_rank, MPI_Aint target_disp)
+{
   //get sender pointer
   const Win* send_win = connected_wins_[target_rank];
 
index c748eb5..a5eb936 100644 (file)
@@ -46,7 +46,7 @@ void LoadBalancer::run()
 {
   simgrid::s4u::Engine* engine                     = simgrid::s4u::Engine::get_instance();
   std::vector<simgrid::s4u::Host*> available_hosts =
-      engine->get_filtered_hosts([](simgrid::s4u::Host* host) { return host->is_on(); });
+      engine->get_filtered_hosts([](const simgrid::s4u::Host* host) { return host->is_on(); });
   xbt_assert(available_hosts.size() > 0, "No hosts available; are they all switched off?");
 
   // TODO: Account for daemon background load (-> use especially the availability file)
index 4924337..3c87f07 100644 (file)
@@ -46,11 +46,8 @@ public:
   void for_each_actor(simgrid::s4u::Host* host, const std::function<void(simgrid::s4u::ActorPtr)>& callback)
   {
     auto range = host_to_actors.equal_range(host);
-    std::for_each(
-        range.first,
-        range.second,
-        [&callback](host_to_actors_map_t::value_type& x) { callback(x.second); }
-    );
+    std::for_each(range.first, range.second,
+                  [&callback](host_to_actors_map_t::value_type const& x) { callback(x.second); });
   }
 };