}
CpuL07Model::~CpuL07Model() {
surf_cpu_model_pm = NULL;
- p_maxminSystem = NULL; // Avoid multi-free
+ lmm_system_free(p_maxminSystem);
+ p_maxminSystem = NULL;
}
NetworkL07Model::NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys)
: NetworkModel()
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<LinkL07*>(_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<LinkL07*>(_link);
+ xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL);
+ }
}
}
}
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<LinkL07*>(_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<LinkL07*>(_link);
+ lmm_expand_add(model->getMaxminSystem(), link->getConstraint(),
+ this->getVariable(), bytes_amount[i * host_nb + j]);
+ }
}
}
}
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ host->p_stateEvent = future_evt_set->add_trace(trace, 0.0, host);
}
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- host->p_speedEvent = tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ host->p_speedEvent = future_evt_set->add_trace(trace, 0.0, host);
}
/* Connect traces relative to network */
xbt_assert(link, "Link %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- link->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ link->p_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
}
xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
xbt_assert(link, "Link %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- link->p_bwEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ link->p_bwEvent = future_evt_set->add_trace(trace, 0.0, link);
}
xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
xbt_assert(link, "Link %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ link->p_latEvent = future_evt_set->add_trace(trace, 0.0, link);
}
}
p_constraint = lmm_constraint_new(model->getMaxminSystem(), this, xbt_dynar_get_as(speedPeakList,pstate,double) * speedScale);
if (speedTrace)
- p_speedEvent = tmgr_history_add_trace(history, speedTrace, 0.0, 0, this);
- else
- p_speedEvent = NULL;
+ p_speedEvent = future_evt_set->add_trace(speedTrace, 0.0, this);
if (state_trace)
- p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, this);
+ p_stateEvent = future_evt_set->add_trace(state_trace, 0.0, this);
}
CpuL07::~CpuL07()
int initiallyOn,
tmgr_trace_t state_trace,
e_surf_link_sharing_policy_t policy)
- : Link(model, name, props, lmm_constraint_new(model->getMaxminSystem(), this, bw_initial), history, state_trace)
+ : Link(model, name, props, lmm_constraint_new(model->getMaxminSystem(), this, bw_initial), future_evt_set, state_trace)
{
m_bwCurrent = bw_initial;
if (bw_trace)
- p_bwEvent = tmgr_history_add_trace(history, bw_trace, 0.0, 0, this);
+ p_bwEvent = future_evt_set->add_trace(bw_trace, 0.0, this);
if (initiallyOn)
turnOn();
m_latCurrent = lat_initial;
if (lat_trace)
- p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, this);
+ p_latEvent = future_evt_set->add_trace(lat_trace, 0.0, this);
if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(getConstraint());
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()
**********/
L07Action::~L07Action(){
- free(p_communicationAmount);
+ if (p_communicationAmount != NULL)
+ free(p_communicationAmount);
free(p_computationAmount);
}
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]);
+ }
}
}
}