current_property_set = NULL;
}
-static void ptask_define_callbacks()
+void surf_host_model_init_ptask_L07(void)
{
+ XBT_INFO("Switching to the L07 model to handle parallel tasks.");
+ xbt_assert(!surf_cpu_model_pm, "CPU model type already defined");
+ xbt_assert(!surf_network_model, "network model type already defined");
+
+ // Define the callbacks to parse the XML
sg_platf_host_add_cb(cpu_parse_init);
sg_platf_host_add_cb(host_parse_init);
sg_platf_link_add_cb(ptask_netlink_parse_init);
sg_platf_postparse_add_cb(host_add_traces);
-}
-void surf_host_model_init_ptask_L07(void)
-{
- XBT_INFO("surf_host_model_init_ptask_L07");
- xbt_assert(!surf_cpu_model_pm, "CPU model type already defined");
- xbt_assert(!surf_network_model, "network model type already defined");
- ptask_define_callbacks();
surf_host_model = new HostL07Model();
Model *model = surf_host_model;
xbt_dynar_push(model_list, &model);
return min;
}
-void HostL07Model::updateActionsState(double /*now*/, double delta)
-{
- double deltap = 0.0;
- HostL07Action *action;
+void HostL07Model::updateActionsState(double /*now*/, double delta) {
+ HostL07Action *action;
ActionList *actionSet = getRunningActionSet();
- for(ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end())
- ; it != itend ; it=itNext) {
+ for(ActionList::iterator it = actionSet->begin(), itNext = it
+ ; it != actionSet->end()
+ ; it = itNext) {
++itNext;
action = static_cast<HostL07Action*>(&*it);
- deltap = delta;
if (action->m_latency > 0) {
- if (action->m_latency > deltap) {
- double_update(&(action->m_latency), deltap, sg_surf_precision);
- deltap = 0.0;
+ if (action->m_latency > delta) {
+ double_update(&(action->m_latency), delta, sg_surf_precision);
} else {
- double_update(&(deltap), action->m_latency, sg_surf_precision);
action->m_latency = 0.0;
}
if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) {
if (action->getMaxDuration() != NO_MAX_DURATION)
action->updateMaxDuration(delta);
- XBT_DEBUG("Action (%p) : remains (%g).",
- action, action->getRemains());
+ XBT_DEBUG("Action (%p) : remains (%g).", action, action->getRemains());
+
+ /* In the next if cascade, the action can be finished either because:
+ * - The amount of remaining work reached 0
+ * - The max duration was reached
+ * If it's not done, it may have failed.
+ */
+
if ((action->getRemains() <= 0) &&
(lmm_get_variable_weight(action->getVariable()) > 0)) {
action->finish();
} else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
(action->getMaxDuration() <= 0)) {
action->finish();
- action->setState(SURF_ACTION_DONE);
+ action->setState(SURF_ACTION_DONE);
} else {
/* Need to check that none of the model has failed */
lmm_constraint_t cnst = NULL;
int i = 0;
- void *constraint_id = NULL;
- while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(),
- i++))) {
- constraint_id = lmm_constraint_id(cnst);
+ while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(), i++))) {
+ void *constraint_id = lmm_constraint_id(cnst);
if (static_cast<Host*>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
XBT_DEBUG("Action (%p) Failed!!", action);
}
Action *HostL07Model::executeParallelTask(int host_nb,
- void **host_list,
- double *flops_amount,
- double *bytes_amount,
- double rate)
+ void **host_list,
+ double *flops_amount,
+ double *bytes_amount,
+ double rate)
{
HostL07Action *action;
int i, j;
xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, wk);
- return wk;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
+ return wk;
}
Action *HostL07Model::communicate(Host *src, Host *dst,
tmgr_trace_t bw_trace,
double lat_initial,
tmgr_trace_t lat_trace,
- e_surf_resource_state_t
- state_initial,
+ e_surf_resource_state_t state_initial,
tmgr_trace_t state_trace,
e_surf_link_sharing_policy_t policy,
xbt_dict_t properties)
{
xbt_assert(!Link::byName(name),
- "Link '%s' declared several times in the platform file.",
- name);
+ "Link '%s' declared several times in the platform file.", name);
- LinkL07 *nw_link = new LinkL07(this, name, properties,
- bw_initial, bw_trace,
- lat_initial, lat_trace,
- state_initial, state_trace,
- policy);
-
- return nw_link;
+ return new LinkL07(this, name, properties,
+ bw_initial, bw_trace,
+ lat_initial, lat_trace,
+ state_initial, state_trace,
+ policy);
}
void HostL07Model::addTraces()
return;
}
-void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
+void LinkL07::updateState(tmgr_trace_event_t event_type, 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) {
updateBandwidth(value, date);
return;
}
-e_surf_resource_state_t HostL07::getState()
-{
+e_surf_resource_state_t HostL07::getState() {
return p_cpu->getState();
}