Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Replace redundant type with "auto" (src/smpi/).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 4 Oct 2020 12:23:25 +0000 (14:23 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 4 Oct 2020 20:18:38 +0000 (22:18 +0200)
24 files changed:
src/smpi/bindings/smpi_f77.cpp
src/smpi/bindings/smpi_f77_coll.cpp
src/smpi/bindings/smpi_f77_comm.cpp
src/smpi/bindings/smpi_f77_type.cpp
src/smpi/bindings/smpi_pmpi_coll.cpp
src/smpi/bindings/smpi_pmpi_request.cpp
src/smpi/bindings/smpi_pmpi_type.cpp
src/smpi/include/smpi_file.hpp
src/smpi/include/smpi_keyvals.hpp
src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_deployment.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/internals/smpi_replay.cpp
src/smpi/internals/smpi_shared.cpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_datatype_derived.cpp
src/smpi/mpi/smpi_file.cpp
src/smpi/mpi/smpi_group.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/mpi/smpi_topo.cpp
src/smpi/mpi/smpi_win.cpp
src/smpi/plugins/ampi/instr_ampi.cpp

index 23b5270..e733968 100644 (file)
@@ -276,9 +276,9 @@ void mpi_win_get_attr_(int* win, int* type_keyval, MPI_Aint* attribute_val, int*
 
 void mpi_win_set_attr_(int* win, int* type_keyval, MPI_Aint* att, int* ierr)
 {
-  MPI_Aint* val = (MPI_Aint*)xbt_malloc(sizeof(MPI_Aint));
-  *val          = *att;
-  *ierr = MPI_Win_set_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, val);
+  auto* val = static_cast<MPI_Aint*>(xbt_malloc(sizeof(MPI_Aint)));
+  *val      = *att;
+  *ierr     = MPI_Win_set_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, val);
 }
 
 void mpi_win_delete_attr_(int* win, int* comm_keyval, int* ierr)
@@ -820,9 +820,9 @@ void mpi_attr_delete_ (int* comm, int* keyval, int* ierr) {
 }
 
 void mpi_attr_put_ (int* comm, int* keyval, int* attr_value, int* ierr) {
int* val = (int*)xbt_malloc(sizeof(int));
*val=*attr_value;
*ierr = MPI_Attr_put(simgrid::smpi::Comm::f2c(*comm), *keyval, val);
 auto* val = static_cast<int*>(xbt_malloc(sizeof(int)));
 *val      = *attr_value;
 *ierr     = MPI_Attr_put(simgrid::smpi::Comm::f2c(*comm), *keyval, val);
 }
 
 void mpi_keyval_create_ (void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr) {
index 5029643..0db71ca 100644 (file)
@@ -119,8 +119,8 @@ void mpi_reduce_scatter_block_ (void *sendbuf, void *recvbuf, int* recvcount, in
 void mpi_alltoallw_ ( void *sendbuf, int *sendcnts, int *sdispls, int* old_sendtypes, void *recvbuf, int *recvcnts,
                       int *rdispls, int* old_recvtypes, int* comm, int* ierr){
   int size = simgrid::smpi::Comm::f2c(*comm)->size();
-  MPI_Datatype* sendtypes = new MPI_Datatype[size];
-  MPI_Datatype* recvtypes = new MPI_Datatype[size];
+  auto* sendtypes = new MPI_Datatype[size];
+  auto* recvtypes = new MPI_Datatype[size];
   for(int i=0; i< size; i++){
     if(FORT_IN_PLACE(sendbuf)!=MPI_IN_PLACE)
       sendtypes[i] = simgrid::smpi::Datatype::f2c(old_sendtypes[i]);
@@ -301,8 +301,8 @@ void mpi_ialltoallw_ ( void *sendbuf, int *sendcnts, int *sdispls, int* old_send
                       int *rdispls, int* old_recvtypes, int* comm, int* request, int* ierr){
   MPI_Request req;
   int size = simgrid::smpi::Comm::f2c(*comm)->size();
-  MPI_Datatype* sendtypes = new MPI_Datatype[size];
-  MPI_Datatype* recvtypes = new MPI_Datatype[size];
+  auto* sendtypes = new MPI_Datatype[size];
+  auto* recvtypes = new MPI_Datatype[size];
   for(int i=0; i< size; i++){
     if(FORT_IN_PLACE(sendbuf)!=MPI_IN_PLACE)
       sendtypes[i] = simgrid::smpi::Datatype::f2c(old_sendtypes[i]);
index aafd435..b087102 100644 (file)
@@ -77,9 +77,9 @@ void mpi_comm_get_attr_ (int* comm, int* comm_keyval, int *attribute_val, int *f
 }
 
 void mpi_comm_set_attr_ (int* comm, int* comm_keyval, int *attribute_val, int* ierr){
int* val = (int*)xbt_malloc(sizeof(int));
*val=*attribute_val;
*ierr = MPI_Comm_set_attr ( simgrid::smpi::Comm::f2c(*comm), *comm_keyval, val);
 auto* val = static_cast<int*>(xbt_malloc(sizeof(int)));
 *val      = *attribute_val;
 *ierr     = MPI_Comm_set_attr(simgrid::smpi::Comm::f2c(*comm), *comm_keyval, val);
 }
 
 void mpi_comm_delete_attr_ (int* comm, int* comm_keyval, int* ierr){
index 9bd6938..c24a661 100644 (file)
@@ -64,9 +64,9 @@ void mpi_type_get_attr_ (int* type, int* type_keyval, int *attribute_val, int* f
 }
 
 void mpi_type_set_attr_ (int* type, int* type_keyval, int *attribute_val, int* ierr){
int* val = (int*)xbt_malloc(sizeof(int));
*val=*attribute_val;
*ierr = MPI_Type_set_attr ( simgrid::smpi::Datatype::f2c(*type), *type_keyval, val);
 auto* val = static_cast<int*>(xbt_malloc(sizeof(int)));
 *val      = *attribute_val;
 *ierr     = MPI_Type_set_attr(simgrid::smpi::Datatype::f2c(*type), *type_keyval, val);
 }
 
 void mpi_type_delete_attr_ (int* type, int* type_keyval, int* ierr){
@@ -132,7 +132,7 @@ void mpi_type_create_hvector_(int* count, int* blocklen, MPI_Aint* stride, int*
 
 void mpi_type_hindexed_ (int* count, int* blocklens, int* indices, int* old_type, int*  newtype, int* ierr) {
   MPI_Datatype tmp;
-  MPI_Aint* indices_aint=new MPI_Aint[*count];
+  auto* indices_aint = new MPI_Aint[*count];
   for(int i=0; i<*count; i++)
     indices_aint[i]=indices[i];
   *ierr = MPI_Type_hindexed(*count, blocklens, indices_aint, simgrid::smpi::Datatype::f2c(*old_type), &tmp);
@@ -186,8 +186,8 @@ void mpi_type_create_indexed_block_ (int* count, int* blocklength, int* indices,
 
 void mpi_type_struct_ (int* count, int* blocklens, int* indices, int* old_types, int*  newtype, int* ierr) {
   MPI_Datatype tmp;
-  MPI_Datatype* types = static_cast<MPI_Datatype*>(xbt_malloc(*count*sizeof(MPI_Datatype)));
-  MPI_Aint* indices_aint=new MPI_Aint[*count];
+  auto* types        = static_cast<MPI_Datatype*>(xbt_malloc(*count * sizeof(MPI_Datatype)));
+  auto* indices_aint = new MPI_Aint[*count];
   for (int i = 0; i < *count; i++) {
     indices_aint[i]=indices[i];
     types[i] = simgrid::smpi::Datatype::f2c(old_types[i]);
@@ -202,7 +202,7 @@ void mpi_type_struct_ (int* count, int* blocklens, int* indices, int* old_types,
 
 void mpi_type_create_struct_(int* count, int* blocklens, MPI_Aint* indices, int*  old_types, int*  newtype, int* ierr){
   MPI_Datatype tmp;
-  MPI_Datatype* types = static_cast<MPI_Datatype*>(xbt_malloc(*count*sizeof(MPI_Datatype)));
+  auto* types = static_cast<MPI_Datatype*>(xbt_malloc(*count * sizeof(MPI_Datatype)));
   for (int i = 0; i < *count; i++) {
     types[i] = simgrid::smpi::Datatype::f2c(old_types[i]);
   }
index ad92c87..8df1ea1 100644 (file)
@@ -176,7 +176,7 @@ int PMPI_Igatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, voi
   int rank         = simgrid::s4u::this_actor::get_pid();
   int dt_size_recv = recvtype->is_replayable() ? 1 : recvtype->size();
 
-  std::vector<int>* trace_recvcounts = new std::vector<int>();
+  auto* trace_recvcounts = new std::vector<int>();
   if (comm->rank() == root) {
     for (int i = 0; i < comm->size(); i++) // copy data to avoid bad free
       trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
@@ -275,7 +275,7 @@ int PMPI_Iallgatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype,
   int rank         = simgrid::s4u::this_actor::get_pid();
   int dt_size_recv = recvtype->is_replayable() ? 1 : recvtype->size();
 
-  std::vector<int>* trace_recvcounts = new std::vector<int>();
+  auto* trace_recvcounts = new std::vector<int>();
   for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
     trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
   }
@@ -377,7 +377,7 @@ int PMPI_Iscatterv(const void* sendbuf, const int* sendcounts, const int* displs
   int rank         = simgrid::s4u::this_actor::get_pid();
   int dt_size_send = sendtype->is_replayable() ? 1 : sendtype->size();
 
-  std::vector<int>* trace_sendcounts = new std::vector<int>();
+  auto* trace_sendcounts = new std::vector<int>();
   if (comm->rank() == root) {
     for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
       trace_sendcounts->push_back(sendcounts[i] * dt_size_send);
@@ -576,7 +576,7 @@ int PMPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcoun
 
   smpi_bench_end();
   int rank                           = simgrid::s4u::this_actor::get_pid();
-  std::vector<int>* trace_recvcounts = new std::vector<int>();
+  auto* trace_recvcounts             = new std::vector<int>();
   int dt_send_size                   = datatype->is_replayable() ? 1 : datatype->size();
   int totalcount                     = 0;
 
@@ -624,7 +624,7 @@ int PMPI_Ireduce_scatter_block(const void* sendbuf, void* recvbuf, int recvcount
 
   int rank                           = simgrid::s4u::this_actor::get_pid();
   int dt_send_size                   = datatype->is_replayable() ? 1 : datatype->size();
-  std::vector<int>* trace_recvcounts = new std::vector<int>(recvcount * dt_send_size); // copy data to avoid bad free
+  auto* trace_recvcounts             = new std::vector<int>(recvcount * dt_send_size); // copy data to avoid bad free
   std::unique_ptr<unsigned char[]> tmp_sendbuf;
   const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, recvcount * count, datatype);
 
@@ -633,7 +633,7 @@ int PMPI_Ireduce_scatter_block(const void* sendbuf, void* recvbuf, int recvcount
       new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "reducescatter" : "ireducescatter", -1, 0,
                                         nullptr, -1, trace_recvcounts, simgrid::smpi::Datatype::encode(datatype), ""));
 
-  int* recvcounts = new int[count];
+  auto* recvcounts = new int[count];
   for (int i      = 0; i < count; i++)
     recvcounts[i] = recvcount;
   if (request == MPI_REQUEST_IGNORED)
@@ -733,8 +733,8 @@ int PMPI_Ialltoallv(const void* sendbuf, const int* sendcounts, const int* sendd
   smpi_bench_end();
   int send_size                      = 0;
   int recv_size                      = 0;
-  std::vector<int>* trace_sendcounts = new std::vector<int>();
-  std::vector<int>* trace_recvcounts = new std::vector<int>();
+  auto* trace_sendcounts             = new std::vector<int>();
+  auto* trace_recvcounts             = new std::vector<int>();
   int dt_size_recv                   = recvtype->size();
 
   const int* real_sendcounts = sendcounts;
@@ -824,8 +824,8 @@ int PMPI_Ialltoallw(const void* sendbuf, const int* sendcounts, const int* sendd
 
   int send_size                      = 0;
   int recv_size                      = 0;
-  std::vector<int>* trace_sendcounts = new std::vector<int>();
-  std::vector<int>* trace_recvcounts = new std::vector<int>();
+  auto* trace_sendcounts             = new std::vector<int>();
+  auto* trace_recvcounts             = new std::vector<int>();
 
   const int* real_sendcounts         = sendcounts;
   const int* real_senddispls          = senddispls;
index ddc0a15..eca60b0 100644 (file)
@@ -427,8 +427,8 @@ int PMPI_Sendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, int
     int src_traced         = getPid(comm, src);
 
     // FIXME: Hack the way to trace this one
-    std::vector<int>* dst_hack = new std::vector<int>();
-    std::vector<int>* src_hack = new std::vector<int>();
+    auto* dst_hack = new std::vector<int>();
+    auto* src_hack = new std::vector<int>();
     dst_hack->push_back(dst_traced);
     src_hack->push_back(src_traced);
     TRACE_smpi_comm_in(my_proc_id, __func__,
index 49b1a87..8bf129a 100644 (file)
@@ -136,7 +136,7 @@ int PMPI_Type_create_indexed_block(int count, int blocklength, const int* indice
 {
   CHECK_COUNT(1, count)
   CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
-  int* blocklens=static_cast<int*>(xbt_malloc(blocklength*count*sizeof(int)));
+  auto* blocklens = static_cast<int*>(xbt_malloc(blocklength * count * sizeof(int)));
   for (int i    = 0; i < count; i++)
     blocklens[i]=blocklength;
   int retval    = simgrid::smpi::Datatype::create_indexed(count, blocklens, indices, old_type, new_type);
@@ -161,7 +161,7 @@ int PMPI_Type_create_hindexed_block(int count, int blocklength, const MPI_Aint*
                                     MPI_Datatype* new_type) {
   CHECK_COUNT(1, count)
   CHECK_MPI_NULL(4, MPI_DATATYPE_NULL, MPI_ERR_TYPE, old_type)
-  int* blocklens=(int*)xbt_malloc(blocklength*count*sizeof(int));
+  auto* blocklens = static_cast<int*>(xbt_malloc(blocklength * count * sizeof(int)));
   for (int i     = 0; i < count; i++)
     blocklens[i] = blocklength;
   int retval     = simgrid::smpi::Datatype::create_hindexed(count, blocklens, indices, old_type, new_type);
index 25b9171..2c6139b 100644 (file)
@@ -82,8 +82,8 @@ int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* sta
   MPI_Offset max_offset =
       min_offset +
       count * datatype->get_extent(); // cheating, as we don't care about exact data location, we can skip extent
-  MPI_Offset* min_offsets = new MPI_Offset[size];
-  MPI_Offset* max_offsets = new MPI_Offset[size];
+  auto* min_offsets = new MPI_Offset[size];
+  auto* max_offsets = new MPI_Offset[size];
   simgrid::smpi::colls::allgather(&min_offset, 1, MPI_OFFSET, min_offsets, 1, MPI_OFFSET, comm_);
   simgrid::smpi::colls::allgather(&max_offset, 1, MPI_OFFSET, max_offsets, 1, MPI_OFFSET, comm_);
   MPI_Offset min = min_offset;
@@ -122,10 +122,10 @@ int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* sta
   MPI_Offset my_chunk_start = (max - min + 1) / size * rank;
   MPI_Offset my_chunk_end   = ((max - min + 1) / size * (rank + 1));
   XBT_CDEBUG(smpi_pmpi, "my chunks to read : %lld:%lld", my_chunk_start, my_chunk_end);
-  int* send_sizes = new int[size];
-  int* recv_sizes = new int[size];
-  int* send_disps = new int[size];
-  int* recv_disps = new int[size];
+  auto* send_sizes = new int[size];
+  auto* recv_sizes = new int[size];
+  auto* send_disps = new int[size];
+  auto* recv_disps = new int[size];
   int total_sent  = 0;
   for (int i = 0; i < size; i++) {
     send_sizes[i] = 0;
index 71bcae8..90ac8da 100644 (file)
@@ -64,7 +64,7 @@ class Keyval{
 template <typename T>
 int Keyval::keyval_create(const smpi_copy_fn& copy_fn, const smpi_delete_fn& delete_fn, int* keyval, void* extra_state)
 {
-  smpi_key_elem value = new s_smpi_key_elem_t;
+  auto* value = new s_smpi_key_elem_t;
 
   value->copy_fn=copy_fn;
   value->delete_fn=delete_fn;
index c6f7164..9149ab7 100644 (file)
@@ -176,8 +176,8 @@ double ActorExt::simulated_elapsed() const
 MPI_Comm ActorExt::comm_self()
 {
   if (comm_self_ == MPI_COMM_NULL) {
-    MPI_Group group = new Group(1);
-    comm_self_      = new Comm(group, nullptr);
+    auto* group = new Group(1);
+    comm_self_  = new Comm(group, nullptr);
     group->set_mapping(actor_, 0);
   }
   return comm_self_;
index 0ef90fa..369445d 100644 (file)
@@ -129,7 +129,7 @@ void smpi_bench_end()
   if (not smpi_cfg_papi_events_file().empty()) {
     papi_counter_t& counter_data        = smpi_process()->papi_counters();
     int event_set                       = smpi_process()->papi_event_set();
-    std::vector<long long> event_values = std::vector<long long>(counter_data.size());
+    std::vector<long long> event_values(counter_data.size());
 
     if (PAPI_stop(event_set, &event_values[0]) != PAPI_OK) { // Error
       XBT_CRITICAL("Could not stop PAPI counters.\n");
@@ -162,7 +162,7 @@ void smpi_bench_end()
     const papi_counter_t& counter_data = smpi_process()->papi_counters();
 
     for (auto const& pair : counter_data) {
-      simgrid::instr::VariableType* variable = static_cast<simgrid::instr::VariableType*>(container->type_->by_name(pair.first));
+      auto* variable = static_cast<simgrid::instr::VariableType*>(container->type_->by_name(pair.first));
       variable->set_event(SIMIX_get_clock(), pair.second);
     }
   }
index 6eb504a..306ab9a 100644 (file)
@@ -22,8 +22,8 @@ class Instance {
 public:
   Instance(int max_no_processes, MPI_Comm comm) : size_(max_no_processes), comm_world_(comm)
   {
-    MPI_Group group = new simgrid::smpi::Group(size_);
-    comm_world_     = new simgrid::smpi::Comm(group, nullptr, false, -1);
+    auto* group = new simgrid::smpi::Group(size_);
+    comm_world_ = new simgrid::smpi::Comm(group, nullptr, false, -1);
     //  FIXME : using MPI_Attr_put with MPI_UNIVERSE_SIZE is forbidden and we make it a no-op (which triggers a warning
     //  as MPI_ERR_ARG is returned). Directly calling Comm::attr_put breaks for now, as MPI_UNIVERSE_SIZE,is <0
     //  instance.comm_world->attr_put<simgrid::smpi::Comm>(MPI_UNIVERSE_SIZE, reinterpret_cast<void*>(instance.size));
index 16826b5..c0e43d7 100644 (file)
@@ -262,7 +262,7 @@ static void smpi_init_papi()
       // first. Hence, we start at ++(events.begin())!
       for (Tokenizer::iterator events_it = ++(event_tokens.begin()); events_it != event_tokens.end(); ++events_it) {
         int event_code   = PAPI_NULL;
-        char* event_name = const_cast<char*>((*events_it).c_str());
+        auto* event_name = const_cast<char*>((*events_it).c_str());
         if (PAPI_event_name_to_code(event_name, &event_code) != PAPI_OK) {
           XBT_CRITICAL("Could not find PAPI event '%s'. Skipping.", event_name);
           continue;
@@ -297,7 +297,7 @@ template <typename F>
 static int smpi_run_entry_point(const F& entry_point, const std::string& executable_path, std::vector<std::string> args)
 {
   // copy C strings, we need them writable
-  std::vector<char*>* args4argv = new std::vector<char*>(args.size());
+  auto* args4argv = new std::vector<char*>(args.size());
   std::transform(begin(args), end(args), begin(*args4argv), [](const std::string& s) { return xbt_strdup(s.c_str()); });
 
   // set argv[0] to executable_path
@@ -342,7 +342,7 @@ static int smpi_run_entry_point(const F& entry_point, const std::string& executa
 // TODO, remove the number of functions involved here
 static smpi_entry_point_type smpi_resolve_function(void* handle)
 {
-  smpi_fortran_entry_point_type entry_point_fortran = (smpi_fortran_entry_point_type)dlsym(handle, "user_main_");
+  auto* entry_point_fortran = reinterpret_cast<smpi_fortran_entry_point_type>(dlsym(handle, "user_main_"));
   if (entry_point_fortran != nullptr) {
     return [entry_point_fortran](int, char**) {
       entry_point_fortran();
@@ -350,7 +350,7 @@ static smpi_entry_point_type smpi_resolve_function(void* handle)
     };
   }
 
-  smpi_c_entry_point_type entry_point = (smpi_c_entry_point_type)dlsym(handle, "main");
+  auto* entry_point = reinterpret_cast<smpi_c_entry_point_type>(dlsym(handle, "main"));
   if (entry_point != nullptr) {
     return entry_point;
   }
@@ -379,7 +379,7 @@ static void smpi_copy_file(const std::string& src, const std::string& target, of
 #endif
   // If this point is reached, sendfile() actually is not available.  Copy file by hand.
   const int bufsize = 1024 * 1024 * 4;
-  char* buf         = new char[bufsize];
+  auto* buf         = new char[bufsize];
   while (int got = read(fdin, buf, bufsize)) {
     if (got == -1) {
       xbt_assert(errno == EINTR, "Cannot read from %s", src.c_str());
@@ -404,7 +404,7 @@ static void smpi_copy_file(const std::string& src, const std::string& target, of
 #if not defined(__APPLE__) && not defined(__HAIKU__)
 static int visit_libs(struct dl_phdr_info* info, size_t, void* data)
 {
-  char* libname = (char*)(data);
+  auto* libname    = static_cast<char*>(data);
   const char *path = info->dlpi_name;
   if(strstr(path, libname)){
     strncpy(libname, path, 512);
index 527dd9e..10bb834 100644 (file)
@@ -824,7 +824,7 @@ void smpi_replay_main(int rank, const char* trace_filename)
   unsigned int count_requests = storage[simgrid::s4u::this_actor::get_pid()].size();
   XBT_DEBUG("There are %ud elements in reqq[*]", count_requests);
   if (count_requests > 0) {
-    MPI_Request* requests= new MPI_Request[count_requests];
+    auto* requests = new MPI_Request[count_requests];
     unsigned int i=0;
 
     for (auto const& pair : storage[simgrid::s4u::this_actor::get_pid()].get_store()) {
index b2653ab..c984b99 100644 (file)
@@ -239,7 +239,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     size_t stop_block_offset = ALIGN_DOWN(stop_offset, smpi_shared_malloc_blocksize);
     for (size_t offset = start_block_offset; offset < stop_block_offset; offset += smpi_shared_malloc_blocksize) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block offset %zx", offset);
-      void* pos = (void*)((unsigned long)mem + offset);
+      void* pos       = static_cast<char*>(mem) + offset;
       const void* res = mmap(pos, smpi_shared_malloc_blocksize, PROT_READ | PROT_WRITE, mmap_flag, huge_fd, 0);
       xbt_assert(res == pos, "Could not map folded virtual memory (%s). Do you perhaps need to increase the "
                              "size of the mapped file using --cfg=smpi/shared-malloc-blocksize:newvalue (default 1048576) ? "
@@ -252,7 +252,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
     size_t low_page_stop_offset = (int64_t)start_block_offset < ALIGN_DOWN(stop_offset, PAGE_SIZE) ? start_block_offset : ALIGN_DOWN(stop_offset, PAGE_SIZE);
     if(low_page_start_offset < low_page_stop_offset) {
       XBT_DEBUG("\t\tglobal shared allocation, mmap block start");
-      void* pos = (void*)((unsigned long)mem + low_page_start_offset);
+      void* pos       = static_cast<char*>(mem) + low_page_start_offset;
       const void* res = mmap(pos, low_page_stop_offset - low_page_start_offset, PROT_READ | PROT_WRITE,
                              mmap_base_flag, // not a full huge page
                              smpi_shared_malloc_bogusfile, 0);
@@ -265,7 +265,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
       XBT_DEBUG("\t\tglobal shared allocation, mmap block stop");
       size_t high_page_stop_offset = stop_offset == size ? size : ALIGN_DOWN(stop_offset, PAGE_SIZE);
       if(high_page_stop_offset > stop_block_offset) {
-        void* pos = (void*)((unsigned long)mem + stop_block_offset);
+        void* pos       = static_cast<char*>(mem) + stop_block_offset;
         const void* res = mmap(pos, high_page_stop_offset - stop_block_offset, PROT_READ | PROT_WRITE,
                                mmap_base_flag, // not a full huge page
                                smpi_shared_malloc_bogusfile, 0);
@@ -279,7 +279,7 @@ void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int
 
   shared_metadata_t newmeta;
   //register metadata for memcpy avoidance
-  shared_data_key_type* data = new shared_data_key_type;
+  auto* data             = new shared_data_key_type;
   data->second.fd = -1;
   data->second.count = 1;
   newmeta.size = size;
index d3e4978..e735a36 100644 (file)
@@ -61,7 +61,7 @@ int Comm::dup(MPI_Comm* newcomm){
     // we need to switch as the called function may silently touch global variables
     smpi_switch_data_segment(s4u::Actor::self());
   }
-  MPI_Group cp = new  Group(this->group());
+  auto* cp     = new Group(this->group());
   (*newcomm)   = new  Comm(cp, this->topo());
   int ret      = MPI_SUCCESS;
 
@@ -355,7 +355,7 @@ MPI_Comm Comm::find_intra_comm(int * leader){
     }
   }
   XBT_DEBUG("number of processes deployed on my node : %d", intra_comm_size);
-  MPI_Group group_intra = new  Group(intra_comm_size);
+  auto* group_intra = new Group(intra_comm_size);
   int i = 0;
   for (auto& actor : actor_list) {
     if (this->group()->rank(actor.ciface()) != MPI_UNDEFINED) {
@@ -390,9 +390,8 @@ void Comm::init_smp(){
   // identify neighbors in comm
   MPI_Comm comm_intra = find_intra_comm(&leader);
 
-
-  int* leaders_map = new int[comm_size];
-  int* leader_list = new int[comm_size];
+  auto* leaders_map = new int[comm_size];
+  auto* leader_list = new int[comm_size];
   std::fill_n(leaders_map, comm_size, 0);
   std::fill_n(leader_list, comm_size, -1);
 
@@ -424,7 +423,7 @@ void Comm::init_smp(){
   xbt_assert(leader_group_size > 0);
   std::sort(leader_list, leader_list + leader_group_size);
 
-  MPI_Group leaders_group = new  Group(leader_group_size);
+  auto* leaders_group = new Group(leader_group_size);
 
   MPI_Comm leader_comm = MPI_COMM_NULL;
   if(MPI_COMM_WORLD!=MPI_COMM_UNINITIALIZED && this!=MPI_COMM_WORLD){
index c28c526..68e42ef 100644 (file)
@@ -377,14 +377,14 @@ int Datatype::copy(const void* sendbuf, int sendcount, MPI_Datatype sendtype, vo
 //Default serialization method : memcpy.
 void Datatype::serialize(const void* noncontiguous_buf, void* contiguous_buf, int count)
 {
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  const char* noncontiguous_buf_char = static_cast<const char*>(noncontiguous_buf)+lb_;
+  auto* contiguous_buf_char          = static_cast<char*>(contiguous_buf);
+  const auto* noncontiguous_buf_char = static_cast<const char*>(noncontiguous_buf) + lb_;
   memcpy(contiguous_buf_char, noncontiguous_buf_char, count*size_);
 }
 
 void Datatype::unserialize(const void* contiguous_buf, void *noncontiguous_buf, int count, MPI_Op op){
-  const char* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb_;
+  const auto* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
+  auto* noncontiguous_buf_char    = static_cast<char*>(noncontiguous_buf) + lb_;
   int n=count;
   if(op!=MPI_OP_NULL)
     op->apply( contiguous_buf_char, noncontiguous_buf_char, &n, this);
index 21d04c9..75abfb4 100644 (file)
@@ -43,15 +43,15 @@ int Type_Contiguous::clone(MPI_Datatype* type)
 
 void Type_Contiguous::serialize(const void* noncontiguous_buf, void* contiguous_buf, int count)
 {
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  const char* noncontiguous_buf_char = static_cast<const char*>(noncontiguous_buf)+lb();
+  auto* contiguous_buf_char          = static_cast<char*>(contiguous_buf);
+  const auto* noncontiguous_buf_char = static_cast<const char*>(noncontiguous_buf) + lb();
   memcpy(contiguous_buf_char, noncontiguous_buf_char, count * block_count_ * old_type_->size());
 }
 
 void Type_Contiguous::unserialize(const void* contiguous_buf, void* noncontiguous_buf, int count, MPI_Op op)
 {
-  const char* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+lb();
+  const auto* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
+  auto* noncontiguous_buf_char    = static_cast<char*>(noncontiguous_buf) + lb();
   int n= count*block_count_;
   if(op!=MPI_OP_NULL)
     op->apply( contiguous_buf_char, noncontiguous_buf_char, &n, old_type_);
@@ -75,8 +75,8 @@ int Type_Hvector::clone(MPI_Datatype* type)
 
 void Type_Hvector::serialize(const void* noncontiguous_buf, void *contiguous_buf,
                     int count){
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  const char* noncontiguous_buf_char = static_cast<const char*>(noncontiguous_buf);
+  auto* contiguous_buf_char          = static_cast<char*>(contiguous_buf);
+  const auto* noncontiguous_buf_char = static_cast<const char*>(noncontiguous_buf);
 
   for (int i = 0; i < block_count_ * count; i++) {
     if (not(old_type_->flags() & DT_FLAG_DERIVED))
@@ -94,8 +94,8 @@ void Type_Hvector::serialize(const void* noncontiguous_buf, void *contiguous_buf
 
 void Type_Hvector::unserialize(const void* contiguous_buf, void *noncontiguous_buf,
                               int count, MPI_Op op){
-  const char* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf);
+  const auto* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
+  auto* noncontiguous_buf_char    = static_cast<char*>(noncontiguous_buf);
 
   for (int i = 0; i < block_count_ * count; i++) {
     if (not(old_type_->flags() & DT_FLAG_DERIVED)) {
@@ -135,7 +135,7 @@ Type_Hindexed::Type_Hindexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int
     , block_indices_(new MPI_Aint[count])
     , old_type_(old_type)
 {
-  int* ints = new int[count+1];
+  auto* ints = new int[count + 1];
   ints[0]=count;
   for(int i=1;i<=count;i++)
     ints[i]=block_lengths[i-1];
@@ -181,9 +181,9 @@ Type_Hindexed::~Type_Hindexed()
 
 void Type_Hindexed::serialize(const void* noncontiguous_buf, void *contiguous_buf,
                 int count){
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  const char* noncontiguous_buf_iter = static_cast<const char*>(noncontiguous_buf);
-  const char* noncontiguous_buf_char = noncontiguous_buf_iter + block_indices_[0];
+  auto* contiguous_buf_char          = static_cast<char*>(contiguous_buf);
+  const auto* noncontiguous_buf_iter = static_cast<const char*>(noncontiguous_buf);
+  const auto* noncontiguous_buf_char = noncontiguous_buf_iter + block_indices_[0];
   for (int j = 0; j < count; j++) {
     for (int i = 0; i < block_count_; i++) {
       if (not(old_type_->flags() & DT_FLAG_DERIVED))
@@ -203,8 +203,8 @@ void Type_Hindexed::serialize(const void* noncontiguous_buf, void *contiguous_bu
 
 void Type_Hindexed::unserialize(const void* contiguous_buf, void *noncontiguous_buf,
                           int count, MPI_Op op){
-  const char* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+ block_indices_[0];
+  const auto* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
+  auto* noncontiguous_buf_char    = static_cast<char*>(noncontiguous_buf) + block_indices_[0];
   for (int j = 0; j < count; j++) {
     for (int i = 0; i < block_count_; i++) {
       if (not(old_type_->flags() & DT_FLAG_DERIVED)) {
@@ -229,7 +229,7 @@ Type_Indexed::Type_Indexed(int size, MPI_Aint lb, MPI_Aint ub, int flags, int co
     : Type_Hindexed(size, lb, ub, flags, count, block_lengths, block_indices, old_type, old_type->get_extent())
 {
   delete contents_;
-  int* ints = new int[2*count+1];
+  auto* ints = new int[2 * count + 1];
   ints[0]=count;
   for(int i=1;i<=count;i++)
     ints[i]=block_lengths[i-1];
@@ -254,7 +254,7 @@ Type_Struct::Type_Struct(int size, MPI_Aint lb, MPI_Aint ub, int flags, int coun
     , block_indices_(new MPI_Aint[count])
     , old_types_(new MPI_Datatype[count])
 {
-  int* ints = new int[count+1];
+  auto* ints = new int[count + 1];
   ints[0]=count;
   for(int i=1;i<=count;i++)
     ints[i]=block_lengths[i-1];
@@ -288,9 +288,9 @@ int Type_Struct::clone(MPI_Datatype* type)
 
 void Type_Struct::serialize(const void* noncontiguous_buf, void *contiguous_buf,
                         int count){
-  char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
-  const char* noncontiguous_buf_iter = static_cast<const char*>(noncontiguous_buf);
-  const char* noncontiguous_buf_char = noncontiguous_buf_iter + block_indices_[0];
+  auto* contiguous_buf_char          = static_cast<char*>(contiguous_buf);
+  const auto* noncontiguous_buf_iter = static_cast<const char*>(noncontiguous_buf);
+  const auto* noncontiguous_buf_char = noncontiguous_buf_iter + block_indices_[0];
   for (int j = 0; j < count; j++) {
     for (int i = 0; i < block_count_; i++) {
       if (not(old_types_[i]->flags() & DT_FLAG_DERIVED))
@@ -311,8 +311,8 @@ void Type_Struct::serialize(const void* noncontiguous_buf, void *contiguous_buf,
 
 void Type_Struct::unserialize(const void* contiguous_buf, void *noncontiguous_buf,
                               int count, MPI_Op op){
-  const char* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
-  char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf)+ block_indices_[0];
+  const auto* contiguous_buf_char = static_cast<const char*>(contiguous_buf);
+  auto* noncontiguous_buf_char    = static_cast<char*>(noncontiguous_buf) + block_indices_[0];
   for (int j = 0; j < count; j++) {
     for (int i = 0; i < block_count_; i++) {
       if (not(old_types_[i]->flags() & DT_FLAG_DERIVED)) {
index 872d9a7..bccba0d 100644 (file)
@@ -98,7 +98,7 @@ namespace smpi{
   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);
+    auto* f = new File(MPI_COMM_SELF, filename, MPI_MODE_DELETE_ON_CLOSE | MPI_MODE_RDWR, nullptr);
     close(&f);
     return MPI_SUCCESS;
   }
index 37b2a22..dceefb9 100644 (file)
@@ -207,7 +207,7 @@ int Group::excl(int n, const int *ranks, MPI_Group * newgroup){
   int oldsize = size_;
   int newsize = oldsize - n;
   *newgroup = new  Group(newsize);
-  int* to_exclude = new int[size_];
+  auto* to_exclude = new int[size_];
   for (int i     = 0; i < oldsize; i++)
     to_exclude[i]=0;
   for (int i            = 0; i < n; i++)
index 2bc696f..99badd8 100644 (file)
@@ -153,15 +153,15 @@ void Request::init_buffer(int count){
 
 bool Request::match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl*)
 {
-  MPI_Request ref = static_cast<MPI_Request>(a);
-  MPI_Request req = static_cast<MPI_Request>(b);
+  auto ref = static_cast<MPI_Request>(a);
+  auto req = static_cast<MPI_Request>(b);
   return match_common(req, req, ref);
 }
 
 bool Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl*)
 {
-  MPI_Request ref = static_cast<MPI_Request>(a);
-  MPI_Request req = static_cast<MPI_Request>(b);
+  auto ref = static_cast<MPI_Request>(a);
+  auto req = static_cast<MPI_Request>(b);
   return match_common(req, ref, req);
 }
 
@@ -766,9 +766,9 @@ void Request::iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status*
   static int nsleeps = 1;
   double speed        = s4u::this_actor::get_host()->get_speed();
   double maxrate      = smpi_cfg_iprobe_cpu_usage();
-  MPI_Request request = new Request(nullptr, 0, MPI_CHAR,
-                                    source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(source)->get_pid(),
-                                    simgrid::s4u::this_actor::get_pid(), tag, comm, MPI_REQ_PERSISTENT | MPI_REQ_RECV);
+  auto request        = new Request(nullptr, 0, MPI_CHAR,
+                             source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : comm->group()->actor(source)->get_pid(),
+                             simgrid::s4u::this_actor::get_pid(), tag, comm, MPI_REQ_PERSISTENT | MPI_REQ_RECV);
   if (smpi_iprobe_sleep > 0) {
     /** Compute the number of flops we will sleep **/
     s4u::this_actor::exec_init(/*nsleeps: See comment above */ nsleeps *
index e25a214..425a479 100644 (file)
@@ -78,8 +78,8 @@ Topo_Cart::Topo_Cart(MPI_Comm comm_old, int ndims, const int dims[], const int p
   } else {
     if(comm_cart != nullptr){
       if (rank == 0) {
-        MPI_Group group = new Group(MPI_COMM_SELF->group());
-        *comm_cart      = new Comm(group, std::shared_ptr<Topo>(this));
+        auto* group = new Group(MPI_COMM_SELF->group());
+        *comm_cart  = new Comm(group, std::shared_ptr<Topo>(this));
       } else {
         *comm_cart = MPI_COMM_NULL;
       }
@@ -131,8 +131,8 @@ Topo_Cart* Topo_Cart::sub(const int remain_dims[], MPI_Comm *newcomm) {
     res = new Topo_Cart(getComm(), newNDims, newDims, newPeriodic, 0, newcomm);
   } else {
     *newcomm = getComm()->split(color, getComm()->rank());
-    res = new Topo_Cart(getComm(), newNDims, newDims, newPeriodic, 0, nullptr);
-    std::shared_ptr<Topo> topo=std::shared_ptr<Topo>(res);
+    auto topo = std::make_shared<Topo_Cart>(getComm(), newNDims, newDims, newPeriodic, 0, nullptr);
+    res       = topo.get();
     res->setComm(*newcomm);
     (*newcomm)->set_topo(topo);
   }
@@ -207,7 +207,7 @@ int Topo_Cart::shift(int direction, int disp, int* rank_source, int* rank_dest)
     return MPI_ERR_DIMS;
   }
 
-  int* position = new int[ndims_];
+  auto* position = new int[ndims_];
   this->coords(getComm()->rank(), ndims_, position);
   position[direction] += disp;
 
@@ -360,7 +360,7 @@ static int assignnodes(int ndim, int nfactor, const int* pfacts, int** pdims)
   }
 
   /* Allocate and initialize the bins */
-  int *bins = new int[ndim];
+  auto* bins = new int[ndim];
 
   *pdims = bins;
   int *p = bins;
index 456905c..390f78e 100644 (file)
@@ -228,7 +228,7 @@ int Win::put(const void *origin_addr, int origin_count, MPI_Datatype origin_data
   if(target_count*target_datatype->get_extent()>recv_win->size_)
     return MPI_ERR_ARG;
 
-  void* recv_addr = static_cast<void*> ( static_cast<char*>(recv_win->base_) + target_disp * recv_win->disp_unit_);
+  void* recv_addr = static_cast<char*>(recv_win->base_) + target_disp * recv_win->disp_unit_;
 
   if (target_rank != comm_->rank()) { // This is not for myself, so we need to send messages
     XBT_DEBUG("Entering MPI_Put to remote rank %d", target_rank);
@@ -348,7 +348,7 @@ int Win::accumulate(const void *origin_addr, int origin_count, MPI_Datatype orig
   if(target_count*target_datatype->get_extent()>recv_win->size_)
     return MPI_ERR_ARG;
 
-  void* recv_addr = static_cast<void*>(static_cast<char*>(recv_win->base_) + target_disp * recv_win->disp_unit_);
+  void* recv_addr = static_cast<char*>(recv_win->base_) + target_disp * recv_win->disp_unit_;
   XBT_DEBUG("Entering MPI_Accumulate to %d", target_rank);
   // As the tag will be used for ordering of the operations, subtract count from it (to avoid collisions with other
   // SMPI tags, SMPI_RMA_TAG is set below all the other ones we use)
index 4245c78..d6ea5b0 100644 (file)
@@ -38,8 +38,7 @@ void TRACE_migration_call(int rank, simgrid::instr::TIData* extra)
   if(smpi_process()->replaying()) {//When replaying, we register an event.
     smpi_container(rank)->get_state("MIGRATE_STATE")->add_entity_value(operation);
 
-    simgrid::instr::EventType* type =
-      static_cast<simgrid::instr::EventType*>(smpi_container(rank)->type_->by_name(operation));
+    auto* type = static_cast<simgrid::instr::EventType*>(smpi_container(rank)->type_->by_name(operation));
     new simgrid::instr::NewEvent(smpi_process()->simulated_elapsed(), smpi_container(rank), type,
                                  type->get_entity_value(operation));
   } else {