X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f06041cf2c450457a0b47a49b66b19cb9133c18e..b3b356352e87ae00a20f737c48e19b0c8413455a:/src/simdag/sd_task.c diff --git a/src/simdag/sd_task.c b/src/simdag/sd_task.c index 9ab54e6cde..c55d588f79 100644 --- a/src/simdag/sd_task.c +++ b/src/simdag/sd_task.c @@ -1,4 +1,4 @@ -/* 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 @@ -292,9 +292,10 @@ void SD_task_set_data(SD_task_t task, void *data) * \brief Sets the rate of a task * * This will change the network bandwidth a task can use. This rate - * depends on both the nominal bandwidth on the route onto which the task is - * scheduled (\see SD_task_get_current_bandwidth) and the amount of data to - * transfer. + * cannot be dynamically changed. Once the task has started, this call + * is ineffective. This rate depends on both the nominal bandwidth on + * the route onto which the task is scheduled (\see + * SD_task_get_current_bandwidth) and the amount of data to transfer. * * To divide the nominal bandwidth by 2, the rate then has to be : * rate = bandwidth/(2*amount) @@ -306,8 +307,11 @@ void SD_task_set_rate(SD_task_t task, double rate) { xbt_assert(task->kind == SD_TASK_COMM_E2E, "The rate can be modified for end-to-end communications only."); - - task->rate = rate; + if(task->start_time<0) { + task->rate = rate; + } else { + XBT_WARN("Task %p has started. Changing rate is ineffective.", task); + } } /** @@ -1086,7 +1090,7 @@ void __SD_task_really_run(SD_task_t task) { int i; - void **surf_workstations; + 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", @@ -1096,13 +1100,13 @@ void __SD_task_really_run(SD_task_t task) SD_task_get_name(task)); XBT_DEBUG("Really running task '%s'", SD_task_get_name(task)); - int workstation_nb = task->workstation_nb; + int host_nb = task->workstation_nb; /* set this task as current task for the workstations in sequential mode */ - for (i = 0; i < workstation_nb; i++) { + 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"); } @@ -1113,27 +1117,26 @@ void __SD_task_really_run(SD_task_t task) /* start the task */ - /* we have to create a Surf workstation array instead of the SimDag - * workstation array */ - surf_workstations = xbt_new(void *, workstation_nb); + /* Copy the elements of the task into the action */ + hosts = xbt_new(sg_host_t, host_nb); - for (i = 0; i < workstation_nb; i++) - surf_workstations[i] = surf_workstation_resource_priv(task->workstation_list[i]); + for (i = 0; i < host_nb; i++) + hosts[i] = task->workstation_list[i]; - double *flops_amount = xbt_new0(double, workstation_nb); - double *bytes_amount = xbt_new0(double, workstation_nb * workstation_nb); + double *flops_amount = xbt_new0(double, host_nb); + double *bytes_amount = xbt_new0(double, host_nb * host_nb); if(task->flops_amount) memcpy(flops_amount, task->flops_amount, sizeof(double) * - workstation_nb); + host_nb); if(task->bytes_amount) memcpy(bytes_amount, task->bytes_amount, - sizeof(double) * workstation_nb * workstation_nb); + sizeof(double) * host_nb * host_nb); - task->surf_action = surf_workstation_model_execute_parallel_task((surf_workstation_model_t)surf_workstation_model, - workstation_nb, - surf_workstations, + task->surf_action = surf_host_model_execute_parallel_task((surf_host_model_t)surf_host_model, + host_nb, + hosts, flops_amount, bytes_amount, task->rate); @@ -1181,11 +1184,11 @@ int __SD_task_try_to_run(SD_task_t task) 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); @@ -1235,23 +1238,23 @@ void __SD_task_just_done(SD_task_t task) 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)); @@ -1305,10 +1308,10 @@ void __SD_task_just_done(SD_task_t task) /* 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), @@ -1320,8 +1323,8 @@ void __SD_task_just_done(SD_task_t task) 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");