Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Hooo my eyes, that hurts!
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 26 Jan 2016 20:34:47 +0000 (21:34 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 26 Jan 2016 20:38:01 +0000 (21:38 +0100)
I didn't intend at changing that at first, but couldn't refrain. Sorry.

teshsuite/simdag/availability/availability_test.c
teshsuite/simdag/availability/availability_test.tesh

index a426e74..88d34f0 100644 (file)
 #include <xbt/ex.h>
 #include <signal.h>
 
-
-typedef struct {
-  FILE *daxFile;
-  FILE *envFile;
-} XMLfiles;
-
-
-static void usage(char *name)
-{
-  fprintf(stdout, "Error on parameters.\n");
-  fprintf(stdout, "usage: %s <XML environment file>  <DAX file>\n", name);
-}
-
-static void checkParameters(int argc, char *argv[])
-{
-  if (argc != 3) {
-    int i;
-    printf("====%d===\n",argc);
-    for(i=0; i<argc; i++) {
-      printf("\t%s\n",argv[i]);
-    }
-    usage(argv[0]);
-    exit(-1);
-  }
- /* Check that files exist */
-  XMLfiles xmlFiles;
-  if ((xmlFiles.envFile = fopen(argv[1], "r")) == NULL) {
-    fprintf(stderr, "Error while opening XML file %s.\n", argv[1]);
-    exit(-1);
-  }
-  fclose(xmlFiles.envFile);
-
-  if ((xmlFiles.daxFile = fopen(argv[2], "r")) == NULL) {
-    fprintf(stderr, "Error while opening DAX file %s.\n", argv[2]);
-    exit(-1);
-  }
-  fclose(xmlFiles.daxFile);
-}
+XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging for the current example");
 
 static int name_compare_hosts(const void *n1, const void *n2)
 {
-  char name1[80], name2[80];
-  strcpy(name1, sg_host_get_name(*((sg_host_t *) n1)));
-  strcpy(name2, sg_host_get_name(*((sg_host_t *) n2)));
-
-  return strcmp(name1, name2);
+  return strcmp(
+      sg_host_get_name(*(sg_host_t *) n1),
+      sg_host_get_name(*(sg_host_t *) n2)
+  );
 }
 
 static void scheduleDAX(xbt_dynar_t dax)
@@ -70,20 +31,18 @@ static void scheduleDAX(xbt_dynar_t dax)
 
   const sg_host_t *ws_list = sg_host_list();
   int totalHosts = sg_host_count();
-  qsort((void *) ws_list, totalHosts, sizeof(sg_host_t),
-        name_compare_hosts);
+  qsort((void *) ws_list, totalHosts, sizeof(sg_host_t), name_compare_hosts);
 
-  //fprintf(stdout, "No. workstations: %d, %d\n", totalHosts, (dax != NULL));
 
   xbt_dynar_foreach(dax, cursor, task) {
     if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
       if (!strcmp(SD_task_get_name(task), "end")
           || !strcmp(SD_task_get_name(task), "root")) {
-        fprintf(stdout, "Scheduling %s to node: %s\n", SD_task_get_name(task),
+        XBT_INFO("Scheduling %s to node: %s", SD_task_get_name(task),
                 sg_host_get_name(ws_list[0]));
         SD_task_schedulel(task, 1, ws_list[0]);
       } else {
-        fprintf(stdout, "Scheduling %s to node: %s\n", SD_task_get_name(task),
+        XBT_INFO("Scheduling %s to node: %s", SD_task_get_name(task),
                 sg_host_get_name(ws_list[(cursor) % totalHosts]));
         SD_task_schedulel(task, 1, ws_list[(cursor) % totalHosts]);
       }
@@ -91,92 +50,43 @@ static void scheduleDAX(xbt_dynar_t dax)
   }
 }
 
-/* static void printTasks(xbt_dynar_t completedTasks) */
-/* { */
-/*     unsigned int cursor; */
-/*     SD_task_t task; */
-
-/*     xbt_dynar_foreach(completedTasks, cursor, task) */
-/*     { */
-/*             if(SD_task_get_state(task) == SD_DONE) */
-/*             { */
-/*                     fprintf(stdout, "Task done: %s, %f, %f\n", */
-/*                                             SD_task_get_name(task), SD_task_get_start_time(task), SD_task_get_finish_time(task)); */
-/*             } */
-/*     } */
-/* } */
-
-
-/* void createDottyFile(xbt_dynar_t dax, char *filename) */
-/* { */
-/*     char filename2[1000]; */
-/*     unsigned int cursor; */
-/*     SD_task_t task; */
-
-/*     sprintf(filename2, "%s.dot", filename); */
-/*     FILE *dotout = fopen(filename2, "w"); */
-/*     fprintf(dotout, "digraph A {\n"); */
-/*     xbt_dynar_foreach(dax, cursor, task) */
-/*     { */
-/*             SD_task_dotty(task, dotout); */
-/*     } */
-/*     fprintf(dotout, "}\n"); */
-/*     fclose(dotout); */
-/* } */
-
-static xbt_dynar_t initDynamicThrottling(int *argc, char *argv[])
+static xbt_dynar_t initDynamicThrottling(int argc, char *argv[])
 {
-  /* Initialize SD */
-  SD_init(argc, argv);
+  SD_init(&argc, argv);
+  xbt_assert(argc == 3,
+      "Error on parameters.\n"
+      "Usage: %s <XML platform file>  <DAX file>\n", argv[0]);
 
-  /* Check parameters */
-  checkParameters(*argc,argv);
+  FILE *testFile = fopen(argv[1], "r");
+  xbt_assert(testFile, "Cannot open platform file %s.\n", argv[1]);
+  testFile = fopen(argv[2], "r");
+  xbt_assert(testFile, "Cannot open DAX file %s.\n", argv[2]);
 
-  /* Create environment */
   SD_create_environment(argv[1]);
-  /* Load DAX file */
   xbt_dynar_t dax = SD_daxload(argv[2]);
 
-  //  createDottyFile(dax, argv[2]);
-
   // Schedule DAX
-  fprintf(stdout, "Scheduling DAX...\n");
+  XBT_INFO("Scheduling DAX...");
   scheduleDAX(dax);
-  fprintf(stdout, "DAX scheduled\n");
+  XBT_INFO("DAX scheduled");
   SD_simulate(-1);
-  fprintf(stdout, "Simulation end. Time: %f\n", SD_get_clock());
+  XBT_INFO("Simulation done.");
 
   return dax;
 }
 
-/**
- * Garbage collector :D
- */
-static void garbageCollector(xbt_dynar_t dax)
+int main(int argc, char *argv[])
 {
+
+  /* Start process... */
+  xbt_dynar_t dax = initDynamicThrottling(argc, argv);
+
+  // Free memory
   while (!xbt_dynar_is_empty(dax)) {
     SD_task_t task = xbt_dynar_pop_as(dax, SD_task_t);
     SD_task_destroy(task);
   }
   xbt_dynar_free(&dax);
   SD_exit();
-}
-
-
-
-/**
- * Main procedure
- * @param argc
- * @param argv
- * @return
- */
-int main(int argc, char *argv[])
-{
-
-  /* Start process... */
-  xbt_dynar_t dax = initDynamicThrottling(&argc, argv);
-
-  // Free memory
-  garbageCollector(dax);
   return 0;
 }
index d975690..5bf04fb 100644 (file)
@@ -1,36 +1,34 @@
-! output sort
-
 $ simdag/availability/availability_test ${srcdir:=.}/../examples/platforms/simulacrum_7_hosts.xml --cfg=path:${srcdir:=.}/simdag/availability/ ${srcdir:=.}/../examples/simdag/scheduling/Montage_25.xml --cfg=network/TCP_gamma:4194304 --log=sd_daxparse.thresh:critical
 > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'network/TCP_gamma' to '4194304'
 > [0.000000] [xbt_cfg/INFO] Switching to the L07 model to handle parallel tasks.
-> Scheduling DAX...
-> Scheduling root to node: Host 26
-> Scheduling ID00000@mProjectPP to node: Host 27
-> Scheduling ID00001@mProjectPP to node: Host 28
-> Scheduling ID00002@mProjectPP to node: Host 29
-> Scheduling ID00003@mProjectPP to node: Host 30
-> Scheduling ID00004@mProjectPP to node: Host 31
-> Scheduling ID00005@mDiffFit to node: Host 32
-> Scheduling ID00006@mDiffFit to node: Host 26
-> Scheduling ID00007@mDiffFit to node: Host 27
-> Scheduling ID00008@mDiffFit to node: Host 28
-> Scheduling ID00009@mDiffFit to node: Host 29
-> Scheduling ID00010@mDiffFit to node: Host 30
-> Scheduling ID00011@mDiffFit to node: Host 31
-> Scheduling ID00012@mDiffFit to node: Host 32
-> Scheduling ID00013@mDiffFit to node: Host 26
-> Scheduling ID00014@mConcatFit to node: Host 27
-> Scheduling ID00015@mBgModel to node: Host 28
-> Scheduling ID00016@mBackground to node: Host 29
-> Scheduling ID00017@mBackground to node: Host 30
-> Scheduling ID00018@mBackground to node: Host 31
-> Scheduling ID00019@mBackground to node: Host 32
-> Scheduling ID00020@mBackground to node: Host 26
-> Scheduling ID00021@mImgTbl to node: Host 27
-> Scheduling ID00022@mAdd to node: Host 28
-> Scheduling ID00023@mShrink to node: Host 29
-> Scheduling ID00024@mJPEG to node: Host 30
-> Scheduling end to node: Host 26
-> DAX scheduled
-> Simulation end. Time: 164.052870
+> [0.000000] [test/INFO] Scheduling DAX...
+> [0.000000] [test/INFO] Scheduling root to node: Host 26
+> [0.000000] [test/INFO] Scheduling ID00000@mProjectPP to node: Host 27
+> [0.000000] [test/INFO] Scheduling ID00001@mProjectPP to node: Host 28
+> [0.000000] [test/INFO] Scheduling ID00002@mProjectPP to node: Host 29
+> [0.000000] [test/INFO] Scheduling ID00003@mProjectPP to node: Host 30
+> [0.000000] [test/INFO] Scheduling ID00004@mProjectPP to node: Host 31
+> [0.000000] [test/INFO] Scheduling ID00005@mDiffFit to node: Host 32
+> [0.000000] [test/INFO] Scheduling ID00006@mDiffFit to node: Host 26
+> [0.000000] [test/INFO] Scheduling ID00007@mDiffFit to node: Host 27
+> [0.000000] [test/INFO] Scheduling ID00008@mDiffFit to node: Host 28
+> [0.000000] [test/INFO] Scheduling ID00009@mDiffFit to node: Host 29
+> [0.000000] [test/INFO] Scheduling ID00010@mDiffFit to node: Host 30
+> [0.000000] [test/INFO] Scheduling ID00011@mDiffFit to node: Host 31
+> [0.000000] [test/INFO] Scheduling ID00012@mDiffFit to node: Host 32
+> [0.000000] [test/INFO] Scheduling ID00013@mDiffFit to node: Host 26
+> [0.000000] [test/INFO] Scheduling ID00014@mConcatFit to node: Host 27
+> [0.000000] [test/INFO] Scheduling ID00015@mBgModel to node: Host 28
+> [0.000000] [test/INFO] Scheduling ID00016@mBackground to node: Host 29
+> [0.000000] [test/INFO] Scheduling ID00017@mBackground to node: Host 30
+> [0.000000] [test/INFO] Scheduling ID00018@mBackground to node: Host 31
+> [0.000000] [test/INFO] Scheduling ID00019@mBackground to node: Host 32
+> [0.000000] [test/INFO] Scheduling ID00020@mBackground to node: Host 26
+> [0.000000] [test/INFO] Scheduling ID00021@mImgTbl to node: Host 27
+> [0.000000] [test/INFO] Scheduling ID00022@mAdd to node: Host 28
+> [0.000000] [test/INFO] Scheduling ID00023@mShrink to node: Host 29
+> [0.000000] [test/INFO] Scheduling ID00024@mJPEG to node: Host 30
+> [0.000000] [test/INFO] Scheduling end to node: Host 26
+> [0.000000] [test/INFO] DAX scheduled
+> [164.052870] [test/INFO] Simulation done.