/* Remove all dependencies associated with a task. This function is called when the task is destroyed. */
static void __SD_task_remove_dependencies(SD_task_t task)
{
- /* we must destroy the dependencies carefuly (with SD_dependency_remove) because each one is stored twice */
+ /* we must destroy the dependencies carefully (with SD_dependency_remove) because each one is stored twice */
SD_dependency_t dependency;
while (xbt_dynar_is_empty(task->tasks_before) == 0) {
xbt_dynar_get_cpy(task->tasks_before, 0, &dependency);
/* Reset the content */
task->kind = SD_TASK_NOT_TYPED;
task->state= SD_NOT_SCHEDULED;
- xbt_dynar_push(sd_global->initial_task_set,&task);
+ sd_global->initial_tasks->insert(task);
task->marked = 0;
*/
void SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state)
{
- int idx;
+ std::set<SD_task_t>::iterator idx;
switch (new_state) {
case SD_NOT_SCHEDULED:
case SD_SCHEDULABLE:
if (SD_task_get_state(task) == SD_FAILED){
- xbt_dynar_remove_at(sd_global->completed_task_set,
- xbt_dynar_search(sd_global->completed_task_set, &task), nullptr);
- xbt_dynar_push(sd_global->initial_task_set,&task);
+ sd_global->completed_tasks->erase(task);
+ sd_global->initial_tasks->insert(task);
}
break;
case SD_SCHEDULED:
if (SD_task_get_state(task) == SD_RUNNABLE){
- xbt_dynar_remove_at(sd_global->executable_task_set,
- xbt_dynar_search(sd_global->executable_task_set, &task), nullptr);
- xbt_dynar_push(sd_global->initial_task_set,&task);
+ sd_global->initial_tasks->insert(task);
+ sd_global->executable_tasks->erase(task);
}
break;
case SD_RUNNABLE:
- idx = xbt_dynar_search_or_negative(sd_global->initial_task_set, &task);
- if (idx >= 0) {
- xbt_dynar_remove_at(sd_global->initial_task_set, idx, nullptr);
- xbt_dynar_push(sd_global->executable_task_set,&task);
+ idx = std::find(sd_global->initial_tasks->begin(), sd_global->initial_tasks->end(), task);
+ if (idx != sd_global->initial_tasks->end()) {
+ sd_global->executable_tasks->insert(*idx);
+ sd_global->initial_tasks->erase(idx);
}
break;
case SD_RUNNING:
- xbt_dynar_remove_at(sd_global->executable_task_set,
- xbt_dynar_search(sd_global->executable_task_set, &task), nullptr);
+ sd_global->executable_tasks->erase(task);
break;
case SD_DONE:
- xbt_dynar_push(sd_global->completed_task_set,&task);
+ sd_global->completed_tasks->insert(task);
task->finish_time = task->surf_action->getFinishTime();
task->remains = 0;
#if HAVE_JEDULE
#endif
break;
case SD_FAILED:
- xbt_dynar_push(sd_global->completed_task_set,&task);
+ sd_global->completed_tasks->insert(task);
break;
default:
xbt_die( "Invalid state");
}
/**
- * \brief Returns the amount of workstations involved in a task
+ * \brief Returns the number of workstations involved in a task
*
* Only call this on already scheduled tasks!
* \param task a task
* \param task the task to evaluate
* \param workstation_nb number of workstations on which the task would be executed
* \param workstation_list the workstations on which the task would be executed
- * \param flops_amount computation amount for each workstation
- * \param bytes_amount communication amount between each pair of workstations
+ * \param flops_amount computation amount for each workstation (i.e., an array of workstation_nb doubles)
+ * \param bytes_amount communication amount between each pair of workstations (i.e., a matrix of
+ * workstation_nb*workstation_nb doubles)
* \see SD_schedule()
*/
double SD_task_get_execution_time(SD_task_t task, int workstation_nb, const sg_host_t *workstation_list,
* Once scheduled, a task is executed as soon as possible in \see SD_simulate, i.e. when its dependencies are satisfied.
*
* \param task the task you want to schedule
- * \param host_count number of workstations on which the task will be executed
- * \param workstation_list the workstations on which the task will be executed
- * \param flops_amount computation amount for each workstation
- * \param bytes_amount communication amount between each pair of workstations
+ * \param host_count number of hosts on which the task will be executed
+ * \param workstation_list the hosts on which the task will be executed
+ * \param flops_amount computation amount for each hosts (i.e., an array of host_count doubles)
+ * \param bytes_amount communication amount between each pair of hosts (i.e., a matrix of host_count*host_count doubles)
* \param rate task execution speed rate
* \see SD_task_unschedule()
*/
double src_start, src_end, dst_start, dst_end;
src_nb = before->host_count;
dst_nb = count;
- before->host_list = (sg_host_t*) xbt_realloc(before->host_list, (before->host_count+count)*sizeof(sg_host_t));
+ before->host_list = static_cast<sg_host_t*>(xbt_realloc(before->host_list, (before->host_count+count)*sizeof(sg_host_t)));
for(i=0; i<count; i++)
before->host_list[before->host_count+i] = task->host_list[i];
if (SD_task_get_state(before)< SD_SCHEDULED) {
SD_task_do_schedule(before);
- XBT_VERB
- ("Auto-Schedule redistribution task %s. Send %.f bytes from %d hosts to %d hosts.",
+ XBT_VERB ("Auto-Schedule redistribution task %s. Send %.f bytes from %d hosts to %d hosts.",
SD_task_get_name(before),before->amount, src_nb, dst_nb);
}
}
double src_start, src_end, dst_start, dst_end;
src_nb = count;
dst_nb = after->host_count;
- after->host_list = (sg_host_t*) xbt_realloc(after->host_list, (after->host_count+count)*sizeof(sg_host_t));
+ after->host_list = static_cast<sg_host_t*>(xbt_realloc(after->host_list, (after->host_count+count)*sizeof(sg_host_t)));
for(i=after->host_count - 1; i>=0; i--)
after->host_list[count+i] = after->host_list[i];
for(i=0; i<count; i++)