1 /* Copyright (c) 2006-2010, 2012-2015. 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"
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, seq_comp1, e2e_comm, seq_comp2;
23 SD_task_t par_comp1, redist, par_comp2, par_comp3;
24 xbt_dynar_t changed_tasks;
26 double computation_amount[4];
27 double communication_amount[16] = { 0 };
28 SD_workstation_t workstation_list[4];
30 /* initialization of SD */
33 /* xbt_log_control_set("sd.thres=debug"); */
35 xbt_assert(argc > 1, "Usage: %s platform_file\n"
36 "\nExample: %s two_clusters.xml", argv[0], argv[0]);
38 /* creation of the environment */
39 platform_file = argv[1];
40 SD_create_environment(platform_file);
42 workstations = SD_workstation_get_list();
44 /* creation of some typed tasks and their dependencies */
45 seq_comp1 = SD_task_create_comp_seq("Seq. comp. 1", NULL, 1e9);
46 e2e_comm = SD_task_create_comm_e2e("E2E comm.", NULL, 1e7);
47 seq_comp2 = SD_task_create_comp_seq("Seq. comp 2.", NULL, 1e9);
48 par_comp1 = SD_task_create_comp_par_amdahl("Par. Comp. 1", NULL, 1e9, 0.2);
49 redist = SD_task_create_comm_par_mxn_1d_block("MxN redist", NULL, 1.2e8);
50 par_comp2 = SD_task_create_comp_par_amdahl("Par. Comp. 2", NULL, 3e8, 0.5);
52 par_comp3 = SD_task_create("Par. Comp. 3", NULL, 1e9);
54 SD_task_dependency_add(NULL, NULL, seq_comp1, e2e_comm);
55 SD_task_dependency_add(NULL, NULL, e2e_comm, seq_comp2);
57 SD_task_dependency_add(NULL, NULL, par_comp1, redist);
58 SD_task_dependency_add(NULL, NULL, redist, par_comp2);
60 SD_task_schedulel(seq_comp1, 1, workstations[8]);
61 SD_task_schedulel(seq_comp2, 1, workstations[9]);
63 SD_task_schedulev(par_comp1, 4, workstations);
64 SD_task_schedulev(par_comp2, 3, workstations);
66 /* Let's unschedule these tasks and test the auto-scheduling in the
69 SD_task_unschedule(par_comp1);
70 SD_task_unschedule(par_comp2);
71 SD_task_unschedule(redist); /* yes, it was scheduled too */
73 SD_task_schedulev(par_comp2, 3, workstations);
74 SD_task_schedulev(par_comp1, 4, workstations);
77 workstation_list[i]=workstations[i+4];
78 /* Apply Amdahl's law manually assuming a 20% serial part */
79 computation_amount[i]=(0.2 + (1 - 0.2)/4) * SD_task_get_amount(par_comp3);
82 SD_task_schedule(par_comp3, 4, workstation_list,
83 computation_amount, communication_amount, -1);
85 changed_tasks = SD_simulate(-1.0);
86 xbt_dynar_foreach(changed_tasks, ctr, task) {
87 XBT_INFO("Task '%s' start time: %f, finish time: %f",
88 SD_task_get_name(task),
89 SD_task_get_start_time(task), SD_task_get_finish_time(task));
92 xbt_dynar_foreach(changed_tasks, ctr, task) {
93 SD_task_destroy(task);