Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Friday smell chase
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 17 Feb 2017 14:08:24 +0000 (15:08 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 17 Feb 2017 14:08:24 +0000 (15:08 +0100)
12 files changed:
src/bindings/java/jmsg_task.cpp
src/kernel/routing/ClusterZone.cpp
src/kernel/routing/DijkstraZone.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/RoutedZone.cpp
src/kernel/routing/TorusZone.cpp
src/msg/msg_vm.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/simix/libsmx.cpp
src/simix/smx_environment.cpp
src/simix/smx_global.cpp
src/surf/cpu_ti.cpp

index 844433c..cd4a262 100644 (file)
@@ -70,12 +70,12 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_create(JNIEnv * env, jobject jt
   const char *name = nullptr;      /* the name of the task                                 */
 
   if (jflopsAmount < 0) {
-    jxbt_throw_illegal(env, bprintf("Task flopsAmount (%f) cannot be negative", (double) jflopsAmount));
+    jxbt_throw_illegal(env, bprintf("Task flopsAmount (%f) cannot be negative", static_cast<double>(jflopsAmount)));
     return;
   }
 
   if (jbytesAmount < 0) {
-    jxbt_throw_illegal(env, bprintf("Task bytesAmount (%f) cannot be negative", (double) jbytesAmount));
+    jxbt_throw_illegal(env, bprintf("Task bytesAmount (%f) cannot be negative", static_cast<double>(jbytesAmount)));
     return;
   }
 
@@ -85,7 +85,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_create(JNIEnv * env, jobject jt
   }
 
   /* create the task */
-  task = MSG_task_create(name, (double) jflopsAmount, (double) jbytesAmount, nullptr);
+  task = MSG_task_create(name, static_cast<double>(jflopsAmount), static_cast<double>(jbytesAmount), nullptr);
   if (jname)
     env->ReleaseStringUTFChars(jname, name);
   /* sets the task name */
@@ -125,7 +125,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_parallelCreate(JNIEnv * env, jo
     return;
   }
 
-  host_count = (int) env->GetArrayLength(jhosts);
+  host_count = static_cast<int>(env->GetArrayLength(jhosts));
 
   hosts = xbt_new0(msg_host_t, host_count);
   computeDurations = xbt_new0(double, host_count);
@@ -289,7 +289,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setPriority(JNIEnv * env, jobje
     jxbt_throw_notbound(env, "task", jtask);
     return;
   }
-  MSG_task_set_priority(task, (double) priority);
+  MSG_task_set_priority(task, static_cast<double>(priority));
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setFlopsAmount (JNIEnv *env, jobject jtask, jdouble computationAmount)
@@ -300,7 +300,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setFlopsAmount (JNIEnv *env, jo
     jxbt_throw_notbound(env, "task", jtask);
     return;
   }
-  MSG_task_set_flops_amount(task, (double) computationAmount);
+  MSG_task_set_flops_amount(task, static_cast<double>(computationAmount));
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBytesAmount (JNIEnv *env, jobject jtask, jdouble dataSize)
@@ -312,7 +312,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBytesAmount (JNIEnv *env, jo
     return;
   }
   env->SetDoubleField(jtask, jtask_field_Task_messageSize, dataSize);
-  MSG_task_set_bytes_amount(task, (double) dataSize);
+  MSG_task_set_bytes_amount(task, static_cast<double>(dataSize));
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_send(JNIEnv * env,jobject jtask, jstring jalias, jdouble jtimeout)
@@ -330,7 +330,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_send(JNIEnv * env,jobject jtask
 
   /* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
   MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
-  rv = MSG_task_send_with_timeout(task, alias, (double) jtimeout);
+  rv = MSG_task_send_with_timeout(task, alias, static_cast<double>(jtimeout));
   env->ReleaseStringUTFChars(jalias, alias);
 
   if (rv != MSG_OK) {
@@ -354,7 +354,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_sendBounded(JNIEnv * env,jobjec
 
   /* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
   MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
-  rv = MSG_task_send_with_timeout_bounded(task, alias, (double) jtimeout, (double) maxrate);
+  rv = MSG_task_send_with_timeout_bounded(task, alias, static_cast<double>(jtimeout), static_cast<double>(maxrate));
   env->ReleaseStringUTFChars(jalias, alias);
 
   if (rv != MSG_OK) {
@@ -366,9 +366,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv * env, jclass
                                                             jobject jhost)
 {
   msg_task_t task = nullptr;
-
   msg_host_t host = nullptr;
-  jobject jtask_global, jtask_local;
 
   if (jhost) {
     host = jhost_get_native(env, jhost);
@@ -387,10 +385,10 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receive(JNIEnv * env, jclass
     jmsg_throw_status(env,rv);
     return nullptr;
   }
-  jtask_global = (jobject) MSG_task_get_data(task);
+  jobject jtask_global = (jobject) MSG_task_get_data(task);
 
   /* Convert the global ref into a local ref so that the JVM can free the stuff */
-  jtask_local = env->NewLocalRef(jtask_global);
+  jobject jtask_local = env->NewLocalRef(jtask_global);
   env->DeleteGlobalRef(jtask_global);
   MSG_task_set_data(task, nullptr);
 
@@ -434,8 +432,6 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv * env,
   *task = nullptr;
 
   msg_host_t host = nullptr;
-  jobject jtask_global, jtask_local;
-  const char *alias;
 
   if (jhost) {
     host = jhost_get_native(env, jhost);
@@ -446,18 +442,18 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv * env,
     }
   }
 
-  alias = env->GetStringUTFChars(jalias, 0);
-  rv = MSG_task_receive_ext_bounded(task, alias, (double) jtimeout, host, (double) rate);
+  const char *alias = env->GetStringUTFChars(jalias, 0);
+  rv = MSG_task_receive_ext_bounded(task, alias, static_cast<double>(jtimeout), host, static_cast<double>(rate));
   if (env->ExceptionOccurred())
     return nullptr;
   if (rv != MSG_OK) {
     jmsg_throw_status(env,rv);
     return nullptr;
   }
-  jtask_global = (jobject) MSG_task_get_data(*task);
+  jobject jtask_global = (jobject) MSG_task_get_data(*task);
 
   /* Convert the global ref into a local ref so that the JVM can free the stuff */
-  jtask_local = env->NewLocalRef(jtask_global);
+  jobject jtask_local = env->NewLocalRef(jtask_global);
   env->DeleteGlobalRef(jtask_global);
   MSG_task_set_data(*task, nullptr);
 
@@ -485,7 +481,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecvBounded(JNIEnv * env, j
   }
 
   const char* mailbox = env->GetStringUTFChars(jmailbox, 0);
-  msg_comm_t comm     = MSG_task_irecv_bounded(task, mailbox, (double)rate);
+  msg_comm_t comm     = MSG_task_irecv_bounded(task, mailbox, static_cast<double>(rate));
   env->ReleaseStringUTFChars(jmailbox, mailbox);
 
   env->SetLongField(jcomm, jtask_field_Comm_bind, (jlong) (uintptr_t)(comm));
@@ -620,18 +616,15 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_dsendBounded(JNIEnv * env, jobj
 
   /* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
   MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
-  MSG_task_dsend_bounded(task, alias, msg_task_cancel_on_failed_dsend,(double)maxrate);
+  MSG_task_dsend_bounded(task, alias, msg_task_cancel_on_failed_dsend,static_cast<double>(maxrate));
 
   env->ReleaseStringUTFChars(jalias, alias);
 }
 
 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Task_listen(JNIEnv * env, jclass cls, jstring jalias)
 {
-  const char *alias;
-  int rv;
-
-  alias = env->GetStringUTFChars(jalias, 0);
-  rv = MSG_task_listen(alias);
+  const char *alias = env->GetStringUTFChars(jalias, 0);
+  int rv = MSG_task_listen(alias);
   env->ReleaseStringUTFChars(jalias, alias);
 
   return (jboolean) rv;
@@ -639,9 +632,8 @@ JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Task_listen(JNIEnv * env, jclass
 
 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Task_listenFrom(JNIEnv * env, jclass cls, jstring jalias)
 {
-  int rv;
   const char *alias = env->GetStringUTFChars(jalias, 0);
-  rv = MSG_task_listen_from(alias);
+  int rv = MSG_task_listen_from(alias);
   env->ReleaseStringUTFChars(jalias, alias);
 
   return (jint) rv;
index 97edfcc..19cd4e9 100644 (file)
@@ -131,7 +131,8 @@ void ClusterZone::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id
   link.policy    = cluster->sharing_policy;
   sg_platf_new_link(&link);
 
-  surf::LinkImpl *linkUp, *linkDown;
+  surf::LinkImpl *linkUp;
+  surf::LinkImpl *linkDown;
   if (link.policy == SURF_LINK_FULLDUPLEX) {
     char* tmp_link = bprintf("%s_UP", link_id);
     linkUp         = surf::LinkImpl::byName(tmp_link);
index b376601..d0e07ee 100644 (file)
@@ -45,7 +45,8 @@ namespace routing {
 void DijkstraZone::seal()
 {
   xbt_node_t node = nullptr;
-  unsigned int cursor2, cursor;
+  unsigned int cursor2;
+  unsigned int cursor;
 
   /* Create the topology graph */
   if (!routeGraph_)
@@ -86,16 +87,12 @@ void DijkstraZone::seal()
 
 xbt_node_t DijkstraZone::routeGraphNewNode(int id, int graph_id)
 {
-  xbt_node_t node              = nullptr;
-  graph_node_data_t data       = nullptr;
-  graph_node_map_element_t elm = nullptr;
-
-  data           = xbt_new0(struct graph_node_data, 1);
+  graph_node_data_t data         = xbt_new0(struct graph_node_data, 1);
   data->id       = id;
   data->graph_id = graph_id;
-  node           = xbt_graph_new_node(routeGraph_, data);
 
-  elm       = xbt_new0(struct graph_node_map_element, 1);
+  xbt_node_t node                = xbt_graph_new_node(routeGraph_, data);
+  graph_node_map_element_t elm   = xbt_new0(struct graph_node_map_element, 1);
   elm->node = node;
   xbt_dict_set_ext(graphNodeMap_, (char*)(&id), sizeof(int), (xbt_dictelm_t)elm, nullptr);
 
@@ -209,7 +206,7 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
 
     /* apply dijkstra using the indexes from the graph's node array */
     while (xbt_heap_size(pqueue) > 0) {
-      int* v_id         = (int*)xbt_heap_pop(pqueue);
+      int* v_id         = static_cast<int*>(xbt_heap_pop(pqueue));
       xbt_node_t v_node = xbt_dynar_get_as(nodes, *v_id, xbt_node_t);
       xbt_edge_t edge   = nullptr;
       unsigned int cursor;
@@ -239,7 +236,10 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
   }
 
   /* compose route path with links */
-  NetPoint *gw_src = nullptr, *gw_dst, *prev_gw_src, *first_gw = nullptr;
+  NetPoint *gw_src = nullptr;
+  NetPoint *gw_dst;
+  NetPoint *prev_gw_src;
+  NetPoint *first_gw = nullptr;
   NetPoint *gw_dst_net_elm = nullptr, *prev_gw_src_net_elm = nullptr;
 
   for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
index 90c4828..efbfb1c 100644 (file)
@@ -315,7 +315,9 @@ void NetZoneImpl::getGlobalRoute(routing::NetPoint* src, routing::NetPoint* dst,
   XBT_DEBUG("Resolve route from '%s' to '%s'", src->cname(), dst->cname());
 
   /* Find how src and dst are interconnected */
-  NetZoneImpl *common_ancestor, *src_ancestor, *dst_ancestor;
+  NetZoneImpl *common_ancestor;
+  NetZoneImpl *src_ancestor;
+  NetZoneImpl *dst_ancestor;
   find_common_ancestors(src, dst, &common_ancestor, &src_ancestor, &dst_ancestor);
   XBT_DEBUG("elements_father: common ancestor '%s' src ancestor '%s' dst ancestor '%s'", common_ancestor->name(),
             src_ancestor->name(), dst_ancestor->name());
index 1d0207b..9f846b5 100644 (file)
@@ -88,8 +88,10 @@ void RoutedZone::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 
       XBT_DEBUG("get_route_and_latency %s -> %s", my_src->cname(), my_dst->cname());
 
-      xbt_node_t current, previous;
-      const char *previous_name, *current_name;
+      xbt_node_t current;
+      xbt_node_t previous;
+      const char *previous_name;
+      const char *current_name;
 
       if (route->gw_src) {
         previous      = new_xbt_graph_node(graph, route->gw_src->cname(), nodes);
index b2c1896..f632e6e 100644 (file)
@@ -12,9 +12,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster_torus, surf_route_cluster, "T
 inline unsigned int* rankId_to_coords(int rankId, xbt_dynar_t dimensions)
 {
 
-  unsigned int i = 0, cur_dim_size = 1, dim_size_product = 1;
+  unsigned int cur_dim_size = 1;
+  unsigned int dim_size_product = 1;
   unsigned int* coords = (unsigned int*)malloc(xbt_dynar_length(dimensions) * sizeof(unsigned int));
-  for (i = 0; i < xbt_dynar_length(dimensions); i++) {
+  for (unsigned int i = 0; i < xbt_dynar_length(dimensions); i++) {
     cur_dim_size = xbt_dynar_get_as(dimensions, i, int);
     coords[i]    = (rankId / dim_size_product) % cur_dim_size;
     dim_size_product *= cur_dim_size;
@@ -41,16 +42,16 @@ void TorusZone::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id,
    * Each rank creates @a dimensions-1 links
    */
   int neighbor_rank_id  = 0; // The other node the link connects
-  int current_dimension = 0, // which dimension are we currently in?
+  int current_dimension = 0; // which dimension are we currently in?
       // we need to iterate over all dimensions
       // and create all links there
-      dim_product = 1; // Needed to calculate the next neighbor_id
+  int dim_product = 1; // Needed to calculate the next neighbor_id
   for (unsigned int j = 0; j < xbt_dynar_length(dimensions_); j++) {
 
     s_sg_platf_link_cbarg_t link;
     memset(&link, 0, sizeof(link));
     current_dimension = xbt_dynar_get_as(dimensions_, j, int);
-    neighbor_rank_id  = (((int)rank / dim_product) % current_dimension == current_dimension - 1)
+    neighbor_rank_id  = ((static_cast<int>(rank) / dim_product) % current_dimension == current_dimension - 1)
                            ? rank - (current_dimension - 1) * dim_product
                            : rank + dim_product;
     // name of neighbor is not right for non contiguous cluster radicals (as id != rank in this case)
@@ -131,7 +132,8 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
    * Dimension based routing routes through each dimension consecutively
    * TODO Change to dynamic assignment
    */
-  unsigned int j, cur_dim, dim_product = 1;
+  unsigned int cur_dim;
+  unsigned int dim_product = 1;
   unsigned int current_node = src->id();
   unsigned int next_node    = 0;
   /*
@@ -156,7 +158,7 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
   // false means: next -> cur
   while (current_node != dst->id()) {
     dim_product = 1; // First, we will route in x-dimension
-    for (j = 0; j < xbt_dynar_length(dimensions_); j++) {
+    for (unsigned int j = 0; j < xbt_dynar_length(dimensions_); j++) {
       cur_dim = xbt_dynar_get_as(dimensions_, j, int);
 
       // current_node/dim_product = position in current dimension
index 6d1d5c3..e1f2576 100644 (file)
@@ -106,18 +106,18 @@ msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int ramsize, int mig_net
 
   /* For the moment, intensity_rate is the percentage against the migration bandwidth */
   double host_speed = MSG_host_get_speed(pm);
-  double update_speed = ((double)dp_intensity/100) * mig_netspeed;
+  double update_speed = (static_cast<double>(dp_intensity)/100) * mig_netspeed;
 
   msg_vm_t vm = MSG_vm_create_core(pm, name);
   s_vm_params_t params;
   memset(&params, 0, sizeof(params));
-  params.ramsize = (sg_size_t)ramsize * 1024 * 1024;
+  params.ramsize = static_cast<sg_size_t>(ramsize) * 1024 * 1024;
   params.devsize = 0;
   params.skip_stage2 = 0;
   params.max_downtime = 0.03;
   params.dp_rate = (update_speed * 1024 * 1024) / host_speed;
   params.dp_cap = params.ramsize * 0.9; // assume working set memory is 90% of ramsize
-  params.mig_speed = (double)mig_netspeed * 1024 * 1024; // mig_speed
+  params.mig_speed = static_cast<double>(mig_netspeed) * 1024 * 1024; // mig_speed
 
   XBT_DEBUG("dp rate %f migspeed : %f intensity mem : %d, updatespeed %f, hostspeed %f", params.dp_rate,
             params.mig_speed, dp_intensity, update_speed, host_speed);
@@ -303,52 +303,51 @@ static int migration_rx_fun(int argc, char *argv[])
     vm->pimpl_vm_->resume();
   });
 
-  {
-    // Now the VM is running on the new host (the migration is completed) (even if the SRC crash)
-    vm->pimpl_vm_->isMigrating = false;
-    XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)", ms->vm->cname(), ms->src_pm->cname(), ms->dst_pm->cname());
-
-    if (TRACE_msg_vm_is_enabled()) {
-      static long long int counter = 0;
-      char key[INSTR_DEFAULT_STR_SIZE];
-      snprintf(key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++);
-
-      // start link
-      container_t msg = PJ_container_get(vm->cname());
-      type_t type     = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
-      new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
-
-      // destroy existing container of this vm
-      container_t existing_container = PJ_container_get(vm->cname());
-      PJ_container_remove_from_parent(existing_container);
-      PJ_container_free(existing_container);
-
-      // create new container on the new_host location
-      PJ_container_new(vm->cname(), INSTR_MSG_VM, PJ_container_get(ms->dst_pm->cname()));
-
-      // end link
-      msg  = PJ_container_get(vm->cname());
-      type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
-      new_pajeEndLink(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
-    }
+
+  // Now the VM is running on the new host (the migration is completed) (even if the SRC crash)
+  vm->pimpl_vm_->isMigrating = false;
+  XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)", ms->vm->cname(), ms->src_pm->cname(), ms->dst_pm->cname());
+
+  if (TRACE_msg_vm_is_enabled()) {
+    static long long int counter = 0;
+    char key[INSTR_DEFAULT_STR_SIZE];
+    snprintf(key, INSTR_DEFAULT_STR_SIZE, "%lld", counter);
+    counter++;
+
+    // start link
+    container_t msg = PJ_container_get(vm->cname());
+    type_t type     = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
+    new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+
+    // destroy existing container of this vm
+    container_t existing_container = PJ_container_get(vm->cname());
+    PJ_container_remove_from_parent(existing_container);
+    PJ_container_free(existing_container);
+
+    // create new container on the new_host location
+    PJ_container_new(vm->cname(), INSTR_MSG_VM, PJ_container_get(ms->dst_pm->cname()));
+
+    // end link
+    msg  = PJ_container_get(vm->cname());
+    type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
+    new_pajeEndLink(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
   }
+
   // Inform the SRC that the migration has been correctly performed
-  {
-    char *task_name = get_mig_task_name(ms->vm, ms->src_pm, ms->dst_pm, 4);
-    msg_task_t task = MSG_task_create(task_name, 0, 0, nullptr);
-    msg_error_t ret = MSG_task_send(task, ms->mbox_ctl);
-    // xbt_assert(ret == MSG_OK);
-    if(ret == MSG_HOST_FAILURE){
-      // The DST has crashed, this is a problem has the VM since we are not sure whether SRC is considering that the VM
-      // has been correctly migrated on the DST node
-      // TODO What does it mean ? What should we do ?
-      MSG_task_destroy(task);
-    } else if(ret == MSG_TRANSFER_FAILURE){
-      // The SRC has crashed, this is not a problem has the VM has been correctly migrated on the DST node
-      MSG_task_destroy(task);
-    }
-    xbt_free(task_name);
+  char *task_name = get_mig_task_name(ms->vm, ms->src_pm, ms->dst_pm, 4);
+  msg_task_t task = MSG_task_create(task_name, 0, 0, nullptr);
+  msg_error_t ret = MSG_task_send(task, ms->mbox_ctl);
+  // xbt_assert(ret == MSG_OK);
+  if(ret == MSG_HOST_FAILURE){
+    // The DST has crashed, this is a problem has the VM since we are not sure whether SRC is considering that the VM
+    // has been correctly migrated on the DST node
+    // TODO What does it mean ? What should we do ?
+    MSG_task_destroy(task);
+  } else if(ret == MSG_TRANSFER_FAILURE){
+    // The SRC has crashed, this is not a problem has the VM has been correctly migrated on the DST node
+    MSG_task_destroy(task);
   }
+  xbt_free(task_name);
 
   XBT_DEBUG("mig: rx_done");
   return 0;
@@ -482,7 +481,7 @@ static sg_size_t send_migration_data(msg_vm_t vm, msg_host_t src_pm, msg_host_t
 {
   sg_size_t sent = 0;
   char *task_name = get_mig_task_name(vm, src_pm, dst_pm, stage);
-  msg_task_t task = MSG_task_create(task_name, 0, (double)size, nullptr);
+  msg_task_t task = MSG_task_create(task_name, 0, static_cast<double>(size), nullptr);
 
   /* TODO: clean up */
 
@@ -499,18 +498,18 @@ static sg_size_t send_migration_data(msg_vm_t vm, msg_host_t src_pm, msg_host_t
   if (ret == MSG_OK) {
     sent = size;
   } else if (ret == MSG_TIMEOUT) {
-    sg_size_t remaining = (sg_size_t)MSG_task_get_remaining_communication(task);
+    sg_size_t remaining = static_cast<sg_size_t>(MSG_task_get_remaining_communication(task));
     sent = size - remaining;
     XBT_VERB("timeout (%lf s) in sending_migration_data, remaining %llu bytes of %llu", timeout, remaining, size);
   }
 
   /* FIXME: why try-and-catch is used here? */
   if(ret == MSG_HOST_FAILURE){
-    //XBT_DEBUG("SRC host failed during migration of %s (stage %d)", sg_host_name(vm), stage);
+    XBT_DEBUG("SRC host failed during migration of %s (stage %d)", vm->cname(), stage);
     MSG_task_destroy(task);
     THROWF(host_error, 0, "SRC host failed during migration of %s (stage %d)", vm->cname(), stage);
   }else if(ret == MSG_TRANSFER_FAILURE){
-    //XBT_DEBUG("DST host failed during migration of %s (stage %d)", sg_host_name(vm), stage);
+    XBT_DEBUG("DST host failed during migration of %s (stage %d)", vm->cname(), stage);
     MSG_task_destroy(task);
     THROWF(host_error, 0, "DST host failed during migration of %s (stage %d)", vm->cname(), stage);
   }
@@ -539,7 +538,7 @@ static sg_size_t get_updated_size(double computed, double dp_rate, double dp_cap
     updated_size = dp_cap;
   }
 
-  return (sg_size_t) updated_size;
+  return static_cast<sg_size_t>(updated_size);
 }
 
 static int migration_tx_fun(int argc, char *argv[])
@@ -547,7 +546,7 @@ static int migration_tx_fun(int argc, char *argv[])
   XBT_DEBUG("mig: tx_start");
 
   // Note that the ms structure has been allocated in do_migration and hence should be freed in the same function ;)
-  migration_session *ms = (migration_session *) MSG_process_get_data(MSG_process_self());
+  migration_session *ms = static_cast<migration_session *>(MSG_process_get_data(MSG_process_self()));
 
   s_vm_params_t params;
   static_cast<simgrid::s4u::VirtualMachine*>(ms->vm)->parameters(&params);
@@ -562,7 +561,7 @@ static int migration_tx_fun(int argc, char *argv[])
 
   double mig_timeout = 10000000.0;
 
-  double remaining_size = (double) (ramsize + devsize);
+  double remaining_size = static_cast<double>(ramsize + devsize);
   double threshold = 0.0;
 
   /* check parameters */
@@ -694,7 +693,8 @@ static int migration_tx_fun(int argc, char *argv[])
 
   try {
     XBT_DEBUG("Stage 3: Gonna send %f", remaining_size);
-    send_migration_data(ms->vm, ms->src_pm, ms->dst_pm, (sg_size_t)remaining_size, ms->mbox, 3, 0, mig_speed, -1);
+    send_migration_data(ms->vm, ms->src_pm, ms->dst_pm, static_cast<sg_size_t>(remaining_size), ms->mbox, 3, 0,
+                        mig_speed, -1);
   }
   catch(xbt_ex& e) {
     //hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code)
index 785ef94..49b9cc7 100644 (file)
@@ -163,7 +163,8 @@ void VirtualMachineImpl::suspend(smx_actor_t issuer)
 
   action_->suspend();
 
-  smx_actor_t smx_process, smx_process_safe;
+  smx_actor_t smx_process;
+  smx_actor_t smx_process_safe;
   xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
     XBT_DEBUG("suspend %s", smx_process->name.c_str());
     SIMIX_process_suspend(smx_process, issuer);
@@ -184,7 +185,8 @@ void VirtualMachineImpl::resume()
 
   action_->resume();
 
-  smx_actor_t smx_process, smx_process_safe;
+  smx_actor_t smx_process;
+  smx_actor_t smx_process_safe;
   xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
     XBT_DEBUG("resume %s", smx_process->cname());
     SIMIX_process_resume(smx_process);
@@ -208,7 +210,8 @@ void VirtualMachineImpl::shutdown(smx_actor_t issuer)
   xbt_swag_t process_list = piface_->extension<simgrid::simix::Host>()->process_list;
   XBT_DEBUG("shutdown VM %s, that contains %d processes", piface_->cname(), xbt_swag_size(process_list));
 
-  smx_actor_t smx_process, smx_process_safe;
+  smx_actor_t smx_process;
+  smx_actor_t smx_process_safe;
   xbt_swag_foreach_safe(smx_process, smx_process_safe, process_list) {
     XBT_DEBUG("kill %s", smx_process->cname());
     SIMIX_process_kill(smx_process, issuer);
index d97e17a..482750d 100644 (file)
@@ -90,12 +90,11 @@ smx_activity_t simcall_execution_parallel_start(const char* name, int host_nb, s
                                                 double* flops_amount, double* bytes_amount, double amount, double rate,
                                                 double timeout)
 {
-  int i,j;
   /* checking for infinite values */
-  for (i = 0 ; i < host_nb ; ++i) {
+  for (int i = 0 ; i < host_nb ; ++i) {
     xbt_assert(std::isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i);
     if (bytes_amount != nullptr) {
-      for (j = 0 ; j < host_nb ; ++j) {
+      for (int j = 0 ; j < host_nb ; ++j) {
         xbt_assert(std::isfinite(bytes_amount[i + host_nb * j]),
                    "bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j);
       }
index f6c0fd9..d0c7d02 100644 (file)
@@ -32,7 +32,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_environment, simix, "Logging specific to S
  */
 void SIMIX_create_environment(const char *file)
 {
-  double start = 0, end = 0;
+  double start = 0;
+  double end = 0;
   if(XBT_LOG_ISENABLED(simix_environment, xbt_log_priority_debug))
     start = xbt_os_time();
   try {
index a3623c1..00e3866 100644 (file)
@@ -119,7 +119,8 @@ char sigsegv_stack[SIGSTKSZ];   /* alternate stack for SIGSEGV handler */
  */
 static void install_segvhandler()
 {
-  stack_t stack, old_stack;
+  stack_t stack;
+  stack_t old_stack;
   stack.ss_sp = sigsegv_stack;
   stack.ss_size = sizeof sigsegv_stack;
   stack.ss_flags = 0;
@@ -134,7 +135,8 @@ static void install_segvhandler()
     sigaltstack(&old_stack, nullptr);
   }
 
-  struct sigaction action, old_action;
+  struct sigaction action;
+  struct sigaction old_action;
   action.sa_sigaction = &segvhandler;
   action.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
   sigemptyset(&action.sa_mask);
index b55d21e..7f00160 100644 (file)
@@ -69,11 +69,7 @@ CpuTiTgmr::~CpuTiTgmr()
 */
 double CpuTiTgmr::integrate(double a, double b)
 {
-  double first_chunk;
-  double middle_chunk;
-  double last_chunk;
   int a_index;
-  int b_index;
 
   if ((a < 0.0) || (a > b)) {
     xbt_die("Error, invalid integration interval [%.2f,%.2f]. "
@@ -91,15 +87,15 @@ double CpuTiTgmr::integrate(double a, double b)
   else
     a_index = static_cast<int> (ceil(a / lastTime_));
 
-  b_index = static_cast<int> (floor(b / lastTime_));
+  int b_index = static_cast<int> (floor(b / lastTime_));
 
   if (a_index > b_index) {      /* Same chunk */
     return trace_->integrateSimple(a - (a_index - 1) * lastTime_, b - (b_index) * lastTime_);
   }
 
-  first_chunk = trace_->integrateSimple(a - (a_index - 1) * lastTime_, lastTime_);
-  middle_chunk = (b_index - a_index) * total_;
-  last_chunk = trace_->integrateSimple(0.0, b - (b_index) * lastTime_);
+  double first_chunk = trace_->integrateSimple(a - (a_index - 1) * lastTime_, lastTime_);
+  double middle_chunk = (b_index - a_index) * total_;
+  double last_chunk = trace_->integrateSimple(0.0, b - (b_index) * lastTime_);
 
   XBT_DEBUG("first_chunk=%.2f  middle_chunk=%.2f  last_chunk=%.2f\n", first_chunk, middle_chunk, last_chunk);
 
@@ -124,10 +120,10 @@ double CpuTiTrace::integrateSimple(double a, double b)
 double CpuTiTrace::integrateSimplePoint(double a)
 {
   double integral = 0;
-  int ind;
   double a_aux = a;
-  ind = binarySearch(timePoints_, a, 0, nbPoints_ - 1);
+  int ind = binarySearch(timePoints_, a, 0, nbPoints_ - 1);
   integral += integral_[ind];
+
   XBT_DEBUG("a %f ind %d integral %f ind + 1 %f ind %f time +1 %f time %f",
        a, ind, integral, integral_[ind + 1], integral_[ind], timePoints_[ind + 1], timePoints_[ind]);
   double_update(&a_aux, timePoints_[ind], sg_maxmin_precision*sg_surf_precision);