Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
woops revalidate some tesh 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   if (argc < 2) {
33     XBT_INFO("Usage: %s platform_file", argv[0]);
34     XBT_INFO("example: %s sd_platform.xml", argv[0]);
35     exit(1);
36   }
37
38   /* creation of the environment */
39   platform_file = argv[1];
40   SD_create_environment(platform_file);
41
42   /* Change the access mode of the workstations */
43   workstations = SD_workstation_get_list();
44   w1 = workstations[0];
45   w2 = workstations[1];
46
47   /* creation of the tasks and their dependencies */
48   taskA = SD_task_create_comp_seq("Task A", NULL, 2e9);
49   taskB = SD_task_create_comm_e2e("Task B", NULL, 2e9);
50   taskC = SD_task_create_comp_seq("Task C", NULL, 1e9);
51   TRACE_category ("taskA");
52   TRACE_category ("taskB");
53   TRACE_category ("taskC");
54   TRACE_sd_set_task_category (taskA, "taskA");
55   TRACE_sd_set_task_category (taskB, "taskB");
56   TRACE_sd_set_task_category (taskC, "taskC");
57
58   /* scheduling parameters */
59   workstation_list[0] = w1;
60   workstation_list[1] = w2;
61   computation_amount[0] = SD_task_get_amount(taskA);
62   computation_amount[1] = SD_task_get_amount(taskB);
63
64   communication_amount[1] = SD_task_get_amount(taskC);
65   communication_amount[2] = 0.0;
66
67   SD_task_schedule(taskA, 1, &w1,
68                    &(computation_amount[0]), SD_SCHED_NO_COST, rate);
69   SD_task_schedule(taskB, 2, workstation_list,
70                    SD_SCHED_NO_COST, communication_amount, rate);
71   SD_task_schedule(taskC, 1, &w1,
72                    &(computation_amount[1]), SD_SCHED_NO_COST, rate);
73
74   /* let's launch the simulation! */
75   SD_simulate(-1.0);
76
77   XBT_DEBUG("Destroying tasks...");
78
79   SD_task_destroy(taskA);
80   SD_task_destroy(taskB);
81   SD_task_destroy(taskC);
82
83   XBT_DEBUG("Tasks destroyed. Exiting SimDag...");
84
85   SD_exit();
86   return 0;
87 }