Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr/gitroot/simgrid/simgrid
[simgrid.git] / examples / msg / cloud / scale.c
index 338b75f..9cc1153 100644 (file)
@@ -4,16 +4,10 @@
 /* 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. */
 
-#include <stdio.h>
 #include <sys/time.h>
 #include "simgrid/msg.h"
-#include "xbt/sysdep.h"         /* calloc, printf */
 
-/* Create a log channel to have nice outputs. */
-#include "xbt/log.h"
-#include "xbt/asserts.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
-                             "Messages specific for this msg example");
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
 
 /*
  * Usage:
@@ -24,14 +18,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
  **/
 
 static double time_precise(void) {
-       struct timeval tv;
-       int ret = gettimeofday(&tv, NULL);
-  if (ret < 0)
-    xbt_die("gettimeofday");
-
-       double now = (double) tv.tv_sec + tv.tv_usec * 0.001 * 0.001;
-
-       return now;
+  struct timeval tv;
+  int ret = gettimeofday(&tv, NULL);
+  xbt_assert(ret >= 0, "gettimeofday");
+  return (double) tv.tv_sec + tv.tv_usec * 0.001 * 0.001;
 }
 
 static int computation_fun(int argc, char *argv[]) {
@@ -46,8 +36,6 @@ static int computation_fun(int argc, char *argv[]) {
 
     // XBT_INFO("%f", clock_end - clock_sta);
   }
-
-
   return 0;
 }
 
@@ -67,37 +55,34 @@ static int master_main(int argc, char *argv[])
 
   int i = 0;
   for (i = 0; i < npm; i++) {
-         pm[i] = xbt_dynar_get_as(hosts_dynar, i, msg_host_t);
+    pm[i] = xbt_dynar_get_as(hosts_dynar, i, msg_host_t);
   }
 
   for (i = 0; i < nvm; i++) {
-         int pm_index = i % npm;
-         char *vm_name = bprintf("vm%d", i);
-         vm[i] = MSG_vm_create_core(pm[pm_index], vm_name);
-         MSG_vm_start(vm[i]);
+    int pm_index = i % npm;
+    char *vm_name = bprintf("vm%d", i);
+    vm[i] = MSG_vm_create_core(pm[pm_index], vm_name);
+    MSG_vm_start(vm[i]);
 
     launch_computation_worker(vm[i]);
 
-         xbt_free(vm_name);
+    xbt_free(vm_name);
   }
 
-
   XBT_INFO("## Test (start)");
 
   for (i = 0; i < 10; i++) {
-         double clock_sta = time_precise();
-         MSG_process_sleep(1);
-         double clock_end = time_precise();
-         XBT_INFO("duration %f", clock_end - clock_sta);
+    double clock_sta = time_precise();
+    MSG_process_sleep(1);
+    double clock_end = time_precise();
+    XBT_INFO("duration %f", clock_end - clock_sta);
   }
 
-
   for (i = 0; i < nvm; i++) {
-         MSG_vm_destroy(vm[i]);
+    MSG_vm_destroy(vm[i]);
   }
 
   XBT_INFO("## Test (ended)");
-  
   return 0;
 }
 
@@ -128,6 +113,5 @@ int main(int argc, char *argv[])
   int res = MSG_main();
   XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
 
-
   return !(res == MSG_OK);
 }