Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 12 May 2017 13:27:05 +0000 (15:27 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 12 May 2017 13:27:05 +0000 (15:27 +0200)
37 files changed:
examples/java/app/centralizedmutex/Node.java
examples/java/dht/kademlia/Common.java
examples/java/dht/kademlia/Node.java
examples/java/energy/consumption/Main.java
examples/java/io/file/Node.java
examples/java/trace/pingpong/Sender.java
include/simgrid/simix.h
include/surf/surf_routing.h
src/bindings/java/jmsg.cpp
src/bindings/java/jmsg.h
src/bindings/java/jmsg_host.cpp
src/bindings/java/jmsg_storage.cpp
src/include/surf/surf.h
src/kernel/routing/DijkstraZone.cpp
src/msg/msg_environment.cpp
src/msg/msg_io.cpp
src/simgrid/host.cpp
src/simgrid/sg_config.cpp
src/simix/smx_global.cpp
src/simix/smx_io.cpp
src/simix/smx_io_private.h
src/smpi/instr_smpi.cpp
src/smpi/smpi_global.cpp
src/smpi/smpi_shared.cpp
src/surf/cpu_cas01.cpp
src/surf/fair_bottleneck.cpp
src/surf/network_cm02.cpp
src/surf/network_cm02.hpp
src/surf/network_interface.cpp
src/surf/storage_interface.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_interface.hpp
src/surf/xml/surfxml_parseplatf.cpp
src/xbt/backtrace_linux.cpp
src/xbt/cunit.cpp
src/xbt/xbt_str.cpp
teshsuite/simdag/flatifier/flatifier.cpp

index 78bfef9..43ed0cf 100644 (file)
@@ -16,13 +16,13 @@ public class Node extends Process {
   public Node(Host host, String name, String[]args) {
    super(host,name,args);
   }
-  public void request(double CStime) throws MsgException {
+  public void request(double csTime) throws MsgException {
     RequestTask req = new RequestTask(getName());
     Msg.info("Send a request to the coordinator");
     req.send("coordinator");
     Msg.info("Wait for a grant from the coordinator");
     GrantTask.receive(getName());
-    Task compute = new Task("CS", CStime, 0);
+    Task compute = new Task("CS", csTime, 0);
     compute.execute();
     ReleaseTask release = new ReleaseTask();
     release.send("coordinator");
index 381cf38..8af5cc5 100644 (file)
@@ -13,7 +13,7 @@ public class Common {
 
   public static final int RANDOM_LOOKUP_INTERVAL = 100;
 
-  public static final int alpha = 3;
+  public static final int ALPHA = 3;
 
   public static final int IDENTIFIER_SIZE = 32;
   /* Maximum size of the buckets */
index 4e46ba0..841e9d1 100644 (file)
@@ -57,16 +57,16 @@ public class Node extends Process {
   }
 
   public void mainLoop() {
-    double next_lookup_time = Msg.getClock() + Common.RANDOM_LOOKUP_INTERVAL;
+    double nextLookupTime = Msg.getClock() + Common.RANDOM_LOOKUP_INTERVAL;
     while (Msg.getClock() < this.deadline) {
       try {
         if (comm == null) {
           comm = Task.irecv(Integer.toString(id));
         }
         if (!comm.test()) {
-          if (Msg.getClock() >= next_lookup_time) {
+          if (Msg.getClock() >= nextLookupTime) {
             randomLookup();
-            next_lookup_time += Common.RANDOM_LOOKUP_INTERVAL;
+            nextLookupTime += Common.RANDOM_LOOKUP_INTERVAL;
           } else {
             waitFor(1);
           }
@@ -275,7 +275,7 @@ public class Node extends Process {
   public int sendFindNodeToBest(Answer nodeList) {
     int destination = nodeList.getDestinationId();
     int i;
-    for (i = 0; i < Common.alpha && i < nodeList.size(); i++) {
+    for (i = 0; i < Common.ALPHA && i < nodeList.size(); i++) {
       Contact node = nodeList.getNodes().get(i);
       if (node.getId() != this.id) {
         this.sendFindNode(node.getId(),destination);
index 3ac36da..e318036 100644 (file)
@@ -10,9 +10,6 @@ import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
 
 public class Main {
-  public static final double task_comp_size = 10;
-  public static final double task_comm_size = 10;
-  public static final int hostNB = 2 ; 
   private Main() {
     throw new IllegalAccessError("Utility class");
   }
index df9e214..82ce689 100644 (file)
@@ -26,10 +26,10 @@ import org.simgrid.msg.HostNotFoundException;
 import org.simgrid.msg.MsgException;
 
 public class Node extends Process {
-  private static String FILENAME1 = "/doc/simgrid/examples/platforms/g5k.xml";
-  private static String FILENAME2 = "\\Windows\\setupact.log";
-  private static String FILENAME3 = "/doc/simgrid/examples/platforms/g5k_cabinets.xml";
-  private static String FILENAME4 = "/doc/simgrid/examples/platforms/nancy.xml";
+  private static String file1 = "/doc/simgrid/examples/platforms/g5k.xml";
+  private static String file2 = "\\Windows\\setupact.log";
+  private static String file3 = "/doc/simgrid/examples/platforms/g5k_cabinets.xml";
+  private static String file4 = "/doc/simgrid/examples/platforms/nancy.xml";
 
   protected int rank;
 
@@ -40,42 +40,42 @@ public class Node extends Process {
 
   public void main(String[] args) throws MsgException {
     String mount;
-    String filename;
+    String fileName;
     switch (rank) {
       case 4:
         mount = "/home";
-        filename = mount + FILENAME1;
+        fileName = mount + file1;
       break;
       case 0:
         mount = "c:";
-        filename = mount + FILENAME2;
+        fileName = mount + file2;
       break;
       case 2:
         mount = "/home";
-        filename = mount + FILENAME3;
+        fileName = mount + file3;
       break;
       case 1:
         mount = "/home";
-        filename = mount + FILENAME4;
+        fileName = mount + file4;
       break;
       default:
         mount = "/home";
-        filename = mount + FILENAME1;
+        fileName = mount + file1;
     }
 
-    Msg.info("Open file " + filename);
-    File file = new File(filename);
+    Msg.info("Open file " + fileName);
+    File file = new File(fileName);
 
     long read = file.read(10000,1);
-    Msg.info("Having read " + read + " on " + filename);
+    Msg.info("Having read " + read + " on " + fileName);
 
     long write = file.write(100000,1);
-    Msg.info("Having write " + write + " on " + filename);
+    Msg.info("Having write " + write + " on " + fileName);
 
-    Msg.info("Seek back to the beginning of " + filename);
+    Msg.info("Seek back to the beginning of " + fileName);
     file.seek(0,File.SEEK_SET);
 
     read = file.read(150000,1);
-    Msg.info("Having read " + read + " on " + filename);  
+    Msg.info("Having read " + read + " on " + fileName);  
   }
 }
index d3f107d..6af47fa 100644 (file)
@@ -14,8 +14,8 @@ import org.simgrid.msg.Task;
 import org.simgrid.trace.Trace;
 
 public class Sender extends Process {
-  private static final double commSizeLat = 1;
-  private static final double commSizeBw = 100000000;
+  private static final double COMM_SIZE_LAT = 1;
+  private static final double COMM_SIZE_BW = 100000000;
   private static final String PM_STATE = "PM_STATE";
 
   public Sender(String hostname, String name, String[] args) throws HostNotFoundException {
@@ -40,7 +40,7 @@ public class Sender extends Process {
     for (int pos = 0; pos < hostCount; pos++) { 
       time = Msg.getClock(); 
       Msg.info("sender time: " + time);
-      ping = new PingPongTask("no name",computeDuration,commSizeLat);
+      ping = new PingPongTask("no name",computeDuration,COMM_SIZE_LAT);
       ping.setTime(time);
       ping.send(mailboxes[pos]);
 
@@ -57,7 +57,7 @@ public class Sender extends Process {
       communicationTime=timeGot - time;
       Msg.info("Communication time : " + communicationTime);
 
-      Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
+      Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
 
       /* Pop the last state (going back to sending ping) */  
       Trace.hostPopState (getHost().getName(), PM_STATE);
index e06f54f..c101d43 100644 (file)
@@ -369,8 +369,6 @@ XBT_PUBLIC(int) simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin)
 XBT_PUBLIC(int) simcall_file_move(smx_file_t fd, const char* fullpath);
 /*****************************   Storage   **********************************/
 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
-XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_storage_t storage);
-
 /************************** MC simcalls   **********************************/
 XBT_PUBLIC(int) simcall_mc_random(int min, int max);
 
index ce7ec7a..83fa79e 100644 (file)
@@ -13,13 +13,9 @@ SG_BEGIN_DECL()
 
 // FIXME: this header file should die
 
-XBT_PUBLIC_DATA(int) SIMIX_STORAGE_LEVEL; //Simix storage level
-
 XBT_PUBLIC_DATA(xbt_lib_t) storage_lib;
 XBT_PUBLIC_DATA(int) ROUTING_STORAGE_LEVEL;        //Routing storage level
 XBT_PUBLIC_DATA(int) SURF_STORAGE_LEVEL;  // Surf storage level
-XBT_PUBLIC_DATA(xbt_lib_t) storage_type_lib;
-XBT_PUBLIC_DATA(int) ROUTING_STORAGE_TYPE_LEVEL;   //Routing storage_type level
 
 SG_END_DECL()
 
index ec98fde..3a5392d 100644 (file)
@@ -39,7 +39,6 @@
 SG_BEGIN_DECL()
 
 int JAVA_HOST_LEVEL = -1;
-int JAVA_STORAGE_LEVEL = -1;
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
 
@@ -132,7 +131,6 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, j
   MSG_init(&argc, argv);
 
   JAVA_HOST_LEVEL = simgrid::s4u::Host::extension_create(__JAVA_host_priv_free);
-  JAVA_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, __JAVA_storage_priv_free);
 
   for (index = 0; index < argc - 1; index++) {
     env->SetObjectArrayElement(jargs, index, (jstring)env->NewStringUTF(argv[index + 1]));
@@ -164,15 +162,8 @@ JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass
   xbt_dynar_free(&hosts);
 
   /* Cleanup java storages */
-  xbt_dynar_t storages = MSG_storages_as_dynar();
-  if(!xbt_dynar_is_empty(storages)){
-    for (unsigned long index = 0; index < xbt_dynar_length(storages) - 1; index++) {
-      jobject jstorage = (jobject) xbt_lib_get_level(xbt_dynar_get_as(storages,index,msg_storage_t), JAVA_STORAGE_LEVEL);
-      if (jstorage)
-        jstorage_unref(env, jstorage);
-    }
-  }
-  xbt_dynar_free(&storages);
+  for (auto elm : java_storage_map)
+    jstorage_unref(env, elm.second);
 }
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls, jstring jplatformFile)
index de18540..34ba2a2 100644 (file)
@@ -7,8 +7,9 @@
 
 #ifndef MSG4JAVA_H
 #define MSG4JAVA_H
-#include <simgrid/msg.h>
 #include <jni.h>
+#include <simgrid/msg.h>
+#include <unordered_map>
 
 SG_BEGIN_DECL()
 
@@ -22,7 +23,7 @@ SG_BEGIN_DECL()
 /* end of eclipse-mandated pimple */
 
 extern int JAVA_HOST_LEVEL;
-extern int JAVA_STORAGE_LEVEL;
+static std::unordered_map<char*, jobject> java_storage_map;
 
 JavaVM *get_java_VM();
 JNIEnv *get_current_thread_env();
index 7b45e78..1169daf 100644 (file)
@@ -282,7 +282,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getAttachedStorage(JNIE
     jstorage_name = env->NewStringUTF(storage_name);
     env->SetObjectArrayElement(jtable, index, jstorage_name);
   }
-
+  xbt_dynar_free_container(&dyn);
   return jtable;
 }
 
index 48e73bc..15bd3fe 100644 (file)
@@ -53,7 +53,7 @@ void jstorage_unref(JNIEnv * env, jobject jstorage) {
 
 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, jclass cls, jstring jname) {
   msg_storage_t storage;
-  jobject jstorage;
+  jobject jstorage = nullptr;
 
   /* get the C string from the java string */
   if (jname == nullptr) {
@@ -70,8 +70,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j
   }
   env->ReleaseStringUTFChars(jname, name);
 
-  if (!xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL)) {       /* native host not associated yet with java host */
-
+  if (java_storage_map.find(storage->key) == java_storage_map.end()) {
     /* Instantiate a new java storage */
     jstorage = jstorage_new_instance(env);
 
@@ -95,11 +94,12 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, j
     /* the native storage data field is set with the global reference to the
      * java storage returned by this function
      */
-    xbt_lib_set(storage_lib, storage->key, JAVA_STORAGE_LEVEL, (void *) jstorage);
-  }
+    java_storage_map.insert({storage->key, jstorage});
+  } else
+    jstorage = java_storage_map.at(storage->key);
 
   /* return the global reference to the java storage instance */
-  return (jobject) xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL);
+  return (jobject)jstorage;
 }
 
 JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getSize(JNIEnv * env,jobject jstorage) {
@@ -216,9 +216,9 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Storage_all(JNIEnv * env, jc
 
   for (index = 0; index < count; index++) {
     storage = xbt_dynar_get_as(table,index,msg_storage_t);
-    jstorage = (jobject) (xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL));
-
-    if (!jstorage) {
+    if (java_storage_map.find(storage->key) != java_storage_map.end()) {
+      jstorage = java_storage_map.at(storage->key);
+    } else {
       jname = env->NewStringUTF(MSG_storage_get_name(storage));
       jstorage = Java_org_simgrid_msg_Storage_getByName(env, cls_arg, jname);
     }
index 6cf5b49..09941a4 100644 (file)
@@ -322,6 +322,7 @@ XBT_PUBLIC(xbt_dict_t) surf_storage_action_get_ls_dict(surf_action_t action);
  * may not exist.
  */
 XBT_PUBLIC(const char * ) surf_storage_get_host(surf_resource_t resource);
+XBT_PUBLIC(const char * ) surf_storage_get_name(surf_resource_t resource);
 
 /** @} */
 
index d0e07ee..f987ae3 100644 (file)
@@ -236,11 +236,12 @@ void DijkstraZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cb
   }
 
   /* compose route path with links */
-  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;
+  NetPoint* gw_src = nullptr;
+  NetPoint* gw_dst;
+  NetPoint* prev_gw_src;
+  NetPoint* first_gw            = nullptr;
+  NetPoint* gw_dst_net_elm      = nullptr;
+  NetPoint* prev_gw_src_net_elm = nullptr;
 
   for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
     xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
index 2957528..fc067f7 100644 (file)
@@ -43,8 +43,7 @@ void MSG_post_create_environment() {
 
   /* Initialize MSG storages */
   xbt_lib_foreach(storage_lib, cursor, name, data) {
-    if(data[SIMIX_STORAGE_LEVEL])
-      __MSG_storage_create(xbt_dict_cursor_get_elm(cursor));
+    __MSG_storage_create(xbt_dict_cursor_get_elm(cursor));
   }
 }
 
index 282f46a..060e256 100644 (file)
@@ -421,7 +421,7 @@ msg_storage_t __MSG_storage_create(smx_storage_t storage)
 {
   msg_storage_priv_t storage_private = xbt_new0(s_msg_storage_priv_t, 1);
 
-  storage_private->name     = SIMIX_storage_get_name(storage);
+  storage_private->name     = surf_storage_get_name(storage);
   storage_private->hostname = surf_storage_get_host(storage);
   storage_private->size     = surf_storage_get_size(storage);
 
index 308a135..919fb94 100644 (file)
@@ -236,8 +236,6 @@ double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
 void sg_host_dump(sg_host_t host)
 {
   xbt_dict_t props;
-  xbt_dict_cursor_t cursor=nullptr;
-  char *key,*data;
 
   XBT_INFO("Displaying host %s", host->cname());
   XBT_INFO("  - speed: %.0f", host->speed());
@@ -246,6 +244,9 @@ void sg_host_dump(sg_host_t host)
 
   if (!xbt_dict_is_empty(props)){
     XBT_INFO("  - properties:");
+    xbt_dict_cursor_t cursor = nullptr;
+    char* key;
+    char* data;
 
     xbt_dict_foreach(props,cursor,key,data) {
       XBT_INFO("    %s->%s",key,data);
index f1434ef..729f1ee 100644 (file)
@@ -45,7 +45,8 @@ int _sg_cfg_exit_asap = 0;
 static void sg_config_cmd_line(int *argc, char **argv)
 {
   int shall_exit = 0;
-  int i, j;
+  int i;
+  int j;
 
   for (j = i = 1; i < *argc; i++) {
     if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
index 4c7bc53..9292bf6 100644 (file)
@@ -238,11 +238,7 @@ void SIMIX_global_init(int *argc, char **argv)
       // TODO, create sg_storage_by_name
       sg_storage_t s = xbt_lib_get_elm_or_null(storage_lib, name);
       xbt_assert(s != nullptr, "Storage not found for name %s", name);
-
-      SIMIX_storage_create(name, s, nullptr);
     });
-
-    SIMIX_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, SIMIX_storage_destroy);
   }
   if (!simix_timers)
     simix_timers = xbt_heap_new(8, [](void* p) {
index 88892bf..38659ca 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
 
-/**
- * \brief Internal function to create a SIMIX storage.
- * \param name name of the storage to create
- * \param storage the SURF storage to encapsulate
- * \param data some user data (may be nullptr)
- */
-smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data)
-{
-  smx_storage_priv_t smx_storage = xbt_new0(s_smx_storage_priv_t, 1);
-
-  smx_storage->data = data;
-
-  /* Update global variables */
-  xbt_lib_set(storage_lib,name,SIMIX_STORAGE_LEVEL,smx_storage);
-  return xbt_lib_get_elm_or_null(storage_lib, name);
-}
-
-/**
- * \brief Internal function to destroy a SIMIX storage.
- *
- * \param s the host to destroy (a smx_storage_t)
- */
-void SIMIX_storage_destroy(void *s)
-{
-  smx_storage_priv_t storage = static_cast<smx_storage_priv_t>(s);
-
-  xbt_assert((storage != nullptr), "Invalid parameters");
-  if (storage->data)
-    free(storage->data);
-
-  /* Clean storage structure */
-  free(storage);
-}
-
 //SIMIX FILE READ
 void simcall_HANDLER_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, sg_host_t host)
 {
@@ -214,10 +180,6 @@ xbt_dict_t SIMIX_storage_get_properties(smx_storage_t storage){
   return surf_storage_get_properties(storage);
 }
 
-const char* SIMIX_storage_get_name(smx_storage_t storage){
-  return sg_storage_name(storage);
-}
-
 void SIMIX_io_destroy(smx_activity_t synchro)
 {
   simgrid::kernel::activity::Io *io = static_cast<simgrid::kernel::activity::Io*>(synchro);
index 114f9c0..0f9bfd3 100644 (file)
 #include "simgrid/simix.h"
 #include "popping_private.h"
 
-/** @brief Storage datatype */
-typedef struct s_smx_storage_priv {
-  void *data;              /**< @brief user data */
-} s_smx_storage_priv_t;
-
-
-static inline smx_storage_priv_t SIMIX_storage_priv(smx_storage_t storage){
-  return (smx_storage_priv_t) xbt_lib_get_level(storage, SIMIX_STORAGE_LEVEL);
-}
-
-XBT_PRIVATE smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data);
-XBT_PRIVATE void SIMIX_storage_destroy(void *s);
 XBT_PRIVATE smx_activity_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host);
 XBT_PRIVATE smx_activity_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host);
 XBT_PRIVATE smx_activity_t SIMIX_file_open(const char* fullpath, sg_host_t host);
index 900d1a1..588086b 100644 (file)
@@ -61,20 +61,20 @@ static const char *smpi_colors[] ={
 
 static char *str_tolower (const char *str)
 {
-  char *ret = xbt_strdup (str);
-  int i, n = strlen (ret);
-  for (i = 0; i < n; i++)
+  char* ret = xbt_strdup(str);
+  int n     = strlen(ret);
+  for (int i = 0; i < n; i++)
     ret[i] = tolower (str[i]);
   return ret;
 }
 
 static const char *instr_find_color (const char *state)
 {
-  char *target = str_tolower (state);
-  const char *ret = nullptr;
-  unsigned int i = 0;
-  const char *current = smpi_colors[i];
-  while ((current != nullptr)){
+  char* target        = str_tolower(state);
+  const char* ret     = nullptr;
+  unsigned int i      = 0;
+  const charcurrent = smpi_colors[i];
+  while (current != nullptr) {
     if (strcmp (state, current) == 0 //exact match
         || strstr(target, current) != 0 ){//as substring
          ret = smpi_colors[i+1]; 
index d047bcf..161300d 100644 (file)
@@ -180,7 +180,8 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b
        XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
 
        smpi_switch_data_segment(
-           (static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->src_proc->data)->data))->index()));
+           static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->src_proc->data)->data))
+               ->index());
        tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
        memcpy_private(tmpbuff, buff, private_blocks);
   }
@@ -189,7 +190,8 @@ void smpi_comm_copy_buffer_callback(smx_activity_t synchro, void *buff, size_t b
       && ((char*)comm->dst_buff < smpi_start_data_exe + smpi_size_data_exe )){
        XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
        smpi_switch_data_segment(
-           (static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->dst_proc->data)->data))->index()));
+           static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->dst_proc->data)->data))
+               ->index());
   }
   XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff);
   memcpy_private(comm->dst_buff, tmpbuff, private_blocks);
@@ -664,8 +666,8 @@ int smpi_main(const char* executable, int argc, char *argv[])
     }
   }
   int count = smpi_process_count();
-  int i, ret=0;
-  for (i = 0; i < count; i++) {
+  int ret   = 0;
+  for (int i = 0; i < count; i++) {
     if(process_data[i]->return_value()!=0){
       ret=process_data[i]->return_value();//return first non 0 value
       break;
index b9e85fa..09d9030 100644 (file)
@@ -363,7 +363,8 @@ std::vector<std::pair<size_t, size_t>> shift_and_frame_private_blocks(const std:
 
 std::vector<std::pair<size_t, size_t>> merge_private_blocks(std::vector<std::pair<size_t, size_t>> src, std::vector<std::pair<size_t, size_t>> dst) {
   std::vector<std::pair<size_t, size_t>> result;
-  unsigned i_src=0, i_dst=0;
+  unsigned i_src = 0;
+  unsigned i_dst = 0;
   while(i_src < src.size() && i_dst < dst.size()) {
     std::pair<size_t, size_t> block;
     if(src[i_src].second <= dst[i_dst].first) {
index f9835fa..1f5ebb5 100644 (file)
@@ -179,7 +179,7 @@ CpuAction *CpuCas01::sleep(double duration)
   // FIXME: sleep variables should not consume 1.0 in lmm_expand
   action->maxDuration_ = duration;
   action->suspended_ = 2;
-  if (duration == NO_MAX_DURATION) {
+  if (duration < 0) { // NO_MAX_DURATION
     /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
     action->getStateSet()->erase(action->getStateSet()->iterator_to(*action));
     action->stateSet_ = static_cast<CpuCas01Model*>(model())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
index d6c424a..270a399 100644 (file)
@@ -4,11 +4,12 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "xbt/sysdep.h"
-#include "xbt/log.h"
 #include "maxmin_private.hpp"
-#include <stdlib.h>
+#include "xbt/log.h"
+#include "xbt/sysdep.h"
+#include <float.h>
 #include <math.h>
+#include <stdlib.h>
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_maxmin);
 #define SHOW_EXPR_G(expr) XBT_DEBUG(#expr " = %g",expr);
@@ -113,10 +114,11 @@ void bottleneck_solve(lmm_system_t sys)
 
     xbt_swag_foreach_safe(_var, _var_next, var_list) {
       var = static_cast<lmm_variable_t>(_var);
-      double min_inc =  var->cnsts[0].constraint->usage / var->cnsts[0].value;
-      for (int i = 1; i < var->cnsts_number; i++) {
+      double min_inc = DBL_MAX;
+      for (int i = 0; i < var->cnsts_number; i++) {
         lmm_element_t elm = &var->cnsts[i];
-        min_inc = MIN(min_inc, elm->constraint->usage / elm->value);
+        if (elm->value > 0)
+          min_inc = MIN(min_inc, elm->constraint->usage / elm->value);
       }
       if (var->bound > 0)
         min_inc = MIN(min_inc, var->bound - var->value);
index 22f0325..ec1edd5 100644 (file)
@@ -88,7 +88,7 @@ void surf_network_model_init_Reno()
   if (surf_network_model)
     return;
 
-  surf_network_model = new simgrid::surf::NetworkCm02Model(lagrange_solve);
+  surf_network_model = new simgrid::surf::NetworkCm02Model(&lagrange_solve);
   all_existing_models->push_back(surf_network_model);
 
   lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
@@ -104,7 +104,7 @@ void surf_network_model_init_Reno2()
   if (surf_network_model)
     return;
 
-  surf_network_model = new simgrid::surf::NetworkCm02Model(lagrange_solve);
+  surf_network_model = new simgrid::surf::NetworkCm02Model(&lagrange_solve);
   all_existing_models->push_back(surf_network_model);
 
   lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, func_reno2_fpi);
@@ -119,7 +119,7 @@ void surf_network_model_init_Vegas()
   if (surf_network_model)
     return;
 
-  surf_network_model = new simgrid::surf::NetworkCm02Model(lagrange_solve);
+  surf_network_model = new simgrid::surf::NetworkCm02Model(&lagrange_solve);
   all_existing_models->push_back(surf_network_model);
 
   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi);
@@ -234,7 +234,7 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta)
           double_update(&(deltap), action->latency_, sg_surf_precision);
           action->latency_ = 0.0;
         }
-        if (action->latency_ == 0.0 && !(action->isSuspended()))
+        if (action->latency_ <= 0.0 && !(action->isSuspended()))
           lmm_update_variable_weight(maxminSystem_, action->getVariable(), action->weight_);
       }
       if (TRACE_is_enabled()) {
@@ -250,17 +250,16 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta)
         }
       }
       if (!lmm_get_number_of_cnst_from_var (maxminSystem_, action->getVariable())) {
-        /* There is actually no link used, hence an infinite bandwidth.
-         * This happens often when using models like vivaldi.
-         * In such case, just make sure that the action completes immediately.
+        /* There is actually no link used, hence an infinite bandwidth. This happens often when using models like
+         * vivaldi. In such case, just make sure that the action completes immediately.
          */
         action->updateRemains(action->getRemains());
       }
     action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
-                  
-    if (action->getMaxDuration() != NO_MAX_DURATION)
+
+    if (action->getMaxDuration() > NO_MAX_DURATION)
       action->updateMaxDuration(delta);
-      
+
     if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
         ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
       action->finish();
@@ -393,7 +392,6 @@ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const char* name, doub
 
 void NetworkCm02Link::apply_event(tmgr_trace_iterator_t triggered, double value)
 {
-
   /* Find out which of my iterators was triggered, and react accordingly */
   if (triggered == bandwidth_.event) {
     setBandwidth(value);
@@ -487,14 +485,10 @@ void NetworkCm02Link::setLatency(double value)
   }
 }
 
-NetworkCm02Link::~NetworkCm02Link() {}
-
 /**********
  * Action *
  **********/
 
-NetworkCm02Action::~NetworkCm02Action() {}
-
 void NetworkCm02Action::updateRemainingLazy(double now)
 {
   if (suspended_ != 0)
@@ -509,11 +503,11 @@ void NetworkCm02Action::updateRemainingLazy(double now)
     XBT_DEBUG("Updating action(%p): remains is now %f", this, remains_);
   }
 
-  if (maxDuration_ != NO_MAX_DURATION)
+  if (maxDuration_ > NO_MAX_DURATION)
     double_update(&maxDuration_, delta, sg_surf_precision);
 
   if ((remains_ <= 0 && (lmm_get_variable_weight(getVariable()) > 0)) ||
-      (((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0)))){
+      ((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0))) {
     finish();
     setState(Action::State::done);
     heapRemove(getModel()->getActionHeap());
index 9f160e4..5fb0290 100644 (file)
@@ -59,7 +59,7 @@ namespace simgrid {
     public:
       NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency,
                       e_surf_link_sharing_policy_t policy, lmm_system_t system);
-      ~NetworkCm02Link() override;
+      virtual ~NetworkCm02Link() = default;
       void apply_event(tmgr_trace_iterator_t event, double value) override;
       void setBandwidth(double value) override;
       void setLatency(double value) override;
@@ -76,7 +76,7 @@ namespace simgrid {
     public:
       NetworkCm02Action(Model *model, double cost, bool failed)
       : NetworkAction(model, cost, failed) {};
-      ~NetworkCm02Action() override;
+      virtual ~NetworkCm02Action() = default;
       void updateRemainingLazy(double now) override;
     protected:
       double senderGap_;
index 13c24e0..13ce413 100644 (file)
@@ -35,9 +35,10 @@ namespace simgrid {
     LinkImpl** LinkImpl::linksList()
     {
       LinkImpl** res = xbt_new(LinkImpl*, (int)links->size());
-      int i=0;
+      int i          = 0;
       for (auto kv : *links) {
-        res[i++] = kv.second;
+        res[i] = kv.second;
+        i++;
       }
       return res;
     }
index a2ef0eb..30b7444 100644 (file)
@@ -15,7 +15,6 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
 
 xbt_lib_t storage_lib;
-int SIMIX_STORAGE_LEVEL        = -1; // Simix storage level
 int MSG_STORAGE_LEVEL          = -1; // Msg storage level
 int ROUTING_STORAGE_LEVEL      = -1; // Routing for storage level
 int SURF_STORAGE_LEVEL = -1;
index e57d90b..7840806 100644 (file)
@@ -227,6 +227,10 @@ const char* surf_storage_get_host(surf_resource_t resource){
   return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->attach_;
 }
 
+const char* surf_storage_get_name(surf_resource_t resource){
+  return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->cname();
+}
+
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
   static_cast<simgrid::surf::CpuAction*>(action)->setBound(bound);
 }
index a5987f5..25bc6fc 100644 (file)
@@ -52,10 +52,6 @@ extern XBT_PRIVATE simgrid::xbt::signal<void(void)> surfExitCallbacks;
 
 int XBT_PRIVATE __surf_is_absolute_file_path(const char *file_path);
 
-static inline char* sg_storage_name(sg_storage_t storage) {
-  return storage->key;
-}
-
 /***********
  * Classes *
  ***********/
index 24892fd..ba3dab8 100644 (file)
@@ -180,7 +180,8 @@ void parse_platform_file(const char *file)
 
     /* connect all traces relative to hosts */
     xbt_dict_cursor_t cursor = nullptr;
-    char *trace_name, *elm;
+    char* trace_name;
+    char* elm;
 
     xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
       tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
index 5e77a4a..20891ae 100644 (file)
@@ -34,8 +34,9 @@ extern char **environ;          /* the environment, as specified by the opengrou
 
 #include <unwind.h>
 struct trace_arg {
-  void **array;
-  int cnt, size;
+  void** array;
+  int cnt;
+  int size;
 };
 
 static _Unwind_Reason_Code
@@ -190,7 +191,8 @@ std::vector<std::string> resolveBacktrace(
   }
 
   /* To read the output of addr2line */
-  char line_func[1024], line_pos[1024];
+  char line_func[1024];
+  char line_pos[1024];
   for (std::size_t i = 0; i < count; i++) {
     XBT_DEBUG("Looking for symbol %zd, addr = '%s'", i, addrs[i].c_str());
     if (fgets(line_func, 1024, pipe)) {
@@ -217,7 +219,8 @@ std::vector<std::string> resolveBacktrace(
 
       char maps_buff[512];
       long int offset = 0;
-      char *p, *p2;
+      char* p;
+      char* p2;
       int found = 0;
 
       /* let's look for the offset of this library in our addressing space */
@@ -233,7 +236,8 @@ std::vector<std::string> resolveBacktrace(
         addrs[i].c_str(), addr);
 
       while (!found) {
-        long int first, last;
+        long int first;
+        long int last;
 
         if (fgets(maps_buff, 512, maps) == nullptr)
           break;
index bac2505..94e16a6 100644 (file)
@@ -88,7 +88,9 @@ struct s_xbt_test_unit {
   xbt_dynar_t tests;            /* of xbt_test_test_t */
 
   int nb_tests;
-  int test_failed, test_ignore, test_expect;
+  int test_failed;
+  int test_ignore;
+  int test_expect;
 };
 
 static void xbt_test_unit_dump(xbt_test_unit_t unit)
@@ -112,9 +114,14 @@ struct s_xbt_test_suite {
   char *title;
   xbt_dynar_t units;            /* of xbt_test_unit_t */
 
-  int nb_tests, nb_units;
-  int test_failed, test_ignore, test_expect;
-  int unit_failed, unit_ignore, unit_disabled;
+  int nb_tests;
+  int nb_units;
+  int test_failed;
+  int test_ignore;
+  int test_expect;
+  int unit_failed;
+  int unit_ignore;
+  int unit_disabled;
 };
 
 /* destroy test suite */
@@ -245,7 +252,9 @@ static int xbt_test_suite_run(xbt_test_suite_t suite, int verbosity)
   const char *file;
   int line;
   char *cp;
-  unsigned int it_unit, it_test, it_log;
+  unsigned int it_unit;
+  unsigned int it_test;
+  unsigned int it_log;
 
   int first = 1;                /* for result pretty printing */
 
@@ -253,25 +262,22 @@ static int xbt_test_suite_run(xbt_test_suite_t suite, int verbosity)
     return 0;
 
   /* suite title pretty-printing */
-  {
-    char suite_title[81];
-    int suite_len = strlen(suite->title);
-    int i;
-
-    xbt_assert(suite_len < 68, "suite title \"%s\" too long (%d should be less than 68", suite->title, suite_len);
-
-    suite_title[0] = ' ';
-    for (i = 1; i < 80; i++)
-      suite_title[i] = '=';
-    suite_title[i++] = '\n';
-    suite_title[80] = '\0';
-
-    snprintf(suite_title + 40 - (suite_len + 4) / 2, 81-(40 - (suite_len + 4)/ 2), "[ %s ]", suite->title);
-    suite_title[40 + (suite_len + 5) / 2] = '=';
-    if (!suite->enabled)
-      snprintf(suite_title + 70, 11, " DISABLED ");
-    fprintf(stderr, "\n%s\n", suite_title);
-  }
+  char suite_title[81];
+  int suite_len = strlen(suite->title);
+
+  xbt_assert(suite_len < 68, "suite title \"%s\" too long (%d should be less than 68", suite->title, suite_len);
+
+  suite_title[0] = ' ';
+  for (int i = 1; i < 79; i++)
+    suite_title[i] = '=';
+  suite_title[79]  = '\n';
+  suite_title[80]  = '\0';
+
+  snprintf(suite_title + 40 - (suite_len + 4) / 2, 81 - (40 - (suite_len + 4) / 2), "[ %s ]", suite->title);
+  suite_title[40 + (suite_len + 5) / 2] = '=';
+  if (!suite->enabled)
+    snprintf(suite_title + 70, 11, " DISABLED ");
+  fprintf(stderr, "\n%s\n", suite_title);
 
   if (suite->enabled) {
     /* iterate through all tests */
index 8496a21..90eb701 100644 (file)
@@ -183,8 +183,6 @@ char *xbt_str_varsubst(const char *str, xbt_dict_t patterns)
 xbt_dynar_t xbt_str_split(const char *s, const char *sep)
 {
   xbt_dynar_t res = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
-  const char *p, *q;
-  int done;
   const char *sep_dflt = " \t\n\r\x0B";
   char is_sep[256] = { 1, 0 };
 
@@ -197,12 +195,12 @@ xbt_dynar_t xbt_str_split(const char *s, const char *sep)
     while (*sep)
       is_sep[(unsigned char) *sep++] = 1;
   }
-  is_sep[0] = 1;                /* End of string is also separator */
+  is_sep[0] = 1; /* End of string is also separator */
 
   /* Do the job */
-  p = s;
-  q = s;
-  done = 0;
+  const char* p = s;
+  const char* q = s;
+  int done      = 0;
 
   if (s[0] == '\0')
     return res;
@@ -233,12 +231,10 @@ xbt_dynar_t xbt_str_split(const char *s, const char *sep)
 xbt_dynar_t xbt_str_split_str(const char *s, const char *sep)
 {
   xbt_dynar_t res = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
-  int done;
-  const char *p, *q;
 
-  p = s;
-  q = s;
-  done = 0;
+  const char* p = s;
+  const char* q = s;
+  int done      = 0;
 
   if (s[0] == '\0')
     return res;
@@ -287,10 +283,12 @@ xbt_dynar_t xbt_str_split_str(const char *s, const char *sep)
  */
 xbt_dynar_t xbt_str_split_quoted_in_place(char *s) {
   xbt_dynar_t res = xbt_dynar_new(sizeof(char *), nullptr);
-  char *beg, *end;              /* pointers around the parsed chunk */
-  int in_simple_quote = 0, in_double_quote = 0;
-  int done = 0;
-  int ctn = 0;                  /* Got something in this block */
+  char* beg;
+  char* end; /* pointers around the parsed chunk */
+  int in_simple_quote = 0;
+  int in_double_quote = 0;
+  int done            = 0;
+  int ctn             = 0; /* Got something in this block */
 
   if (s[0] == '\0')
     return res;
@@ -403,8 +401,7 @@ char *xbt_str_join(xbt_dynar_t dyn, const char *sep)
 {
   int len = 1, dyn_len = xbt_dynar_length(dyn);
   unsigned int cpt;
-  char *cursor;
-  char *res, *p;
+  char* cursor;
 
   if (!dyn_len)
     return xbt_strdup("");
@@ -415,8 +412,8 @@ char *xbt_str_join(xbt_dynar_t dyn, const char *sep)
   }
   len += strlen(sep) * dyn_len;
   /* Do the job */
-  res = (char*) xbt_malloc(len);
-  p = res;
+  char* res = (char*)xbt_malloc(len);
+  char* p   = res;
   xbt_dynar_foreach(dyn, cpt, cursor) {
     if ((int) cpt < dyn_len - 1)
       p += snprintf(p,len, "%s%s", cursor, sep);
@@ -433,26 +430,24 @@ char *xbt_str_join(xbt_dynar_t dyn, const char *sep)
  */
 char *xbt_str_join_array(const char *const *strs, const char *sep)
 {
-  char *res,*q;
   int amount_strings=0;
   int len=0;
-  int i;
 
   if ((!strs) || (!strs[0]))
     return xbt_strdup("");
 
   /* compute the length before malloc */
-  for (i=0;strs[i];i++) {
+  for (int i = 0; strs[i]; i++) {
     len += strlen(strs[i]);
     amount_strings++;
   }
   len += strlen(sep) * amount_strings;
 
   /* Do the job */
-  res = (char*) xbt_malloc(len);
-  q = res;
-  for (i=0;strs[i];i++) {
-    if (i!=0) { // not first loop
+  char* res = (char*)xbt_malloc(len);
+  char* q   = res;
+  for (int i = 0; strs[i]; i++) {
+    if (i != 0) { // not first loop
       q += snprintf(q,len, "%s%s", sep, strs[i]);
     } else {
       q += snprintf(q,len, "%s",strs[i]);
@@ -468,7 +463,7 @@ char *xbt_str_join_array(const char *const *strs, const char *sep)
  */
 long int xbt_str_parse_int(const char* str, const char* error_msg)
 {
-  char *endptr;
+  charendptr;
   if (str == nullptr || str[0] == '\0')
     THROWF(arg_error, 0, error_msg, str);
 
index 5baf868..d654328 100644 (file)
@@ -61,7 +61,8 @@ static void dump_platform()
   int version = 4;
   xbt_dict_t props = nullptr;
   xbt_dict_cursor_t cursor = nullptr;
-  char *key, *data;
+  char* key;
+  char* data;
 
   std::printf("<?xml version='1.0'?>\n");
   std::printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n");