Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill the right XML files
[simgrid.git] / examples / simdag / simdag_trace.c
1 /* Copyright (c) 2006-2015. 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 <stdio.h>
8 #include <stdlib.h>
9 #include "simgrid/simdag.h"
10 #include "xbt/ex.h"
11 #include "xbt/log.h"
12
13 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_seq_access,
14                              "Logging specific to this SimDag example");
15
16 int main(int argc, char **argv)
17 {
18   const char *platform_file;
19   const SD_workstation_t *workstations;
20   SD_task_t taskA, taskB, taskC;
21   SD_workstation_t workstation_list[2];
22   double computation_amount[2];
23   double communication_amount[4] = { 0 };
24   double rate = -1.0;
25   SD_workstation_t w1, w2;
26
27   /* SD initialization */
28   SD_init(&argc, argv);
29
30   /*  xbt_log_control_set("sd.thres=debug"); */
31
32   xbt_assert(argc > 1, "Usage: %s platform_file\n"
33              "\nExample: %s two_clusters.xml", argv[0], argv[0]);
34
35   /* creation of the environment */
36   platform_file = argv[1];
37   SD_create_environment(platform_file);
38
39   /* Change the access mode of the workstations */
40   workstations = SD_workstation_get_list();
41   w1 = workstations[0];
42   w2 = workstations[1];
43
44   /* creation of the tasks and their dependencies */
45   taskA = SD_task_create_comp_seq("Task A", NULL, 2e9);
46   taskB = SD_task_create_comm_e2e("Task B", NULL, 2e9);
47   taskC = SD_task_create_comp_seq("Task C", NULL, 1e9);
48   TRACE_category ("taskA");
49   TRACE_category ("taskB");
50   TRACE_category ("taskC");
51   TRACE_sd_set_task_category (taskA, "taskA");
52   TRACE_sd_set_task_category (taskB, "taskB");
53   TRACE_sd_set_task_category (taskC, "taskC");
54
55   /* scheduling parameters */
56   workstation_list[0] = w1;
57   workstation_list[1] = w2;
58   computation_amount[0] = SD_task_get_amount(taskA);
59   computation_amount[1] = SD_task_get_amount(taskB);
60
61   communication_amount[1] = SD_task_get_amount(taskC);
62   communication_amount[2] = 0.0;
63
64   SD_task_schedule(taskA, 1, &w1,
65                    &(computation_amount[0]), SD_SCHED_NO_COST, rate);
66   SD_task_schedule(taskB, 2, workstation_list,
67                    SD_SCHED_NO_COST, communication_amount, rate);
68   SD_task_schedule(taskC, 1, &w1,
69                    &(computation_amount[1]), SD_SCHED_NO_COST, rate);
70
71   /* let's launch the simulation! */
72   SD_simulate(-1.0);
73
74   XBT_DEBUG("Destroying tasks...");
75
76   SD_task_destroy(taskA);
77   SD_task_destroy(taskB);
78   SD_task_destroy(taskC);
79
80   XBT_DEBUG("Tasks destroyed. Exiting SimDag...");
81
82   SD_exit();
83   return 0;
84 }