-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2015. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "simgrid/simdag.h"
#include "xbt/sysdep.h"
#include "xbt/dynar.h"
-#include "instr/instr_private.h"
+#include "src/instr/instr_private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_task, sd,
"Logging specific to SimDag (task)");
{
int i;
- void **surf_hosts;
+ sg_host_t *hosts;
xbt_assert(__SD_task_is_runnable_or_in_fifo(task),
"Task '%s' is not runnable or in a fifo! Task state: %d",
for (i = 0; i < host_nb; i++) {
if (SD_workstation_get_access_mode(task->workstation_list[i]) ==
SD_WORKSTATION_SEQUENTIAL_ACCESS) {
- SD_workstation_priv(task->workstation_list[i])->current_task = task;
+ sg_host_sd(task->workstation_list[i])->current_task = task;
xbt_assert(__SD_workstation_is_busy(task->workstation_list[i]),
"The workstation should be busy now");
}
/* start the task */
- /* we have to create a Surf workstation array instead of the SimDag
- * workstation array */
- surf_hosts = xbt_new(void *, host_nb);
+ /* Copy the elements of the task into the action */
+ hosts = xbt_new(sg_host_t, host_nb);
for (i = 0; i < host_nb; i++)
- surf_hosts[i] = surf_host_resource_priv(task->workstation_list[i]);
+ hosts[i] = task->workstation_list[i];
double *flops_amount = xbt_new0(double, host_nb);
double *bytes_amount = xbt_new0(double, host_nb * host_nb);
task->surf_action = surf_host_model_execute_parallel_task((surf_host_model_t)surf_host_model,
host_nb,
- surf_hosts,
+ hosts,
flops_amount,
bytes_amount,
task->rate);
if (!can_start) { /* if the task cannot start and is not in the FIFOs yet */
for (i = 0; i < task->workstation_nb; i++) {
workstation = task->workstation_list[i];
- if (SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
+ if (sg_host_sd(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
XBT_DEBUG("Pushing task '%s' in the FIFO of workstation '%s'",
SD_task_get_name(task),
SD_workstation_get_name(workstation));
- xbt_fifo_push(SD_workstation_priv(workstation)->task_fifo, task);
+ xbt_fifo_push(sg_host_sd(workstation)->task_fifo, task);
}
}
__SD_task_set_state(task, SD_IN_FIFO);
for (i = 0; i < task->workstation_nb; i++) {
workstation = task->workstation_list[i];
XBT_DEBUG("Workstation '%s': access_mode = %d",
- SD_workstation_get_name(workstation), (int)SD_workstation_priv(workstation)->access_mode);
- if (SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
- xbt_assert(SD_workstation_priv(workstation)->task_fifo != NULL,
+ SD_workstation_get_name(workstation), (int)sg_host_sd(workstation)->access_mode);
+ if (sg_host_sd(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
+ xbt_assert(sg_host_sd(workstation)->task_fifo != NULL,
"Workstation '%s' has sequential access but no FIFO!",
SD_workstation_get_name(workstation));
- xbt_assert(SD_workstation_priv(workstation)->current_task =
+ xbt_assert(sg_host_sd(workstation)->current_task =
task, "Workstation '%s': current task should be '%s'",
SD_workstation_get_name(workstation),
SD_task_get_name(task));
/* the task is over so we can release the workstation */
- SD_workstation_priv(workstation)->current_task = NULL;
+ sg_host_sd(workstation)->current_task = NULL;
XBT_DEBUG("Getting candidate in FIFO");
candidate =
xbt_fifo_get_item_content(xbt_fifo_get_first_item
- (SD_workstation_priv(workstation)->task_fifo));
+ (sg_host_sd(workstation)->task_fifo));
if (candidate != NULL) {
XBT_DEBUG("Candidate: '%s'", SD_task_get_name(candidate));
/* I can start on this workstation if the workstation is shared
or if I am the first task in the FIFO */
- can_start = SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SHARED_ACCESS
+ can_start = sg_host_sd(workstation)->access_mode == SD_WORKSTATION_SHARED_ACCESS
|| candidate ==
xbt_fifo_get_item_content(xbt_fifo_get_first_item
- (SD_workstation_priv(workstation)->task_fifo));
+ (sg_host_sd(workstation)->task_fifo));
}
XBT_DEBUG("Candidate '%s' can start: %d", SD_task_get_name(candidate),
workstation = candidate->workstation_list[j];
/* update the FIFO */
- if (SD_workstation_priv(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
- candidate = xbt_fifo_shift(SD_workstation_priv(workstation)->task_fifo); /* the return value is stored just for debugging */
+ if (sg_host_sd(workstation)->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
+ candidate = xbt_fifo_shift(sg_host_sd(workstation)->task_fifo); /* the return value is stored just for debugging */
XBT_DEBUG("Head of the FIFO: '%s'",
(candidate !=
NULL) ? SD_task_get_name(candidate) : "NULL");