1 /* Copyright (c) 2006, 2007, 2008, 2009, 2010. 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 "simdag/simdag.h"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_typed_tasks_test,
14 "Logging specific to this SimDag example");
16 int main(int argc, char **argv)
20 const char *platform_file;
21 const SD_workstation_t *workstations;
22 SD_task_t task, taskA, taskB, taskC, taskD, taskE;
23 xbt_dynar_t changed_tasks;
25 double computation_amount[4];
26 double communication_amount[16] = { 0 };
27 SD_workstation_t workstation_list[4];
29 /* initialization of SD */
32 /* xbt_log_control_set("sd.thres=debug"); */
35 XBT_INFO("Usage: %s platform_file", argv[0]);
36 XBT_INFO("example: %s sd_platform.xml", argv[0]);
40 /* creation of the environment */
41 platform_file = argv[1];
42 SD_create_environment(platform_file);
44 workstations = SD_workstation_get_list();
47 XBT_INFO("%s runs at %f flops", SD_workstation_get_name(workstations[i]),
48 SD_workstation_get_power(workstations[i]));
50 /* creation of some typed tasks and their dependencies */
51 taskA = SD_task_create_comp_seq("Task A", NULL, 1e9);
52 taskB = SD_task_create_comm_e2e("Task B", NULL, 1e7);
53 taskC = SD_task_create_comp_seq("Task C", NULL, 1e9);
54 taskD = SD_task_create_comp_par_amdahl("Task D", NULL, 1e9, 0.2);
55 taskE = SD_task_create("Task E", NULL, 1e9);
57 double toto = (0.2 + (1 - 0.2)/4) * 1e9;
58 XBT_INFO("%f %f",toto ,toto/SD_workstation_get_power(workstations[0]));
60 SD_task_dependency_add(NULL, NULL, taskA, taskB);
61 SD_task_dependency_add(NULL, NULL, taskB, taskC);
63 SD_task_schedulel(taskA, 1, workstations[8]);
64 SD_task_schedulel(taskC, 1, workstations[9]);
66 SD_task_distribute_comp_amdhal(taskD, 4);
67 SD_task_schedulev(taskD, 4, workstations);
70 workstation_list[i]=workstations[i+4];
71 computation_amount[i]=toto;
73 SD_task_schedule(taskE, 4, workstation_list,
74 computation_amount, communication_amount, -1);
76 changed_tasks = SD_simulate(-1.0);
77 xbt_dynar_foreach(changed_tasks, ctr, task) {
78 XBT_INFO("Task '%s' start time: %f, finish time: %f",
79 SD_task_get_name(task),
80 SD_task_get_start_time(task), SD_task_get_finish_time(task));
83 XBT_DEBUG("Destroying tasks...");
85 SD_task_destroy(taskA);
86 SD_task_destroy(taskB);
87 SD_task_destroy(taskC);
88 SD_task_destroy(taskD);
89 SD_task_destroy(taskE);
91 XBT_DEBUG("Tasks destroyed. Exiting SimDag...");