Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce scope for variables.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 20 Oct 2019 19:04:05 +0000 (21:04 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 20 Oct 2019 20:53:14 +0000 (22:53 +0200)
examples/deprecated/simdag/scheduling/sd_scheduling.c
src/mc/checker/CommunicationDeterminismChecker.cpp
src/smpi/bindings/smpi_pmpi_request.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_replay.cpp
src/smpi/mpi/smpi_group.cpp
src/smpi/mpi/smpi_request.cpp
src/surf/surf_c_bindings.cpp

index 17972b6..c7cd717 100644 (file)
@@ -72,7 +72,6 @@ static double finish_on_at(SD_task_t task, sg_host_t host)
   if (!xbt_dynar_is_empty(parents)) {
     unsigned int i;
     double data_available = 0.;
-    double redist_time    = 0;
     double last_data_available;
     /* compute last_data_available */
     SD_task_t parent;
@@ -82,6 +81,7 @@ static double finish_on_at(SD_task_t task, sg_host_t host)
       if (SD_task_get_kind(parent) == SD_TASK_COMM_E2E) {
         sg_host_t * parent_host= SD_task_get_workstation_list(parent);
         /* Estimate the redistribution time from this parent */
+        double redist_time;
         if (SD_task_get_amount(parent) <= 1e-6){
           redist_time= 0;
         } else {
index 1302502..bc2e642 100644 (file)
@@ -119,9 +119,8 @@ namespace mc {
 void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, simgrid::mc::PatternCommunication* comm,
                                                                  int backtracking)
 {
-  simgrid::mc::PatternCommunicationList& list = initial_communications_pattern[process];
-
   if (not backtracking) {
+    simgrid::mc::PatternCommunicationList& list = initial_communications_pattern[process];
     e_mc_comm_pattern_difference_t diff = compare_comm_pattern(list.list[list.index_comm].get(), comm);
 
     if (diff != NONE_DIFF) {
index 7d1f2b0..f64dbab 100644 (file)
@@ -145,10 +145,9 @@ int PMPI_Startall(int count, MPI_Request * requests)
     if(retval != MPI_ERR_REQUEST) {
       int my_proc_id = simgrid::s4u::this_actor::get_pid();
       TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Startall"));
-      MPI_Request req = MPI_REQUEST_NULL;
       if (not TRACE_smpi_view_internals())
         for (int i = 0; i < count; i++) {
-          req = requests[i];
+          MPI_Request req = requests[i];
           if (req->flags() & MPI_REQ_SEND)
             TRACE_smpi_send(my_proc_id, my_proc_id, getPid(req->comm(), req->dst()), req->tag(), req->size());
         }
@@ -157,7 +156,7 @@ int PMPI_Startall(int count, MPI_Request * requests)
 
       if (not TRACE_smpi_view_internals())
         for (int i = 0; i < count; i++) {
-          req = requests[i];
+          MPI_Request req = requests[i];
           if (req->flags() & MPI_REQ_RECV)
             TRACE_smpi_recv(getPid(req->comm(), req->src()), my_proc_id, req->tag());
         }
index a38dd6e..6380f77 100644 (file)
@@ -352,12 +352,12 @@ void smpi_sample_1(int global, const char *file, int line, int iters, double thr
                                          0,         // count
                                          true       // benching (if we have no data, we need at least one)
                                      });
-  LocalData& data = insert.first->second;
   if (insert.second) {
     XBT_DEBUG("XXXXX First time ever on benched nest %s.", loc.c_str());
     xbt_assert(threshold > 0 || iters > 0,
         "You should provide either a positive amount of iterations to bench, or a positive maximal stderr (or both)");
   } else {
+    LocalData& data = insert.first->second;
     if (data.iters != iters || data.threshold != threshold) {
       XBT_ERROR("Asked to bench block %s with different settings %d, %f is not %d, %f. "
                 "How did you manage to give two numbers at the same line??",
@@ -449,12 +449,12 @@ int smpi_sample_exit(int global, const char *file, int line, int iter_count){
     auto sample = samples.find(loc);
     if (sample == samples.end())
       xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
-    LocalData& data = sample->second;
   
     if (smpi_process()->sampling()){//end of loop, but still sampling needed
-        smpi_process()->set_sampling(0);
-        smpi_execute(data.mean*iter_count);
-        smpi_bench_begin();
+      LocalData& data = sample->second;
+      smpi_process()->set_sampling(0);
+      smpi_execute(data.mean * iter_count);
+      smpi_bench_begin();
     }
   }
   return 0;
index 93114a3..2af987f 100644 (file)
@@ -273,13 +273,12 @@ void GatherVArgParser::parse(simgrid::xbt::ReplayAction& action, const std::stri
     if (action.size() > 5 + comm_size)
       datatype2 = simgrid::smpi::Datatype::decode(action[5 + comm_size]);
   } else {
-    int datatype_index = 0;
     int disp_index     = 0;
     /* The 3 comes from "0 gather <sendcount>", which must always be present.
      * The + comm_size is the recvcounts array, which must also be present
      */
     if (action.size() > 3 + comm_size + comm_size) { /* datatype + disp are specified */
-      datatype_index = 3 + comm_size;
+      int datatype_index = 3 + comm_size;
       disp_index     = datatype_index + 1;
       datatype1      = simgrid::smpi::Datatype::decode(action[datatype_index]);
       datatype2      = simgrid::smpi::Datatype::decode(action[datatype_index]);
@@ -287,7 +286,7 @@ void GatherVArgParser::parse(simgrid::xbt::ReplayAction& action, const std::stri
                3 + comm_size + 2) { /* disps specified; datatype is not specified; use the default one */
       disp_index = 3 + comm_size;
     } else if (action.size() > 3 + comm_size) { /* only datatype, no disp specified */
-      datatype_index = 3 + comm_size;
+      int datatype_index = 3 + comm_size;
       datatype1      = simgrid::smpi::Datatype::decode(action[datatype_index]);
       datatype2      = simgrid::smpi::Datatype::decode(action[datatype_index]);
     }
index cbd973a..fb70b84 100644 (file)
@@ -106,7 +106,6 @@ int Group::compare(MPI_Group group2)
 
 int Group::incl(int n, const int* ranks, MPI_Group* newgroup)
 {
-  int i=0;
   if (n == 0) {
     *newgroup = MPI_GROUP_EMPTY;
   } else if (n == size_) {
@@ -115,7 +114,7 @@ int Group::incl(int n, const int* ranks, MPI_Group* newgroup)
       this->ref();
   } else {
     *newgroup = new Group(n);
-    for (i = 0; i < n; i++) {
+    for (int i = 0; i < n; i++) {
       s4u::Actor* actor = this->actor(ranks[i]); // ranks[] was passed as a param!
       (*newgroup)->set_mapping(actor, i);
     }
index 2a70952..0ec24c8 100644 (file)
@@ -722,11 +722,10 @@ int Request::testall(int count, MPI_Request requests[], int* outflag, MPI_Status
   MPI_Status *pstat = status == MPI_STATUSES_IGNORE ? MPI_STATUS_IGNORE : &stat;
   int flag;
   int error = 0;
-  int ret=MPI_SUCCESS;
   *outflag = 1;
   for(int i=0; i<count; i++){
     if (requests[i] != MPI_REQUEST_NULL && not(requests[i]->flags_ & MPI_REQ_PREPARED)) {
-      ret = test(&requests[i], pstat, &flag);
+      int ret = test(&requests[i], pstat, &flag);
       if (flag){
         flag=0;
         requests[i]=MPI_REQUEST_NULL;
index 588764b..f111cc2 100644 (file)
@@ -46,7 +46,6 @@ void surf_presolve()
 double surf_solve(double max_date)
 {
   double time_delta = -1.0; /* duration */
-  double model_next_action_end = -1.0;
   double value = -1.0;
   simgrid::kernel::resource::Resource* resource = nullptr;
   simgrid::kernel::profile::Event* event        = nullptr;
@@ -96,7 +95,7 @@ double surf_solve(double max_date)
 
       XBT_DEBUG("Run the NS3 network at most %fs", time_delta);
       // run until min or next flow
-      model_next_action_end = surf_network_model->next_occurring_event(time_delta);
+      double model_next_action_end = surf_network_model->next_occurring_event(time_delta);
 
       XBT_DEBUG("Min for network : %f", model_next_action_end);
       if (model_next_action_end >= 0.0)