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>
Thu, 9 Jun 2016 14:51:26 +0000 (16:51 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 9 Jun 2016 14:51:26 +0000 (16:51 +0200)
examples/java/trace/pingpong/Main.java
examples/java/trace/pingpong/Sender.java
src/bindings/java/org/simgrid/msg/Semaphore.java
src/simix/simcalls.py
teshsuite/surf/surf_usage/surf_usage.cpp
teshsuite/surf/surf_usage/surf_usage.tesh

index 1e82ea8..bd43e17 100644 (file)
@@ -14,8 +14,8 @@ public class Main  {
   public static void main(String[] args) throws MsgException, NativeException {
     Msg.init(args);
     if(args.length < 1) {
-      Msg.info("Usage   : TracingTest platform_file");
-      Msg.info("example : TracingTest ../platforms/platform.xml");
+      Msg.info("Usage   : Main platform_file");
+      Msg.info("example : Main ../platforms/platform.xml");
       System.exit(1);
     }
 
index f17cabd..5fe2760 100644 (file)
@@ -15,8 +15,9 @@ import org.simgrid.msg.HostNotFoundException;
 import org.simgrid.trace.Trace;
 
 public class Sender extends Process {
-  private final double commSizeLat = 1;
-  private final double commSizeBw = 100000000;
+  private static final double commSizeLat = 1;
+  private static final double commSizeBw = 100000000;
+  private static final String PM_STATE = "PM_STATE";
 
   public Sender(String hostname, String name, String[] args) throws HostNotFoundException, NativeException {
     super(hostname,name,args);
@@ -24,22 +25,17 @@ public class Sender extends Process {
 
   public void main(String[] args) throws MsgException {
     Msg.info("hello !"); 
-    Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPing");
+    Trace.hostPushState (getHost().getName(), PM_STATE, "sendingPing");
 
     int hostCount = args.length;
     Msg.info("host count: " + hostCount);
     String mailboxes[] = new String[hostCount]; 
     double time;
     double computeDuration = 0;
-    PingPongTask ping, pong;
+    PingPongTask ping;
 
     for(int pos = 0; pos < args.length ; pos++) {
-      try {
-        mailboxes[pos] = Host.getByName(args[pos]).getName();
-      } catch (HostNotFoundException e) {
-        Msg.info("Invalid deployment file: " + e.toString());
-        System.exit(1);
-      }
+      mailboxes[pos] = Host.getByName(args[pos]).getName();
     }
 
     for (int pos = 0; pos < hostCount; pos++) { 
@@ -49,15 +45,15 @@ public class Sender extends Process {
       ping.setTime(time);
       ping.send(mailboxes[pos]);
 
-      Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPong");
-      pong = (PingPongTask)Task.receive(getHost().getName());
+      Trace.hostPushState (getHost().getName(), PM_STATE, "waitingPong");
+      PingPongTask pong = (PingPongTask)Task.receive(getHost().getName());
       double timeGot = Msg.getClock();
       double timeSent = ping.getTime();
-      double communicationTime=0;
+      double communicationTime;
 
       Msg.info("Got at time "+ timeGot);
       Msg.info("Was sent at time "+timeSent);
-      time=timeSent;
+      time = timeSent;
 
       communicationTime=timeGot - time;
       Msg.info("Communication time : " + communicationTime);
@@ -65,11 +61,11 @@ public class Sender extends Process {
       Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
 
       /* Pop the last state (going back to sending ping) */  
-      Trace.hostPopState (getHost().getName(), "PM_STATE");
+      Trace.hostPopState (getHost().getName(), PM_STATE);
     }
 
     /* Pop the sendingPong state */  
-    Trace.hostPopState (getHost().getName(), "PM_STATE");
+    Trace.hostPopState (getHost().getName(), PM_STATE);
     Msg.info("goodbye!");
   }
 }
index 0172aa3..4952184 100644 (file)
@@ -34,6 +34,7 @@ public class Semaphore {
        /** Locks on the semaphore object until the provided timeout expires
         * @exception TimeoutException if the timeout expired before 
         *            the semaphore could be acquired.
+        * @param timeout the duration of the lock
         */
        public native void acquire(double timeout) throws TimeoutException;
        /** Locks on the semaphore object with no timeout
@@ -42,8 +43,8 @@ public class Semaphore {
                try {
                        acquire(-1);
                } catch (TimeoutException e) {
-                       // This should not happen.
-                       assert(false);
+                       e.printStackTrace(); // This should not happen.
+                       assert false ;
                }
        }
        /** Releases the semaphore object
index adca709..7d1b2b7 100755 (executable)
@@ -36,15 +36,15 @@ class Simcall(object):
         # libsmx.c  simcall_BODY_
         if self.simcalls_BODY is None:
             f = open('libsmx.cpp')
-            self.simcalls_BODY = set(
-                re.findall('simcall_BODY_(.*?)\(', f.read()))
+            self.simcalls_BODY = set(re.findall('simcall_BODY_(.*?)\(', f.read()))
             f.close()
         if self.name not in self.simcalls_BODY:
-            print '# ERROR: No function calling simcall_BODY_%s' % self.name
-            print '# Add something like this to libsmx.c:'
-            print '%s simcall_%s(%s) {' % (self.res.rettype(), self.name, ', '.join('%s %s' % (arg.rettype(), arg.name) for arg in self.args))
-            print '  return simcall_BODY_%s(%s);' % (self.name, "...")
-            print '}'
+            print ('# ERROR: No function calling simcall_BODY_%s' % self.name)
+            print ('# Add something like this to libsmx.c:')
+            print ('%s simcall_%s(%s) {' % (self.res.rettype(), self.name, ', '.
+                   join('%s %s' % (arg.rettype(), arg.name) for arg in self.args)))
+            print ('  return simcall_BODY_%s(%s);' % (self.name, "..."))
+            print ('}')
             return False
 
         # smx_*.c void simcall_HANDLER_host_on(smx_simcall_t simcall,
@@ -53,22 +53,21 @@ class Simcall(object):
             self.simcalls_PRE = set()
             for fn in glob.glob('smx_*') + glob.glob('../mc/*'):
                 f = open(fn)
-                self.simcalls_PRE |= set(
-                    re.findall('simcall_HANDLER_(.*?)\(', f.read()))
+                self.simcalls_PRE |= set(re.findall('simcall_HANDLER_(.*?)\(', f.read()))
                 f.close()
         if self.need_handler:
-            if (self.name not in self.simcalls_PRE):
-                print '# ERROR: No function called simcall_HANDLER_%s' % self.name
-                print '# Add something like this to the relevant C file (like smx_io.c if it\'s an IO call):'
-                print '%s simcall_HANDLER_%s(smx_simcall_t simcall%s) {' % (self.res.rettype(), self.name, ''.join(', %s %s' % (arg.rettype(), arg.name)
-                                                                                                                   for arg in self.args))
-                print '  // Your code handling the simcall'
-                print '}'
+            if self.name not in self.simcalls_PRE:
+                print ('# ERROR: No function called simcall_HANDLER_%s' % self.name)
+                print ('# Add something like this to the relevant C file (like smx_io.c if it\'s an IO call):')
+                print ('%s simcall_HANDLER_%s(smx_simcall_t simcall%s) {' % (self.res.rettype(), self.name, ''.
+                       join(', %s %s' % (arg.rettype(), arg.name)for arg in self.args)))
+                print ('  // Your code handling the simcall')
+                print ('}')
                 return False
         else:
-            if (self.name in self.simcalls_PRE):
-                print '# ERROR: You have a function called simcall_HANDLER_%s, but that simcall is not using any handler' % self.name
-                print '# Either change your simcall definition, or kill that function'
+            if self.name in self.simcalls_PRE:
+                print ('# ERROR: You have a function called simcall_HANDLER_%s, but that simcall is not using any handler' % self.name)
+                print ('# Either change your simcall definition, or kill that function')
                 return False
         return True
 
@@ -108,7 +107,7 @@ class Simcall(object):
 
     def case(self):
         res = []
-        args = [ ("simgrid::simix::unmarshal<%s>(simcall->args[%d])" % (arg.rettype(), i))
+        args = [ "simgrid::simix::unmarshal<%s>(simcall->args[%d])" % (arg.rettype(), i)
             for i, arg in enumerate(self.args) ]
         res.append('case SIMCALL_%s:' % (self.name.upper()))
         if self.need_handler:
index 949c7be..75ffa7c 100644 (file)
@@ -12,6 +12,7 @@
 #include "surf/surf.h"
 #include "src/surf/surf_interface.hpp"
 #include "src/surf/cpu_interface.hpp"
+#include "src/surf/network_interface.hpp"
 
 #include "xbt/log.h"
 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
@@ -54,9 +55,9 @@ int main(int argc, char **argv)
   XBT_DEBUG("%s : %p", sg_host_get_name(hostB), hostB);
 
   /* Let's do something on it */
-  surf_action_t actionA = hostA->pimpl_cpu->execution_start(1000.0);
-  surf_action_t actionB = hostB->pimpl_cpu->execution_start(1000.0);
-  surf_action_t actionC = surf_host_sleep(hostB, 7.32);
+  simgrid::surf::Action *actionA = hostA->pimpl_cpu->execution_start(1000.0);
+  simgrid::surf::Action *actionB = hostB->pimpl_cpu->execution_start(1000.0);
+  simgrid::surf::Action *actionC = surf_host_sleep(hostB, 7.32);
 
   /* Use whatever calling style you want... */
   simgrid::surf::Action::State stateActionA = actionA->getState(); /* When you know actionA model type */
@@ -74,34 +75,53 @@ int main(int argc, char **argv)
 
   surf_solve(-1.0);
   do {
-    surf_action_t action = nullptr;
+    simgrid::surf::ActionList *action_list = nullptr;
     now = surf_get_clock();
     XBT_INFO("Next Event : %g", now);
     XBT_DEBUG("\t CPU actions");
-    while ((action = surf_model_extract_failed_action_set((surf_model_t)surf_cpu_model_pm))) {
+
+    action_list = surf_cpu_model_pm->getFailedActionSet();
+    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
+        it != itend ; it=itNext) {
+      ++itNext;
+      simgrid::surf::Action *action = static_cast<simgrid::surf::CpuAction*>(&*it);
        XBT_INFO("   CPU Failed action");
        XBT_DEBUG("\t * Failed : %p", action);
        action->unref();
     }
-    while ((action = surf_model_extract_done_action_set((surf_model_t)surf_cpu_model_pm))) {
+
+    action_list = surf_cpu_model_pm->getDoneActionSet();
+    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
+        it != itend ; it=itNext) {
+      ++itNext;
+      simgrid::surf::Action *action = static_cast<simgrid::surf::CpuAction*>(&*it);
       XBT_INFO("   CPU Done action");
       XBT_DEBUG("\t * Done : %p", action);
       action->unref();
     }
-    XBT_DEBUG("\t Network actions");
-    while ((action = surf_model_extract_failed_action_set((surf_model_t)surf_network_model))) {
-      XBT_INFO("   Network Failed action");
-      XBT_DEBUG("\t * Failed : %p", action);
-      action->unref();
+
+    action_list = surf_network_model->getFailedActionSet();
+    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
+        it != itend ; it=itNext) {
+      ++itNext;
+      simgrid::surf::Action *action = static_cast<simgrid::surf::NetworkAction*>(&*it);
+       XBT_INFO("   Network Failed action");
+       XBT_DEBUG("\t * Failed : %p", action);
+       action->unref();
     }
-    while ((action = surf_model_extract_done_action_set((surf_model_t)surf_network_model))) {
-      XBT_INFO("   Network Failed action");
+
+    action_list = surf_network_model->getDoneActionSet();
+    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
+        it != itend ; it=itNext) {
+      ++itNext;
+      simgrid::surf::Action *action = static_cast<simgrid::surf::NetworkAction*>(&*it);
+      XBT_INFO("   Network Done action");
       XBT_DEBUG("\t * Done : %p", action);
       action->unref();
     }
 
-  } while ((surf_model_running_action_set_size((surf_model_t)surf_network_model) ||
-            surf_model_running_action_set_size((surf_model_t)surf_cpu_model_pm)) && surf_solve(-1.0) >= 0.0);
+  } while ((surf_network_model->getRunningActionSet()->size() ||
+           surf_cpu_model_pm->getRunningActionSet()->size()) && surf_solve(-1.0) >= 0.0);
 
   XBT_DEBUG("Simulation Terminated");
 
index ba50b64..a4bc242 100644 (file)
@@ -10,7 +10,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/surf_usage ${srcdir:=.}/../../../examples/platform
 > [0.000000] [surf_test/INFO]    CPU Failed action
 > [0.200000] [surf_test/INFO] Next Event : 0.2
 > [0.200016] [surf_test/INFO] Next Event : 0.200016
-> [0.200016] [surf_test/INFO]    Network Failed action
+> [0.200016] [surf_test/INFO]    Network Done action
 > [7.320000] [surf_test/INFO] Next Event : 7.32
 > [7.320000] [surf_test/INFO]    CPU Done action
 > [10.000000] [surf_test/INFO] Next Event : 10