Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add VM.setBound() and cosmetics changes - Adrien
authoralebre <adrien.lebre@inria.fr>
Wed, 3 Jul 2013 17:24:34 +0000 (19:24 +0200)
committeralebre <adrien.lebre@inria.fr>
Wed, 3 Jul 2013 17:24:34 +0000 (19:24 +0200)
src/bindings/java/jmsg_vm.c
src/bindings/java/jmsg_vm.h
src/bindings/java/org/simgrid/msg/VM.java
src/msg/msg_vm.c

index b5f23f2..5e8c3e4 100644 (file)
@@ -70,6 +70,15 @@ Java_org_simgrid_msg_VM_isRestoring(JNIEnv * env, jobject jvm) {
   msg_vm_t vm = jvm_get_native(env,jvm);
   return (jint) MSG_vm_is_restoring(vm);
 }
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_VM_setBound(JNIEnv *env, jobject jvm, jint load) { 
+
+       msg_vm_t vm = jvm_get_native(env,jvm);
+       double bound = MSG_get_host_speed(vm) * load / 100;
+       MSG_vm_set_bound(vm, bound); 
+}
+
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_VM_create(JNIEnv *env, jobject jvm, jobject jhost, jstring jname,
                               jint jncore, jint jramsize, jint jnetcap, jstring jdiskpath, jint jdisksize, jint jmig_netspeed, jint jdp_intensity) {
@@ -113,10 +122,7 @@ JNIEXPORT void JNICALL
 Java_org_simgrid_msg_VM_internalmig(JNIEnv *env, jobject jvm, jobject jhost) {
   msg_vm_t vm = jvm_get_native(env,jvm);
   msg_host_t host = jhost_get_native(env, jhost);
-
-  XBT_INFO("Start migration of %s to %s", MSG_host_get_name(vm), MSG_host_get_name(host));
   MSG_vm_migrate(vm,host);
-  XBT_INFO("Migration done");
 }
 
 JNIEXPORT void JNICALL
index e8f9190..fc35c28 100644 (file)
@@ -79,6 +79,13 @@ Java_org_simgrid_msg_VM_isSaved(JNIEnv *env, jobject jvm);
  */
 JNIEXPORT jint JNICALL
 Java_org_simgrid_msg_VM_isRestoring(JNIEnv *env, jobject jvm);
+/**
+ * Class                       org_simgrid_msg_VM
+ * Method                      setBound
+ * Signature   ()B
+ */
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_VM_setBound(JNIEnv *env, jobject jvm, jint load); 
 
 /**
  * Class            org_simgrid_msg_VM
index 538a9ec..03edd5b 100644 (file)
@@ -23,7 +23,8 @@ public class VM extends Host{
 
         private static VM[] vms=null;    
     private Host currentHost; 
-    
+    private int dpIntensity = 0 ; 
+
        /* Constructors / destructors */
     /**
         * Create a `basic' VM (i.e. 1 core, 1GB of RAM, other values are not taken into account).
@@ -50,6 +51,7 @@ public class VM extends Host{
                super();
                super.name = name; 
                this.currentHost = host; 
+               this.dpIntensity = dpIntensity; 
                create(host, name, nCore, ramSize, netCap, diskPath, diskSize, migNetSpeed, dpIntensity);
                VM.addVM(this);
        }
@@ -126,7 +128,14 @@ public class VM extends Host{
         */
        private native void create(Host host, String name, int nCore, int ramSize, 
                         int netCap, String diskPath, int diskSize, int migNetSpeed, int dpIntensity);
-       
+
+
+       /**
+        * Bound the VM to a certain % of its vcpu capability (e.g. 75% of vm.getSpeed())
+        * @param load, percentage (between [0,100]
+        */
+       public native void setBound(int load);
+
        /**
         * start the VM
         */
@@ -149,25 +158,11 @@ public class VM extends Host{
         * (pre-copy is implemented)
         */     
        public void migrate(Host destination){
-//             String[] argsRx = new String[5];
-//             argsRx[1] = this.getName();
-//             argsRx[2] = this.currentHost.getName();
-//             argsRx[3] = destination.getName();
-//             argsRx[0] =  "__pr_mig_rx:"+argsRx[1]+"("+argsRx[2]+"-"+argsRx[3]+")";
-//             argsRx[4] = null; // TODO: Why ? 
-//             
-//             //Process rx = new Process(destination, argsRx[0], argsRx );
-//             
-//             String[] argsTx = new String[5];
-//             argsTx[1] = this.getName();
-//             argsTx[2] = this.currentHost.getName();
-//             argsTx[3] = destination.getName();
-//             argsTx[0] =  "__pr_mig_tx:"+argsTx[1]+"("+argsTx[2]+"-"+argsTx[3]+")";
-//             argsTx[4] = null; // TODO: Why ? 
-//             
-//             //Process tx = new Process(this.currentHost, argsTx[0], argsRx ); 
-//             
+               Msg.info("Start migration of VM "+this.getName()+" to node "+destination.getName());
+               Msg.info("    dpIntensity:"+this.dpIntensity);
+               
                this.internalmig(destination);
+               Msg.info("End of migration of VM "+this.getName()+" to node "+destination.getName());
        }
        
        /** Immediately suspend the execution of all processes within the given VM
index 4c474e6..e423f9e 100644 (file)
@@ -466,7 +466,7 @@ static double lookup_computed_flop_counts(msg_vm_t vm, int stage_for_fancy_debug
 
   total += priv->dp_updated_by_deleted_tasks;
 
-  XBT_INFO("mig-stage%d.%d: computed %f flop_counts (including %f by deleted tasks)",
+  XBT_DEBUG("mig-stage%d.%d: computed %f flop_counts (including %f by deleted tasks)",
       stage_for_fancy_debug,
       stage2_round_for_fancy_debug,
       total, priv->dp_updated_by_deleted_tasks);
@@ -817,10 +817,11 @@ static void send_migration_data(const char *vm_name, const char *src_pm_name, co
 
 
 
-  if (stage == 2)
-    XBT_INFO("mig-stage%d.%d: sent %f duration %f actual_speed %f (target %f) cpu %f", stage, stage2_round, size, duration, actual_speed, mig_speed, cpu_utilization);
-  else
-    XBT_INFO("mig-stage%d: sent %f duration %f actual_speed %f (target %f) cpu %f", stage, size, duration, actual_speed, mig_speed, cpu_utilization);
+  if (stage == 2){
+    XBT_DEBUG("mig-stage%d.%d: sent %f duration %f actual_speed %f (target %f) cpu %f", stage, stage2_round, size, duration, actual_speed, mig_speed, cpu_utilization);}
+  else{
+    XBT_DEBUG("mig-stage%d: sent %f duration %f actual_speed %f (target %f) cpu %f", stage, size, duration, actual_speed, mig_speed, cpu_utilization);
+  }
 
   xbt_free(task_name);
 
@@ -845,7 +846,7 @@ static void send_migration_data(const char *vm_name, const char *src_pm_name, co
 static double get_updated_size(double computed, double dp_rate, double dp_cap)
 {
   double updated_size = computed * dp_rate;
-  XBT_INFO("updated_size %f dp_rate %f", updated_size, dp_rate);
+  XBT_DEBUG("updated_size %f dp_rate %f", updated_size, dp_rate);
   if (updated_size > dp_cap) {
     // XBT_INFO("mig-stage2.%d: %f bytes updated, but cap it with the working set size %f", stage2_round, updated_size, dp_cap);
     updated_size = dp_cap;
@@ -969,14 +970,14 @@ static int migration_tx_fun(int argc, char *argv[])
       updated_size = get_updated_size(computed, dp_rate, dp_cap);
     }
 
-    XBT_INFO("%d updated_size %f computed_during_stage1 %f dp_rate %f dp_cap %f",
+    XBT_INFO("mig-stage 2:%d updated_size %f computed_during_stage1 %f dp_rate %f dp_cap %f",
         stage2_round, updated_size, computed_during_stage1, dp_rate, dp_cap);
 
 
     if (stage2_round != 0) {
       /* during stage1, we have already created overhead tasks */
       double overhead = dpt_cpu_overhead * updated_size;
-      XBT_INFO("updated %f overhead %f", updated_size, overhead);
+      XBT_DEBUG("updated %f overhead %f", updated_size, overhead);
       launch_deferred_exec_process(vm, overhead, 10000);
     }
 
@@ -984,7 +985,7 @@ static int migration_tx_fun(int argc, char *argv[])
     {
       remaining_size += updated_size;
 
-      XBT_INFO("mig-stage2.%d: remaining_size %f (%s threshold %f)", stage2_round,
+      XBT_DEBUG("mig-stage2.%d: remaining_size %f (%s threshold %f)", stage2_round,
           remaining_size, (remaining_size < threshold) ? "<" : ">", threshold);
 
       if (remaining_size < threshold)