5 #include "mixtesim_prototypes.h"
6 #include "list_scheduling.h"
8 #include "simdag/simdag.h"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mixtesim_list_scheduling, mixtesim,
12 "Logging specific to Mixtesim (list scheduling)");
15 * freeHostAttributes()
17 void freeHostAttributes()
20 int nb_hosts = SD_workstation_get_number();
21 const SD_workstation_t *hosts = SD_workstation_get_list();
23 for (i=0;i<nb_hosts;i++) {
24 free(SD_workstation_get_data(hosts[i]));
25 SD_workstation_set_data(hosts[i], NULL);
31 * allocateHostAttributes()
33 void allocateHostAttributes()
36 int nb_hosts = SD_workstation_get_number();
37 const SD_workstation_t *hosts = SD_workstation_get_list();
40 for (i=0;i<nb_hosts;i++) {
41 data = calloc(1,sizeof(struct _HostAttribute));
42 SD_workstation_set_data(hosts[i], data);
48 * freeNodeAttributes()
50 void freeNodeAttributes(DAG dag)
54 for (i=0;i<dag->nb_nodes;i++) {
55 if (dag->nodes[i]->metadata) {
56 free(dag->nodes[i]->metadata);
63 * allocateNodeAttributes()
65 void allocateNodeAttributes(DAG dag)
69 for (i=0;i<dag->nb_nodes;i++) {
70 dag->nodes[i]->metadata =
71 (NodeAttribute)calloc(1,sizeof(struct _NodeAttribute));
72 if (dag->nodes[i]->type == NODE_COMPUTATION)
73 NODE_ATTR(dag->nodes[i])->state = LIST_SCHEDULING_NOT_SCHEDULED;
79 * implementSimgridSchedule()
81 void implementSimgridSchedule(DAG dag, Node *list)
86 SD_workstation_t grand_parent_host;
87 SD_workstation_t host;
89 /* SD_link_t *route;*/
91 const double no_cost[] = {0.0, 0.0};
92 const double small_cost = 1.0; /* doesn't work with 0.0 */
93 e_SD_task_state_t state;
94 SD_workstation_t host_list[] = {NULL, NULL};
95 double communication_amount[] = {0.0, 0.0,
99 if (SD_task_get_state(dag->root->sd_task) == SD_NOT_SCHEDULED) {
100 DEBUG1("Dag root cost = %f", dag->root->cost);
101 DEBUG1("Scheduling root task '%s'", SD_task_get_name(dag->root->sd_task));
102 SD_task_schedule(dag->root->sd_task, 1, SD_workstation_get_list(),
103 &small_cost, no_cost, -1.0);
104 DEBUG2("Task '%s' state: %d", SD_task_get_name(dag->root->sd_task), SD_task_get_state(dag->root->sd_task));
107 /* Schedule the computation */
108 for (j=0;list[j];j++) {
111 /* schedule the task */
112 DEBUG1("Scheduling computation task '%s'", SD_task_get_name(node->sd_task));
113 SD_task_schedule(node->sd_task, 1, &NODE_ATTR(node)->host,
114 &node->cost, no_cost, -1.0);
115 DEBUG2("Task '%s' state: %d", SD_task_get_name(node->sd_task), SD_task_get_state(node->sd_task));
117 /* schedule the parent transfer */
118 for (k=0;k<node->nb_parents;k++) {
119 if (node->parents[k]->type == NODE_ROOT)
122 if (node->parents[k]->type == NODE_COMPUTATION)
125 if (node->parents[k]->type == NODE_TRANSFER) {
126 state = SD_task_get_state(node->parents[k]->sd_task);
127 if (state != SD_RUNNING && state != SD_DONE) {
128 grand_parent=node->parents[k]->parents[0];
129 grand_parent_host=NODE_ATTR(grand_parent)->host;
130 host=NODE_ATTR(node)->host;
132 host_list[0] = grand_parent_host;
134 communication_amount[1] = node->parents[k]->cost;
135 DEBUG1("Scheduling transfer task '%s'", SD_task_get_name(node->parents[k]->sd_task));
136 SD_task_schedule(node->parents[k]->sd_task, 2, host_list,
137 no_cost, communication_amount, -1.0);
138 DEBUG2("Task '%s' state: %d", SD_task_get_name(node->parents[k]->sd_task),
139 SD_task_get_state(node->parents[k]->sd_task));
142 /* if (SG_scheduleTaskOnResource(node->parents[k]->sg_task, */
143 /* local_link->sg_link) */
145 /* fprintf(stderr,"Task '%s' already in state %d\n", */
146 /* node->parents[k]->sg_task->name, */
147 /* node->parents[k]->sg_task->state); */
150 /* if (SG_scheduleTaskOnResource(node->parents[k]->sg_task, */
153 /* fprintf(stderr,"Task '%s' already in state %d\n", */
154 /* node->parents[k]->sg_task->name, */
155 /* node->parents[k]->sg_task->state); */
164 /* SG_scheduleTaskOnResource(dag->end->sg_task,local_link->sg_link); */
165 SD_task_schedule(dag->end->sd_task, 1, SD_workstation_get_list(),
166 &small_cost, no_cost, -1.0);