Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further reduce the amount of includes
[simgrid.git] / examples / simdag / ptg-dotload / sd_ptg-dotload.c
1 /* Copyright (c) 2013-2016. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "simgrid/simdag.h"
8 #include "xbt/log.h"
9
10 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this SimDag example");
11
12 /* simple test trying to load a Parallel Task Graph (PTG) as a DOT file.    */
13 int main(int argc, char **argv){
14   xbt_dynar_t dot;
15   unsigned int cursor;
16   SD_task_t task;
17
18   /* initialization of SD */
19   SD_init(&argc, argv);
20
21   /* Check our arguments */
22   xbt_assert (argc > 1,"Usage: %s platform_file dot_file example: %s ../2clusters.xml ptg.dot", argv[0], argv[0]);
23
24   /* creation of the environment */
25   SD_create_environment(argv[1]);
26
27   /* load the DOT file */
28   dot = SD_PTG_dotload(argv[2]);
29   if(dot == NULL){
30     SD_exit();
31     xbt_die("No dot load may be you have a cycle in your graph");
32   }
33
34   /* Display all the tasks */
35   XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------");
36   xbt_dynar_foreach(dot, cursor, task) {
37     SD_task_dump(task);
38   }
39
40   /* Schedule them all on all the first host*/
41   XBT_INFO("------------------- Schedule tasks ---------------------------");
42   sg_host_t *hosts = sg_host_list();
43   int count = sg_host_count();
44   xbt_dynar_foreach(dot, cursor, task) {
45     if (SD_task_get_kind(task) == SD_TASK_COMP_PAR_AMDAHL) {
46         SD_task_schedulev(task, count, hosts);
47     }
48   }
49   xbt_free(hosts);
50
51   XBT_INFO("------------------- Run the schedule ---------------------------");
52   SD_simulate(-1);
53   XBT_INFO("Makespan: %f", SD_get_clock());
54   xbt_dynar_foreach(dot, cursor, task) {
55     SD_task_destroy(task);
56   }
57   xbt_dynar_free_container(&dot);
58
59   /* exit */
60   SD_exit();
61   return 0;
62 }