Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 28 Jun 2016 09:56:55 +0000 (11:56 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 28 Jun 2016 09:56:55 +0000 (11:56 +0200)
20 files changed:
examples/java/app/bittorrent/Peer.java
examples/java/app/bittorrent/Tracker.java
examples/java/dht/chord/ChordTask.java
examples/java/dht/chord/FindSuccessorAnswerTask.java
examples/java/dht/chord/FindSuccessorTask.java
examples/java/dht/chord/GetPredecessorAnswerTask.java
examples/java/dht/chord/Node.java
examples/java/dht/chord/NotifyTask.java
examples/java/dht/kademlia/Node.java
examples/java/io/file/Node.java
examples/java/process/startkilltime/Sleeper.java
examples/java/task/priority/Test.java
examples/java/trace/pingpong/Sender.java
src/bindings/java/JavaContext.cpp
src/bindings/java/jmsg.cpp
src/bindings/java/jmsg_as.cpp
src/bindings/java/jmsg_comm.cpp
src/bindings/java/org/simgrid/msg/Process.java
src/simdag/sd_daxloader.cpp
src/simdag/sd_task.cpp

index 58b4b48..0bdc770 100644 (file)
@@ -50,12 +50,12 @@ public class Peer extends Process {
       Msg.info("Wrong number of arguments");
     }
     if (args.length == 3) {
-      init(Integer.valueOf(args[0]),true);
+      init(Integer.parseInt(args[0]),true);
     } else {
-      init(Integer.valueOf(args[0]),false);
+      init(Integer.parseInt(args[0]),false);
     }
     //Retrieve the deadline
-    deadline = Double.valueOf(args[1]);
+    deadline = Double.parseDouble(args[1]);
     if (deadline < 0) {
       Msg.info("Wrong deadline supplied");
       return;
index f613bb9..c6a1862 100644 (file)
@@ -34,7 +34,7 @@ public class Tracker extends Process {
     //Build the RngStream object for randomness
     stream = new RngStream("tracker");
     //Retrieve the end time
-    deadline = Double.valueOf(args[0]);
+    deadline = Double.parseDouble(args[0]);
     //Building peers array
     peersList = new ArrayList<>();
 
index 0e5edfc..e43fc8b 100644 (file)
@@ -10,11 +10,20 @@ import dht.chord.Common;
 import org.simgrid.msg.Task;
 
 public class ChordTask extends Task {
-  public String issuerHostName;
-  public String answerTo;
+  private String issuerHostName;
+  private String answerTo;
   public ChordTask() {
     this(null,null);
   }
+
+  public String getIssuerHostName(){
+    return this.issuerHostName;
+  }
+
+  public String getAnswerTo(){
+    return this.answerTo;
+  }
+
   public ChordTask(String issuerHostName, String answerTo) {
     super(null, Common.COMP_SIZE, Common.COMM_SIZE);
     this.issuerHostName = issuerHostName;
index cb46127..9d2440a 100644 (file)
@@ -7,7 +7,10 @@
 package dht.chord;
 
 public class FindSuccessorAnswerTask extends ChordTask {
-  public int answerId;
+  private int answerId;
+  public int getAnswerId(){
+    return this.answerId;
+  }
 
   public FindSuccessorAnswerTask(String issuerHostname, String answerTo, int answerId) {
     super(issuerHostname,answerTo);
index 0c78f8b..a16d9ca 100644 (file)
@@ -7,7 +7,11 @@
 package dht.chord;
 
 public class FindSuccessorTask extends ChordTask {
-  public int requestId;
+  private int requestId;
+
+  public int getRequestId(){
+    return this.requestId;
+  }
 
   public FindSuccessorTask(String issuerHostname, String answerTo,  int requestId) {
     super(issuerHostname, answerTo);
index d0d35ab..d9ff5c8 100644 (file)
@@ -7,7 +7,12 @@
 package dht.chord;
 
 public class GetPredecessorAnswerTask extends ChordTask {
-  public int answerId;
+  private int answerId;
+
+  public int getAnswerId(){
+    return this.answerId;
+  }
+
   public GetPredecessorAnswerTask(String issuerHostname, String answerTo, int answerId) {
     super(issuerHostname,answerTo);
     this.answerId = answerId;
index 275c75e..2cb52d8 100644 (file)
@@ -112,26 +112,27 @@ public class Node extends Process {
   void handleTask(Task task) {
     if (task instanceof FindSuccessorTask) {
       FindSuccessorTask fTask = (FindSuccessorTask)task;
-      Msg.debug("Receiving a 'Find Successor' request from " + fTask.issuerHostName + " for id " + fTask.requestId);
+      Msg.debug("Receiving a 'Find Successor' request from " + fTask.getIssuerHostName() + " for id " + 
+                fTask.getRequestId());
       // is my successor the successor?
-      if (isInInterval(fTask.requestId, this.id + 1, fingers[0])) {
-        Msg.debug("Send the request to " + fTask.answerTo + " with answer " + fingers[0]);
+      if (isInInterval(fTask.getRequestId(), this.id + 1, fingers[0])) {
+        Msg.debug("Send the request to " + fTask.getAnswerTo() + " with answer " + fingers[0]);
         FindSuccessorAnswerTask answer = new FindSuccessorAnswerTask(getHost().getName(), mailbox, fingers[0]);
-        answer.dsend(fTask.answerTo);
+        answer.dsend(fTask.getAnswerTo());
       } else {
         // otherwise, forward the request to the closest preceding finger in my table
-        int closest = closestPrecedingNode(fTask.requestId);
+        int closest = closestPrecedingNode(fTask.getRequestId());
         Msg.debug("Forward the request to " + closest);
         fTask.dsend(Integer.toString(closest));
       }
     } else if (task instanceof GetPredecessorTask) {
       GetPredecessorTask gTask = (GetPredecessorTask)(task);
-      Msg.debug("Receiving a 'Get Predecessor' request from " + gTask.issuerHostName);
+      Msg.debug("Receiving a 'Get Predecessor' request from " + gTask.getIssuerHostName());
       GetPredecessorAnswerTask answer = new GetPredecessorAnswerTask(getHost().getName(), mailbox, predId);
-      answer.dsend(gTask.answerTo);
+      answer.dsend(gTask.getAnswerTo());
     } else if (task instanceof NotifyTask) {
       NotifyTask nTask = (NotifyTask)task;
-      notify(nTask.requestId);
+      notify(nTask.getRequestId());
     } else {
       Msg.debug("Ignoring unexpected task of type:" + task);
     }
@@ -203,7 +204,7 @@ public class Node extends Process {
           commReceive.waitCompletion(Common.TIMEOUT);
           Task taskReceived = commReceive.getTask();
           if (taskReceived instanceof GetPredecessorAnswerTask) {
-            predecessorId = ((GetPredecessorAnswerTask) taskReceived).answerId;
+            predecessorId = ((GetPredecessorAnswerTask) taskReceived).getAnswerId();
             stop = true;
           } else {
             handleTask(taskReceived);
@@ -257,7 +258,7 @@ public class Node extends Process {
             //TODO: Check if this this our answer.
             FindSuccessorAnswerTask fTask = (FindSuccessorAnswerTask) task;
             stop = true;
-            successor = fTask.answerId;
+            successor = fTask.getAnswerId();
           } else {
             handleTask(task);
           }
index daf4129..fcc580a 100644 (file)
@@ -7,7 +7,11 @@
 package dht.chord;
 
 public class NotifyTask extends ChordTask {
-  public int requestId;
+  private int requestId;
+  public int getRequestId(){
+    return this.requestId;
+  }
+
   public NotifyTask(String issuerHostname, String answerTo, int requestId) {
     super(issuerHostname, answerTo);
     this.requestId = requestId;
index 25124b6..4e46ba0 100644 (file)
@@ -33,13 +33,13 @@ public class Node extends Process {
       Msg.info("Wrong argument count.");
       return;
     }
-    this.id = Integer.valueOf(args[0]);
+    this.id = Integer.parseInt(args[0]);
     this.table = new RoutingTable(this.id);
 
     if (args.length == 3) {
-      this.deadline = Integer.valueOf(args[2]).intValue();
+      this.deadline = Integer.parseInt(args[2]);
       Msg.info("Hi, I'm going to join the network with the id " + id + "!");
-      if (joinNetwork(Integer.valueOf(args[1]))) {
+      if (joinNetwork(Integer.parseInt(args[1]))) {
         this.mainLoop();
       }
       else {
@@ -47,7 +47,7 @@ public class Node extends Process {
       }
     }
     else {
-      this.deadline = Integer.valueOf(args[1]).intValue();
+      this.deadline = Integer.parseInt(args[1]);
       Msg.info("Hi, I'm going to create the network with the id " + id + "!");
       table.update(this.id);
       this.mainLoop();
@@ -109,12 +109,10 @@ public class Node extends Process {
           } else {
             Task task = comm.getTask();
             if (task instanceof FindNodeAnswerTask) {
-              answerGot = true;
               //Retrieve the node list and ping them
               FindNodeAnswerTask answerTask = (FindNodeAnswerTask)task;
               Answer answer = answerTask.getAnswer();
               answerGot = true;
-              //answersGotten++;
               if (answer.getDestinationId() == this.id) {
                 //Ping everyone in the list
                 for (Contact c : answer.getNodes()) {
@@ -155,8 +153,8 @@ public class Node extends Process {
   public boolean findNode(int destination, boolean counts) {
     int queries;
     int answers;
-    int nodesAdded = 0;
-    boolean destinationFound = false;
+    int nodesAdded;
+    boolean destinationFound;
     int steps = 0;
     double timeBeginReceive;
     double timeout;
index 3044f17..8339064 100644 (file)
@@ -39,7 +39,7 @@ public class Node extends Process {
   }
 
   public void main(String[] args) throws MsgException {
-    String mount = "";
+    String mount;
     String filename;
     switch (number) {
       case 0:
index fe1310e..7a30764 100644 (file)
@@ -18,7 +18,7 @@ public class Sleeper extends Process {
   public void main(String[] args) throws MsgException {
     Msg.info("Hello! I go to sleep.");
     try {
-      waitFor(Integer.valueOf(args[0]).intValue());
+      waitFor(Integer.parseInt(args[0]));
       Msg.info("Done sleeping");
     } catch (MsgException e) {
       Msg.debug("Wait cancelled.");
index 7edd279..f84234d 100644 (file)
@@ -17,11 +17,8 @@ public class Test extends Process {
   }
 
   public void main(String[] args) throws MsgException {  
-    double computationAmount = 1.0;
-    double priority = 1.0;
-
-    computationAmount = Double.valueOf(args[0]);
-    priority = Double.valueOf(args[1]);
+    double computationAmount = Double.parseDouble(args[0]);
+    double priority = Double.parseDouble(args[1]);
 
     Msg.info("Hello! Running a task of size " + computationAmount + " with priority " + priority);
 
index 0204316..256a4b8 100644 (file)
@@ -46,7 +46,7 @@ public class Sender extends Process {
       ping.send(mailboxes[pos]);
 
       Trace.hostPushState (getHost().getName(), PM_STATE, "waitingPong");
-      PingPongTask pong = (PingPongTask)Task.receive(getHost().getName());
+      Task.receive(getHost().getName());
       double timeGot = Msg.getClock();
       double timeSent = ping.getTime();
       double communicationTime;
index 9d0218d..19f7601 100644 (file)
@@ -29,18 +29,15 @@ simgrid::simix::ContextFactory* java_factory()
   return new JavaContextFactory();
 }
 
-JavaContextFactory::JavaContextFactory()
-  : ContextFactory("JavaContextFactory")
+JavaContextFactory::JavaContextFactory(): ContextFactory("JavaContextFactory")
 {
 }
 
-JavaContextFactory::~JavaContextFactory()
-{
-}
+JavaContextFactory::~JavaContextFactory()=default;
 
 JavaContext* JavaContextFactory::self()
 {
-  return (JavaContext*) xbt_os_thread_get_extra_data();
+  return static_cast<JavaContext*>(xbt_os_thread_get_extra_data());
 }
 
 JavaContext* JavaContextFactory::create_context(
@@ -109,13 +106,13 @@ JavaContext::~JavaContext()
 
 void* JavaContext::wrapper(void *data)
 {
-  JavaContext* context = (JavaContext*)data;
+  JavaContext* context = static_cast<JavaContext*>(data);
   xbt_os_thread_set_extra_data(context);
   //Attach the thread to the JVM
 
   JNIEnv *env;
   XBT_ATTRIB_UNUSED jint error =
-    __java_vm->AttachCurrentThread((void **) &env, nullptr);
+    __java_vm->AttachCurrentThread((void **)&env, nullptr);
   xbt_assert((error == JNI_OK), "The thread could not be attached to the JVM");
   context->jenv = get_current_thread_env();
   //Wait for the first scheduling round to happen.
index 71035a3..05add7c 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <simgrid/msg.h>
 #include <simgrid/simix.h>
+#include "simgrid/plugins/energy.h"
 #include <locale.h>
 #include <src/simix/smx_private.h>
 
@@ -39,12 +40,12 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg);
 
 JavaVM *__java_vm = nullptr;
 
-JavaVM *get_java_VM(void)
+JavaVM *get_java_VM()
 {
   return __java_vm;
 }
 
-JNIEnv *get_current_thread_env(void)
+JNIEnv *get_current_thread_env()
 {
   JNIEnv *env;
 
@@ -251,6 +252,10 @@ Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls, jstring jde
 
 SG_END_DECL()
 
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_energyInit() {
+  sg_energy_plugin_init();
+}
+
 /** Run a Java org.simgrid.msg.Process
  *
  *  If needed, this waits for the process starting time.
@@ -275,7 +280,7 @@ static void run_jprocess(JNIEnv *env, jobject jprocess)
 static int java_main(int argc, char *argv[])
 {
   JNIEnv *env = get_current_thread_env();
-  simgrid::java::JavaContext* context = (simgrid::java::JavaContext*) SIMIX_context_self();
+  simgrid::java::JavaContext* context = static_cast<simgrid::java::JavaContext*>(SIMIX_context_self());
 
   //Change the "." in class name for "/".
   xbt_str_subst(argv[0],'.','/',0);
@@ -289,11 +294,9 @@ static int java_main(int argc, char *argv[])
   //Retrieve the name of the process.
   jstring jname = env->NewStringUTF(argv[0]);
   //Build the arguments
-  jobjectArray args = (jobjectArray)env->NewObjectArray(argc - 1,
-    env->FindClass("java/lang/String"),
-    env->NewStringUTF(""));
-  int i;
-  for (i = 1; i < argc; i++)
+  jobjectArray args = static_cast<jobjectArray>(env->NewObjectArray(argc - 1, env->FindClass("java/lang/String"),
+                                                                    env->NewStringUTF("")));
+  for (int i = 1; i < argc; i++)
       env->SetObjectArrayElement(args,i - 1, env->NewStringUTF(argv[i]));
   //Retrieve the host for the process.
   jstring jhostName = env->NewStringUTF(MSG_host_get_name(MSG_host_self()));
@@ -307,8 +310,8 @@ static int java_main(int argc, char *argv[])
 
   context->jprocess = jprocess;
   /* sets the PID and the PPID of the process */
-  env->SetIntField(jprocess, jprocess_field_Process_pid,(jint) MSG_process_get_PID(process));
-  env->SetIntField(jprocess, jprocess_field_Process_ppid, (jint) MSG_process_get_PPID(process));
+  env->SetIntField(jprocess, jprocess_field_Process_pid, static_cast<jint>(MSG_process_get_PID(process)));
+  env->SetIntField(jprocess, jprocess_field_Process_ppid, static_cast<jint>(MSG_process_get_PPID(process)));
   jprocess_bind(jprocess, process, env);
 
   run_jprocess(env, context->jprocess);
@@ -322,7 +325,7 @@ namespace java {
 void java_main_jprocess(jobject jprocess)
 {
   JNIEnv *env = get_current_thread_env();
-  simgrid::java::JavaContext* context = (simgrid::java::JavaContext*) SIMIX_context_self();
+  simgrid::java::JavaContext* context = static_cast<simgrid::java::JavaContext*>(SIMIX_context_self());
   context->jprocess = jprocess;
   smx_process_t process = SIMIX_process_self();
   jprocess_bind(context->jprocess, process, env);
@@ -336,9 +339,3 @@ void java_main_jprocess(jobject jprocess)
 
 }
 }
-
-#include "simgrid/plugins/energy.h"
-JNIEXPORT void JNICALL
-Java_org_simgrid_msg_Msg_energyInit(void) {
-  sg_energy_plugin_init();
-}
index df66f45..8f7b031 100644 (file)
@@ -69,7 +69,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getSons(JNIEnv * env, job
     return nullptr;
   }
 
-  jtable = env->NewObjectArray((jsize) count, cls, nullptr);
+  jtable = env->NewObjectArray(static_cast<jsize>(count), cls, nullptr);
 
   if (!jtable) {
     jxbt_throw_jni(env, "Hosts table allocation failed");
@@ -105,7 +105,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv *env, jobje
     jxbt_throw_notbound(env, "as", jas);
     return nullptr;
   }
-  const char *name = env->GetStringUTFChars((jstring) jname, 0);
+  const char *name = env->GetStringUTFChars(static_cast<jstring>(jname), 0);
 
   const char *property = MSG_environment_as_get_property_value(as, name);
   if (!property) {
@@ -114,7 +114,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_As_getProperty(JNIEnv *env, jobje
 
   jobject jproperty = env->NewStringUTF(property);
 
-  env->ReleaseStringUTFChars((jstring) jname, name);
+  env->ReleaseStringUTFChars(static_cast<jstring>(jname), name);
 
   return jproperty;
 }
@@ -137,7 +137,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo
     return nullptr;
   }
 
-  jtable = env->NewObjectArray((jsize) count, cls, nullptr);
+  jtable = env->NewObjectArray(static_cast<jsize>(count), cls, nullptr);
 
   if (!jtable) {
     jxbt_throw_jni(env, "Hosts table allocation failed");
@@ -147,7 +147,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_As_getHosts(JNIEnv * env, jo
   for (index = 0; index < count; index++) {
     host = xbt_dynar_get_as(table,index,msg_host_t);
 
-    jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
+    jhost = static_cast<jobject>(host->extension(JAVA_HOST_LEVEL));
     if (!jhost) {
       jname = env->NewStringUTF(MSG_host_get_name(host));
 
index e258939..9570c3c 100644 (file)
@@ -27,7 +27,7 @@ void jcomm_bind_task(JNIEnv *env, jobject jcomm) {
     //bind the task object.
     msg_task_t task = MSG_comm_get_task(comm);
     xbt_assert(task != nullptr, "Task is nullptr");
-    jobject jtask_global = (jobject) MSG_task_get_data(task);
+    jobject jtask_global = static_cast<jobject>(MSG_task_get_data(task));
     //case where the data has already been retrieved
     if (jtask_global == nullptr) {
       return;
@@ -111,7 +111,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitCompletion(JNIEnv *env, job
   }
 
   msg_error_t status;
-  status = MSG_comm_wait(comm,(double)timeout);
+  status = MSG_comm_wait(comm,static_cast<double>(timeout));
   env->SetBooleanField(jcomm, jcomm_field_Comm_finished, JNI_TRUE);
   if (status == MSG_OK) {
     jcomm_bind_task(env,jcomm);
index d50a475..433259f 100644 (file)
@@ -76,8 +76,8 @@ public abstract class Process implements Runnable {
        private int ppid = -1;
        private Host host = null;
 
-       /** The arguments of the method function of the process. */     
-       public ArrayList<String> args;
+       /** The arguments of the method function of the process. */
+       private ArrayList<String> args;
 
 
        /**  Default constructor */
index ff5f178..d2e15ed 100644 (file)
@@ -8,6 +8,7 @@
 #include "simgrid/simdag.h"
 #include "xbt/misc.h"
 #include "xbt/log.h"
+#include "xbt/str.h"
 #include "xbt/file.h" /* xbt_basename() */
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_daxparse, sd, "Parsing DAX files");
@@ -20,19 +21,12 @@ extern "C" {
   #undef register
 }
 
-static double dax_parse_double(const char *string)
-{
-  double value;
-  int ret = sscanf(string, "%lg", &value);
-  xbt_assert (ret == 1, "Parse error on line %d: %s is not a double", dax_lineno, string);
-  return value;
-}
-
 /* Ensure that transfer tasks have unique names even though a file is used several times */
 
 void uniq_transfer_task_name(SD_task_t task)
 {
-  SD_task_t child, parent;
+  SD_task_t child;
+  SD_task_t parent;
 
   xbt_dynar_t children = SD_task_get_children(task);
   xbt_dynar_t parents = SD_task_get_parents(task);
@@ -89,7 +83,8 @@ bool acyclic_graph_detail(xbt_dynar_t dag){
     next = xbt_dynar_new(sizeof(SD_task_t),nullptr);
     //test if the current iteration is done
     xbt_dynar_foreach(current,count_current,task){
-      if (task == nullptr) continue;
+      if (task == nullptr)
+        continue;
       //push task in next
       task->marked = 1;
       xbt_dynar_foreach(task->tasks_before,count,depbefore){
@@ -117,7 +112,8 @@ bool acyclic_graph_detail(xbt_dynar_t dag){
   xbt_dynar_free(&current);
   all_marked = true;
   xbt_dynar_foreach(dag,count,task){
-    if(task->kind == SD_TASK_COMM_E2E) continue;
+    if(task->kind == SD_TASK_COMM_E2E)
+      continue;
     //test if all tasks are marked
     if(task->marked == 0){
       XBT_WARN("the task %s is not marked",task->name);
@@ -130,14 +126,16 @@ bool acyclic_graph_detail(xbt_dynar_t dag){
 
     current = xbt_dynar_new(sizeof(SD_task_t),nullptr);
     xbt_dynar_foreach(dag,count,task){
-      if(task->kind == SD_TASK_COMM_E2E) continue;
+      if(task->kind == SD_TASK_COMM_E2E)
+        continue;
       if(xbt_dynar_is_empty(task->tasks_before)){
         xbt_dynar_push(current, &task);
       }
     }
 
     xbt_dynar_foreach(dag,count,task){
-      if(task->kind == SD_TASK_COMM_E2E) continue;
+      if(task->kind == SD_TASK_COMM_E2E)
+       continue;
       if(xbt_dynar_is_empty(task->tasks_before)){
         task->marked = 1;
         xbt_dynar_push(current, &task);
@@ -148,7 +146,8 @@ bool acyclic_graph_detail(xbt_dynar_t dag){
       next = xbt_dynar_new(sizeof(SD_task_t),nullptr);
       //test if the current iteration is done
       xbt_dynar_foreach(current,count_current,task){
-        if (task == nullptr) continue;
+        if (task == nullptr)
+          continue;
         //push task in next
         task->marked = 1;
         xbt_dynar_foreach(task->tasks_after,count,depafter){
@@ -176,7 +175,8 @@ bool acyclic_graph_detail(xbt_dynar_t dag){
     xbt_dynar_free(&current);
     all_marked = true;
     xbt_dynar_foreach(dag,count,task){
-      if(task->kind == SD_TASK_COMM_E2E) continue;
+      if(task->kind == SD_TASK_COMM_E2E)
+        continue;
       //test if all tasks are marked
       if(task->marked == 0){
         XBT_WARN("the task %s is in a cycle",task->name);
@@ -197,7 +197,7 @@ static SD_task_t root_task, end_task;
 
 static void dax_task_free(void *task)
 {
-  SD_task_destroy((SD_task_t)task);
+  SD_task_destroy(static_cast<SD_task_t>(task));
 }
 
 /** @brief loads a DAX file describing a DAG
@@ -240,9 +240,11 @@ xbt_dynar_t SD_daxload(const char *filename)
    */
 
   xbt_dict_foreach(files, cursor, name, file) {
-    unsigned int cpt1, cpt2;
+    unsigned int cpt1;
+    unsigned int cpt2;
     SD_task_t newfile;
-    SD_dependency_t depbefore, depafter;
+    SD_dependency_t depbefore;
+    SD_dependency_t depafter;
     if (xbt_dynar_is_empty(file->tasks_before)) {
       xbt_dynar_foreach(file->tasks_after, cpt2, depafter) {
         newfile = SD_task_create_comm_e2e(file->name, nullptr, file->amount);
@@ -283,15 +285,19 @@ xbt_dynar_t SD_daxload(const char *filename)
   xbt_dynar_foreach(result, cpt, file) {
     if (SD_task_get_kind(file) == SD_TASK_COMM_E2E) {
       uniq_transfer_task_name(file);
-    } else if (SD_task_get_kind(file) == SD_TASK_COMP_SEQ){
-      /* If some tasks do not take files as input, connect them to the root, if
-       * they don't produce files, connect them to the end node.
-       */
-      if ((file != root_task) && xbt_dynar_is_empty(file->tasks_before)) {
-        SD_task_dependency_add(nullptr, nullptr, root_task, file);
-      }
-      if ((file != end_task) && xbt_dynar_is_empty(file->tasks_after)) {
-        SD_task_dependency_add(nullptr, nullptr, file, end_task);
+    } else {
+      if (SD_task_get_kind(file) == SD_TASK_COMP_SEQ){
+        /* If some tasks do not take files as input, connect them to the root, if
+         * they don't produce files, connect them to the end node.
+         */
+        if ((file != root_task) && xbt_dynar_is_empty(file->tasks_before)) {
+          SD_task_dependency_add(nullptr, nullptr, root_task, file);
+        }
+        if ((file != end_task) && xbt_dynar_is_empty(file->tasks_after)) {
+          SD_task_dependency_add(nullptr, nullptr, file, end_task);
+        }
+      } else {
+        THROW_IMPOSSIBLE;
       }
     }
   }
@@ -309,20 +315,20 @@ xbt_dynar_t SD_daxload(const char *filename)
   }
 }
 
-void STag_dax__adag(void)
+void STag_dax__adag()
 {
   XBT_ATTRIB_UNUSED double version;
-  version = dax_parse_double(A_dax__adag_version);
+  version = xbt_str_parse_double(A_dax__adag_version, "Parse error: %s is not a double");
 
   xbt_assert(version == 2.1, "Expected version 2.1 in <adag> tag, got %f. Fix the parser or your file", version);
 }
 
-void STag_dax__job(void)
+void STag_dax__job()
 {
-  double runtime = dax_parse_double(A_dax__job_runtime);
+  double runtime = xbt_str_parse_double(A_dax__job_runtime, "Parse error: %s is not a double");
   char *name = bprintf("%s@%s", A_dax__job_id, A_dax__job_name);
   runtime *= 4200000000.;       /* Assume that timings were done on a 4.2GFlops machine. I mean, why not? */
-//  XBT_INFO("See <job id=%s runtime=%s %.0f>",A_dax__job_id,A_dax__job_runtime,runtime);
+  XBT_DEBUG("See <job id=%s runtime=%s %.0f>",A_dax__job_id,A_dax__job_runtime,runtime);
   current_job = SD_task_create_comp_seq(name, nullptr, runtime);
   xbt_dict_set(jobs, A_dax__job_id, current_job, nullptr);
   free(name);
@@ -331,11 +337,11 @@ void STag_dax__job(void)
 
 void STag_dax__uses(void)
 {
-  double size = dax_parse_double(A_dax__uses_size);
+  double size = xbt_str_parse_double(A_dax__uses_size, "Parse error: %s is not a double");
   int is_input = (A_dax__uses_link == A_dax__uses_link_input);
 
-//  XBT_INFO("See <uses file=%s %s>",A_dax__uses_file,(is_input?"in":"out"));
-  SD_task_t file = (SD_task_t)xbt_dict_get_or_null(files, A_dax__uses_file);
+  XBT_DEBUG("See <uses file=%s %s>",A_dax__uses_file,(is_input?"in":"out"));
+  SD_task_t file = static_cast<SD_task_t>(xbt_dict_get_or_null(files, A_dax__uses_file));
   if (file == nullptr) {
     file = SD_task_create_comm_e2e(A_dax__uses_file, nullptr, size);
     xbt_dynar_pop(sd_global->initial_task_set,nullptr);
@@ -356,44 +362,44 @@ void STag_dax__uses(void)
 }
 
 static SD_task_t current_child;
-void STag_dax__child(void)
+void STag_dax__child()
 {
-  current_child = (SD_task_t)xbt_dict_get_or_null(jobs, A_dax__child_ref);
+  current_child = static_cast<SD_task_t>(xbt_dict_get_or_null(jobs, A_dax__child_ref));
   xbt_assert(current_child != nullptr,"Parse error on line %d: Asked to add dependencies to the non-existent %s task",
              dax_lineno, A_dax__child_ref);
 }
 
-void ETag_dax__child(void)
+void ETag_dax__child()
 {
   current_child = nullptr;
 }
 
-void STag_dax__parent(void)
+void STag_dax__parent()
 {
-  SD_task_t parent = (SD_task_t)xbt_dict_get_or_null(jobs, A_dax__parent_ref);
+  SD_task_t parent = static_cast<SD_task_t>(xbt_dict_get_or_null(jobs, A_dax__parent_ref));
   xbt_assert(parent != nullptr, "Parse error on line %d: Asked to add a dependency from %s to %s, but %s does not exist",
              dax_lineno, current_child->name, A_dax__parent_ref, A_dax__parent_ref);
   SD_task_dependency_add(nullptr, nullptr, parent, current_child);
   XBT_DEBUG("Control-flow dependency from %s to %s", current_child->name, parent->name);
 }
 
-void ETag_dax__adag(void)
+void ETag_dax__adag()
 {
-//  XBT_INFO("See </adag>");
+  XBT_DEBUG("See </adag>");
 }
 
 void ETag_dax__job(void)
 {
   current_job = nullptr;
-//  XBT_INFO("See </job>");
+  XBT_DEBUG("See </job>");
 }
 
 void ETag_dax__parent(void)
 {
-//  XBT_INFO("See </parent>");
+  XBT_DEBUG("See </parent>");
 }
 
 void ETag_dax__uses(void)
 {
-//  XBT_INFO("See </uses>");
+  XBT_DEBUG("See </uses>");
 }
index 2e92697..386c765 100644 (file)
@@ -1136,7 +1136,7 @@ void SD_task_schedulev(SD_task_t task, int count, const sg_host_t * list)
           double src_start, src_end, dst_start, dst_end;
           src_nb = before->host_count;
           dst_nb = count;
-          before->host_list = (sg_host_t*) xbt_realloc(before->host_list, (before->host_count+count)*sizeof(sg_host_t));
+          before->host_list = static_cast<sg_host_t*>(xbt_realloc(before->host_list, (before->host_count+count)*sizeof(sg_host_t)));
           for(i=0; i<count; i++)
             before->host_list[before->host_count+i] = task->host_list[i];
 
@@ -1165,8 +1165,7 @@ void SD_task_schedulev(SD_task_t task, int count, const sg_host_t * list)
 
           if (SD_task_get_state(before)< SD_SCHEDULED) {
             SD_task_do_schedule(before);
-            XBT_VERB
-              ("Auto-Schedule redistribution task %s. Send %.f bytes from %d hosts to %d hosts.",
+            XBT_VERB ("Auto-Schedule redistribution task %s. Send %.f bytes from %d hosts to %d hosts.",
                   SD_task_get_name(before),before->amount, src_nb, dst_nb);
             }
         }
@@ -1187,7 +1186,7 @@ void SD_task_schedulev(SD_task_t task, int count, const sg_host_t * list)
           double src_start, src_end, dst_start, dst_end;
           src_nb = count;
           dst_nb = after->host_count;
-          after->host_list = (sg_host_t*) xbt_realloc(after->host_list, (after->host_count+count)*sizeof(sg_host_t));
+          after->host_list = static_cast<sg_host_t*>(xbt_realloc(after->host_list, (after->host_count+count)*sizeof(sg_host_t)));
           for(i=after->host_count - 1; i>=0; i--)
             after->host_list[count+i] = after->host_list[i];
           for(i=0; i<count; i++)