X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/268aabc05cf124783cd4972c9bc3d8b735ce5f95..f9dd39e26289f9ba2d4ef96fbbed1709bff22043:/src/surf/host_ptask_L07.cpp diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index 1d230efa94..e3a93e4eae 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -209,23 +209,25 @@ L07Action::L07Action(Model *model, int host_nb, this->p_netcardList->push_back(host_list[i]->pimpl_netcard); /* Compute the number of affected resources... */ - for (int i = 0; i < host_nb; i++) { - for (int j = 0; j < host_nb; j++) { - xbt_dynar_t route=NULL; - - if (bytes_amount[i * host_nb + j] > 0) { - double lat=0.0; - unsigned int cpt; - void *_link; - LinkL07 *link; - - routing_platf->getRouteAndLatency((*this->p_netcardList)[i], (*this->p_netcardList)[j], - &route, &lat); - latency = MAX(latency, lat); - - xbt_dynar_foreach(route, cpt, _link) { - link = static_cast(_link); - xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL); + if(bytes_amount != NULL) { + for (int i = 0; i < host_nb; i++) { + for (int j = 0; j < host_nb; j++) { + xbt_dynar_t route=NULL; + + if (bytes_amount[i * host_nb + j] > 0) { + double lat=0.0; + unsigned int cpt; + void *_link; + LinkL07 *link; + + routing_platf->getRouteAndLatency((*this->p_netcardList)[i], (*this->p_netcardList)[j], + &route, &lat); + latency = MAX(latency, lat); + + xbt_dynar_foreach(route, cpt, _link) { + link = static_cast(_link); + xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL); + } } } } @@ -257,22 +259,23 @@ L07Action::L07Action(Model *model, int host_nb, host_list[i]->pimpl_cpu->getConstraint(), this->getVariable(), flops_amount[i]); - for (int i = 0; i < host_nb; i++) { - for (int j = 0; j < host_nb; j++) { - void *_link; + if(bytes_amount != NULL) { + for (int i = 0; i < host_nb; i++) { + for (int j = 0; j < host_nb; j++) { + void *_link; - xbt_dynar_t route=NULL; - if (bytes_amount[i * host_nb + j] == 0.0) - continue; + xbt_dynar_t route=NULL; + if (bytes_amount[i * host_nb + j] == 0.0) + continue; - routing_platf->getRouteAndLatency((*this->p_netcardList)[i], (*this->p_netcardList)[j], - &route, NULL); + routing_platf->getRouteAndLatency((*this->p_netcardList)[i], (*this->p_netcardList)[j], + &route, NULL); - xbt_dynar_foreach(route, cpt, _link) { - LinkL07 *link = static_cast(_link); - lmm_expand_add(model->getMaxminSystem(), link->getConstraint(), - this->getVariable(), - bytes_amount[i * host_nb + j]); + xbt_dynar_foreach(route, cpt, _link) { + LinkL07 *link = static_cast(_link); + lmm_expand_add(model->getMaxminSystem(), link->getConstraint(), + this->getVariable(), bytes_amount[i * host_nb + j]); + } } } } @@ -447,7 +450,7 @@ LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, lmm_constraint_shared(getConstraint()); } -Action *CpuL07::execute(double size) +Action *CpuL07::execution_start(double size) { sg_host_t*host_list = xbt_new0(sg_host_t, 1); double *flops_amount = xbt_new0(double, 1); @@ -456,23 +459,17 @@ Action *CpuL07::execute(double size) host_list[0] = getHost(); flops_amount[0] = size; - return static_cast(getModel()) - ->p_hostModel + return static_cast(getModel())->p_hostModel ->executeParallelTask( 1, host_list, flops_amount, bytes_amount, -1); } Action *CpuL07::sleep(double duration) { - L07Action *action = NULL; - - XBT_IN("(%s,%g)", getName(), duration); - - action = static_cast(execute(1.0)); + L07Action *action = static_cast(execution_start(1.0)); action->m_maxDuration = duration; action->m_suspended = 2; lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), 0.0); - XBT_OUT(); return action; } @@ -503,49 +500,40 @@ bool LinkL07::isUsed(){ return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint()); } -void CpuL07::updateState(tmgr_trace_iterator_t event_type, double value, double /*date*/){ +void CpuL07::updateState(tmgr_trace_iterator_t triggered, double value, double /*date*/){ XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value); - if (event_type == p_speedEvent) { - m_speedScale = value; - onSpeedChange(); - if (tmgr_trace_event_free(event_type)) - p_speedEvent = NULL; - } else if (event_type == p_stateEvent) { + if (triggered == p_speedEvent) { + m_speedScale = value; + onSpeedChange(); + tmgr_trace_event_unref(&p_speedEvent); + } else if (triggered == p_stateEvent) { if (value > 0) turnOn(); else turnOff(); - if (tmgr_trace_event_free(event_type)) - p_stateEvent = NULL; + tmgr_trace_event_unref(&p_stateEvent); } else { - XBT_CRITICAL("Unknown event ! \n"); - xbt_abort(); + xbt_die("Unknown event!\n"); } - return; } -void LinkL07::updateState(tmgr_trace_iterator_t event_type, double value, double date) { +void LinkL07::updateState(tmgr_trace_iterator_t triggered, double value, double date) { XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", getName(), this, value, date); - if (event_type == p_bwEvent) { + if (triggered == p_bwEvent) { updateBandwidth(value, date); - if (tmgr_trace_event_free(event_type)) - p_bwEvent = NULL; - } else if (event_type == p_latEvent) { + tmgr_trace_event_unref(&p_bwEvent); + } else if (triggered == p_latEvent) { updateLatency(value, date); - if (tmgr_trace_event_free(event_type)) - p_latEvent = NULL; - } else if (event_type == p_stateEvent) { + tmgr_trace_event_unref(&p_latEvent); + } else if (triggered == p_stateEvent) { if (value > 0) turnOn(); else turnOff(); - if (tmgr_trace_event_free(event_type)) - p_stateEvent = NULL; + tmgr_trace_event_unref(&p_stateEvent); } else { - XBT_CRITICAL("Unknown event ! \n"); - xbt_abort(); + xbt_die("Unknown event ! \n"); } - return; } double LinkL07::getBandwidth() @@ -589,16 +577,18 @@ void L07Action::updateBound() int hostNb = p_netcardList->size(); - for (i = 0; i < hostNb; i++) { - for (j = 0; j < hostNb; j++) { - xbt_dynar_t route=NULL; + if (p_communicationAmount != NULL) { + for (i = 0; i < hostNb; i++) { + for (j = 0; j < hostNb; j++) { + xbt_dynar_t route=NULL; - if (p_communicationAmount[i * hostNb + j] > 0) { - double lat = 0.0; - routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], - &route, &lat); + if (p_communicationAmount[i * hostNb + j] > 0) { + double lat = 0.0; + routing_platf->getRouteAndLatency((*p_netcardList)[i], (*p_netcardList)[j], + &route, &lat); - lat_current = MAX(lat_current, lat * p_communicationAmount[i * hostNb + j]); + lat_current = MAX(lat_current, lat * p_communicationAmount[i * hostNb + j]); + } } } } @@ -627,46 +617,5 @@ int L07Action::unref() return 0; } -void L07Action::suspend() -{ - XBT_IN("(%p))", this); - if (m_suspended != 2) { - m_suspended = 1; - lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0); - } - XBT_OUT(); -} - -void L07Action::resume() -{ - XBT_IN("(%p)", this); - if (m_suspended != 2) { - lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 1.0); - m_suspended = 0; - } - XBT_OUT(); -} - -void L07Action::setMaxDuration(double duration) -{ /* FIXME: should inherit */ - XBT_IN("(%p,%g)", this, duration); - m_maxDuration = duration; - XBT_OUT(); -} - -void L07Action::setPriority(double priority) -{ /* FIXME: should inherit */ - XBT_IN("(%p,%g)", this, priority); - m_priority = priority; - XBT_OUT(); -} - -double L07Action::getRemains() -{ - XBT_IN("(%p)", this); - XBT_OUT(); - return m_remains; -} - } }