1 /* Copyright (c) 2013-2016. The SimGrid Team.
2 * All rights reserved. */
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. */
9 #include "simgrid/simdag.h"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this SimDag example");
17 /* simple test trying to load a Parallel Task Graph (PTG) as a DOT file. */
18 int main(int argc, char **argv){
23 /* initialization of SD */
26 /* Check our arguments */
27 xbt_assert (argc > 1,"Usage: %s platform_file dot_file example: %s ../2clusters.xml ptg.dot", argv[0], argv[0]);
29 /* creation of the environment */
30 SD_create_environment(argv[1]);
32 /* load the DOT file */
33 dot = SD_PTG_dotload(argv[2]);
36 xbt_die("No dot load may be you have a cycle in your graph");
39 /* Display all the tasks */
40 XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------");
41 xbt_dynar_foreach(dot, cursor, task) {
45 FILE *dotout = fopen("dot.dot", "w");
46 fprintf(dotout, "digraph A {\n");
47 xbt_dynar_foreach(dot, cursor, task) {
48 SD_task_dotty(task, dotout);
50 fprintf(dotout, "}\n");
53 /* Schedule them all on all the first workstation */
54 XBT_INFO("------------------- Schedule tasks ---------------------------");
55 const sg_host_t *ws_list = sg_host_list();
56 int count = sg_host_count();
57 xbt_dynar_foreach(dot, cursor, task) {
58 if (SD_task_get_kind(task) == SD_TASK_COMP_PAR_AMDAHL) {
59 SD_task_schedulev(task, count, ws_list);
63 XBT_INFO("------------------- Run the schedule ---------------------------");
65 XBT_INFO("Makespan: %f", SD_get_clock());
66 xbt_dynar_foreach(dot, cursor, task) {
67 SD_task_destroy(task);
69 xbt_dynar_free_container(&dot);