Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add priority example/test
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Tue, 12 Jun 2012 08:19:35 +0000 (10:19 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Tue, 12 Jun 2012 08:19:35 +0000 (10:19 +0200)
CMakeLists.txt
examples/priority/Priority.java [new file with mode: 0644]
examples/priority/Test.java [new file with mode: 0644]
examples/priority/priority.tesh [new file with mode: 0644]
examples/priority/priorityDeployment.xml [new file with mode: 0644]

index 94aef31..12a9255 100644 (file)
@@ -268,6 +268,7 @@ add_custom_command(
   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/*.java
   COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java                                      
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
+       COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/priority/*.java    
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/*.java
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/suspend/*.java
 
@@ -302,10 +303,11 @@ ADD_TEST(chord             ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_
 ADD_TEST(kill            ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/kill.tesh)
 ADD_TEST(mutualExclusion ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.tesh)
 ADD_TEST(pingPong        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingpong.tesh)
+ADD_TEST(priority        ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/priority/priority.tesh)
 ADD_TEST(startKillTime   ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh)
 ADD_TEST(suspend         ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspend.tesh)
 #Don't forget to put new test in this list!!!
-set(test_list async basic bittorrent bypass chord commTime kill mutualExclusion pingPong startKillTime)
+set(test_list async basic bittorrent bypass chord commTime kill mutualExclusion pingPong priority startKillTime)
 
 ##########################################
 # Set the  DYLD_LIBRARY_PATH for mac     #
diff --git a/examples/priority/Priority.java b/examples/priority/Priority.java
new file mode 100644 (file)
index 0000000..e5bcfb7
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * $Id$
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier         
+ * All rights reserved. 
+ *
+ * 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. 
+ */
+package priority;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.NativeException;
+/**
+ * Demonstrates the use of Task.setPriority to change
+ * the computation priority of a task
+ */ 
+public class Priority  {
+
+   /* This only contains the launcher. If you do nothing more than than you can run 
+    *   java simgrid.msg.Msg
+    * which also contains such a launcher
+    */
+    
+    public static void main(String[] args) throws NativeException {            
+               /* initialize the MSG simulation. Must be done before anything else (even logging). */
+               Msg.init(args);
+               if(args.length < 2) {
+                       Msg.info("Usage   : Priority platform_file deployment_file");
+               Msg.info("example : Priority ping_pong_platform.xml ping_pong_deployment.xml");
+               System.exit(1);
+               }
+       
+               /* construct the platform and deploy the application */
+               Msg.createEnvironment(args[0]);
+               Msg.deployApplication(args[1]);
+               
+               /*  execute the simulation. */
+           Msg.run();
+    }
+}
diff --git a/examples/priority/Test.java b/examples/priority/Test.java
new file mode 100644 (file)
index 0000000..365e8df
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 2012. The SimGrid Team. All rights reserved. 
+ *
+ * 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. 
+ */
+package priority;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+
+public class Test extends Process {
+       public Test(Host host, String name, String[]args) {
+               super(host,name,args);
+       }
+       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]);
+               
+               Msg.info("Hello! Running a task of size " + computationAmount + " with priority " + priority);
+               
+               Task task = new Task("Task", computationAmount, 0);
+               task.setPriority(priority);
+               
+               task.execute();
+               
+               Msg.info("Goodbye now!");
+       }
+}
diff --git a/examples/priority/priority.tesh b/examples/priority/priority.tesh
new file mode 100644 (file)
index 0000000..9501626
--- /dev/null
@@ -0,0 +1,15 @@
+#! ./tesh
+
+! output sort
+
+$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar priority/Priority ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/priority/priorityDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:@) Ready to run MSG_MAIN
+> [  0.000000] (1:priority.Test@Fafard) Hello! Running a task of size 7.6296E7 with priority 1.0
+> [  0.000000] (2:priority.Test@Fafard) Hello! Running a task of size 7.6296E7 with priority 2.0
+> [  0.833332] (2:priority.Test@Fafard) Goodbye now!
+> [  1.111109] (0:@) Done running MSG_MAIN
+> [  1.111109] (0:@) MSG_main finished
+> [  1.111109] (0:@) Clean java world
+> [  1.111109] (0:@) Clean native world
+> [  1.111109] (1:priority.Test@Fafard) Goodbye now!
+
diff --git a/examples/priority/priorityDeployment.xml b/examples/priority/priorityDeployment.xml
new file mode 100644 (file)
index 0000000..78c4958
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+  <process host="Fafard" function="priority.Test">
+       <argument value="76296000"/>
+       <argument value="1.0"/>
+  </process>
+  <process host="Fafard" function="priority.Test">
+       <argument value="76296000"/>
+       <argument value="2.0"/>
+  </process>
+</platform>