Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'vmtrace'
authorJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Thu, 17 Jan 2013 10:29:37 +0000 (11:29 +0100)
committerJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Thu, 17 Jan 2013 10:29:37 +0000 (11:29 +0100)
examples/cloud/Master.java
examples/masterslave/masterslaveDeployment.xml
org/simgrid/msg/Task.java
org/simgrid/msg/VM.java
org/simgrid/trace/Trace.java
src/jmsg_vm.c
src/jmsg_vm.h
src/jtrace.c
src/jtrace.h
src/smx_context_cojava.c

index 2a46bc5..1551521 100644 (file)
@@ -30,7 +30,7 @@ public class Master extends Process {
                for (int i = 0; i < slavesCount; i++) {
                        Slave slave = new Slave(hosts[i],i);
                        slave.start();
-                       VM vm = new VM(hosts[i],1);
+                       VM vm = new VM(hosts[i],hosts[i]+"_"+i,1);
                        vm.bind(slave);
                        vms.add(vm);
                }
@@ -93,4 +93,4 @@ public class Master extends Process {
                        task.send("slave_" + i);
                }
        }
-}
\ No newline at end of file
+}
index 6c01ac0..7794206 100644 (file)
@@ -2,7 +2,7 @@
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
   <process host="Jacquelin" function="masterslave.Master">
-     <argument value="5"/>     <!-- Amount of tasks to dispatch -->
+     <argument value="5000"/>     <!-- Amount of tasks to dispatch -->
      <argument value="50000"/> <!-- Computation size of each task -->
      <argument value="10"/>    <!-- Communication size of each one -->
      <argument value="7"/>     <!-- Amount of slaves waiting for orders -->
index a81e8fc..59c103b 100644 (file)
@@ -26,9 +26,18 @@ public class Task {
         */
        protected String name;
 
+       private double messageSize;
+
+       static private Long idCpt = 0L;
+
+       private Long id;
+
        /** Default constructor (all fields to 0 or null) */
        public Task() {
                create(null, 0, 0);
+               this.messageSize = 0;
+               setId(idCpt);
+               idCpt++;
        }
 
        /* *              * *
@@ -50,6 +59,9 @@ public class Task {
         */ 
        public Task(String name, double computeDuration, double messageSize) {
                create(name, computeDuration, messageSize);
+               this.messageSize = messageSize;
+               setId(idCpt);
+               idCpt++;
        }
        /**
         * Construct an new parallel task with the specified processing amount and amount for each host
@@ -77,7 +89,7 @@ public class Task {
         *                        methods. This value has to be >= 0.
         * @exception             IllegalArgumentException if compute duration <0 or message size <0
         */
-       final native void create(String name,
+       private final native void create(String name,
                        double computeDuration,
                        double messageSize)
        throws IllegalArgumentException;                
@@ -91,7 +103,7 @@ public class Task {
         * @param messageSizes        An array of doubles
         *
         */
-       final native void parallelCreate(String name,
+       private final native void parallelCreate(String name,
                        Host[]hosts,
                        double[]computeDurations,
                        double[]messageSizes)
@@ -280,4 +292,16 @@ public class Task {
                Msg.nativeInit();
                nativeInit();
        }
+
+       public double getMessageSize() {
+               return this.messageSize;
+       }
+
+       public Long getId() {
+               return id;
+       }
+
+       public void setId(Long id) {
+               this.id = id;
+       }
 }
index 3de79f9..525ea39 100644 (file)
@@ -22,14 +22,17 @@ public class VM {
        private long bind = 0;
        
        private int coreAmount;
+
+        private String name;
        /**
         * @brief Create a new empty VM.
         * @bug it is expected that in the future, the coreAmount parameter will be used
         * to add extra constraints on the execution, but the argument is ignored for now.
         */
-       public VM(Host host, int coreAmount) {
+       public VM(Host host, String name, int coreAmount) {
                this.coreAmount = coreAmount;
-               start(host,coreAmount);
+               this.name = name;
+               start(host,name,coreAmount);
        }
        protected void finalize() {
                destroy();
@@ -42,7 +45,7 @@ public class VM {
         * Natively implemented method starting the VM.
         * @param coreAmount
         */
-       private native void start(Host host, int coreAmount);
+       private native void start(Host host, String name, int coreAmount);
                
        /** @brief Returns whether the given VM is currently suspended
         */     
@@ -88,5 +91,8 @@ public class VM {
         * @brief Reboot the VM, restarting all the processes in it.
         */
        public native void reboot();
-               
-}
\ No newline at end of file
+
+       public String getName() {
+               return name;
+       }               
+}
index be6f085..7943ed4 100644 (file)
@@ -301,4 +301,21 @@ public final class Trace {
         * @param value
         */
        public final static native      void hostVariableSet (String host, String variable, double value);
+
+       /**
+        * Declare a new user variable associated to VMs. 
+        * 
+        * @param variable
+        */
+       public final static native      void vmVariableDeclare (String variable);
+
+       /**
+        * Set the value of a variable of a VM. 
+        * 
+        * @param host
+        * @param variable
+        * @param value
+        */
+       public final static native      void vmVariableSet (String vm, String variable, double value);
 }
index ffa9714..7e98a81 100644 (file)
@@ -28,10 +28,14 @@ Java_org_simgrid_msg_VM_nativeInit(JNIEnv *env, jclass cls) {
   }
 }
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_VM_start(JNIEnv *env, jobject jvm, jobject jhost, jint jcoreamount) {
+Java_org_simgrid_msg_VM_start(JNIEnv *env, jobject jvm, jobject jhost, jstring jname, jint jcoreamount) {
   msg_host_t host = jhost_get_native(env, jhost);
 
-  msg_vm_t vm = MSG_vm_start(host, (int)jcoreamount);
+  const char *name;
+  name = (*env)->GetStringUTFChars(env, jname, 0);
+  name = xbt_strdup(name);
+  
+  msg_vm_t vm = MSG_vm_start(host, name, (int)jcoreamount);
 
   jvm_bind(env,jvm,vm);
 }
index 79106fd..4933969 100644 (file)
@@ -30,7 +30,7 @@ Java_org_simgrid_msg_VM_nativeInit(JNIEnv *env, jclass);
  * Signature   (I)V
  */
 JNIEXPORT void JNICALL
-Java_org_simgrid_msg_VM_start(JNIEnv *env, jobject jvm, jobject jhost, jint jcoreamount);
+Java_org_simgrid_msg_VM_start(JNIEnv *env, jobject jvm, jobject jhost, jstring jname, jint jcoreamount);
 /**
  * Class            org_simgrid_msg_VM
  * Method           destroy
index df2d878..1bdfa67 100644 (file)
@@ -112,3 +112,51 @@ JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableSet
   (*env)->ReleaseStringUTFChars(env, js_host, host);
   (*env)->ReleaseStringUTFChars(env, js_state, state);
 }
+
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableSub
+  (JNIEnv *env, jclass cls, jstring js_host, jstring js_state, jdouble value)
+{
+  const char *host = (*env)->GetStringUTFChars(env, js_host, 0);
+  const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+
+  TRACE_host_variable_sub(host, state, value);
+
+  (*env)->ReleaseStringUTFChars(env, js_host, host);
+  (*env)->ReleaseStringUTFChars(env, js_state, state);
+}
+
+
+
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_vmVariableDeclare
+  (JNIEnv *env, jclass cls, jstring js_state)
+{
+  const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+
+  TRACE_vm_variable_declare(state);
+
+  (*env)->ReleaseStringUTFChars(env, js_state, state);
+}
+
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_vmVariableSet
+  (JNIEnv *env, jclass cls, jstring js_vm, jstring js_state, jdouble value)
+{
+  const char *vm = (*env)->GetStringUTFChars(env, js_vm, 0);
+  const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+
+  TRACE_vm_variable_set(vm, state, value);
+
+  (*env)->ReleaseStringUTFChars(env, js_vm, vm);
+  (*env)->ReleaseStringUTFChars(env, js_state, state);
+}
+
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableAdd
+  (JNIEnv *env, jclass cls, jstring js_host, jstring js_state, jdouble value) {
+
+  const char *host = (*env)->GetStringUTFChars(env, js_host, 0);
+  const char *state = (*env)->GetStringUTFChars(env, js_state, 0);
+
+  TRACE_host_variable_set(host, state, value);
+
+  (*env)->ReleaseStringUTFChars(env, js_host, host);
+  (*env)->ReleaseStringUTFChars(env, js_state, state);
+}
index 5c435ed..62d9160 100644 (file)
@@ -15,6 +15,15 @@ extern "C" {
 JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableDeclare
   (JNIEnv *, jclass, jstring);
 
+/*
+ * Class:     org_simgrid_trace_Trace
+ * Method:    vmVariableDeclare
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_vmVariableDeclare
+  (JNIEnv *, jclass, jstring);
+
+
 /*
  * Class:     org_simgrid_trace_Trace
  * Method:    hostVariableDeclareWithColor
@@ -31,6 +40,15 @@ JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableDeclareWithColor
 JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_hostVariableSet
   (JNIEnv *, jclass, jstring, jstring, jdouble);
 
+/*
+ * Class:     org_simgrid_trace_Trace
+ * Method:    vmVariableSet
+ * Signature: (Ljava/lang/String;Ljava/lang/String;D)V
+ */
+JNIEXPORT void JNICALL Java_org_simgrid_trace_Trace_vmVariableSet
+  (JNIEnv *, jclass, jstring, jstring, jdouble);
+
+
 /*
  * Class:     org_simgrid_trace_Trace
  * Method:    hostVariableAdd
index 0c4c9f6..00fe9b5 100644 (file)
@@ -83,6 +83,7 @@ void SIMIX_ctx_cojava_factory_init(smx_context_factory_t * factory)
 
   jclass class_thread = (*global_env)->FindClass(global_env, "java/lang/Thread");
   xbt_assert((class_thread != NULL), "Can't find java.lang.Thread class");
+  
   jclass class_coroutine_support = (*global_env)->FindClass(global_env, "java/dyn/CoroutineSupport");
   xbt_assert((class_coroutine_support != NULL), "Can't find java.dyn.CoroutineSupport class");
   jmethodID thread_get_current = (*global_env)->GetStaticMethodID(global_env, class_thread, "currentThread", "()Ljava/lang/Thread;");
@@ -244,10 +245,12 @@ static void smx_ctx_cojava_runall(void)
 {
   cojava_processes = SIMIX_process_get_runnable();
   smx_process_t process;
-  process = xbt_dynar_get_as(cojava_processes, 0, smx_process_t);
-  cojava_process_index = 1;
-  /* Execute the first process */
-  smx_ctx_cojava_resume(SIMIX_process_get_context(process));
+  if (xbt_dynar_length(cojava_processes) > 0) {
+    process = xbt_dynar_get_as(cojava_processes, 0, smx_process_t);
+    cojava_process_index = 1;
+    /* Execute the first process */
+    smx_ctx_cojava_resume(SIMIX_process_get_context(process));
+  }
 }
 
 static void smx_ctx_cojava_create_coroutine(smx_ctx_cojava_t context) {