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);
double HostL07Model::shareResources(double /*now*/)
{
- HostL07Action *action;
+ L07Action *action;
ActionList *running_actions = getRunningActionSet();
double min = this->shareResourcesMaxMin(running_actions,
for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end())
; it != itend ; ++it) {
- action = static_cast<HostL07Action*>(&*it);
+ action = static_cast<L07Action*>(&*it);
if (action->m_latency > 0) {
if (min < 0) {
min = action->m_latency;
return min;
}
-void HostL07Model::updateActionsState(double /*now*/, double delta)
-{
- double deltap = 0.0;
- HostL07Action *action;
+void HostL07Model::updateActionsState(double /*now*/, double delta) {
+ L07Action *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;
+ action = static_cast<L07Action*>(&*it);
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;
+ L07Action *action;
int i, j;
unsigned int cpt;
int nb_link = 0;
if (flops_amount[i] > 0)
nb_host++;
- action = new HostL07Action(this, 1, 0);
+ action = new L07Action(this, 1, 0);
XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
action, host_nb, nb_link);
action->m_suspended = 0; /* Should be useless because of the
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);
-
- LinkL07 *nw_link = new LinkL07(this, name, properties,
- bw_initial, bw_trace,
- lat_initial, lat_trace,
- state_initial, state_trace,
- policy);
+ "Link '%s' declared several times in the platform file.", name);
- 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();
}
Action *HostL07::sleep(double duration)
{
- HostL07Action *action = NULL;
+ L07Action *action = NULL;
XBT_IN("(%s,%g)", getName(), duration);
- action = static_cast<HostL07Action*>(execute(1.0));
+ action = static_cast<L07Action*>(execute(1.0));
action->m_maxDuration = duration;
action->m_suspended = 2;
lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
void LinkL07::updateLatency(double value, double date)
{
lmm_variable_t var = NULL;
- HostL07Action *action;
+ L07Action *action;
lmm_element_t elem = NULL;
m_latCurrent = value;
while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, getConstraint(), &elem))) {
- action = static_cast<HostL07Action*>(lmm_variable_id(var));
+ action = static_cast<L07Action*>(lmm_variable_id(var));
action->updateBound();
}
}
* Action *
**********/
-HostL07Action::~HostL07Action(){
+L07Action::~L07Action(){
free(p_hostList);
free(p_communicationAmount);
free(p_computationAmount);
}
-void HostL07Action::updateBound()
+void L07Action::updateBound()
{
double lat_current = 0.0;
double lat_bound = -1.0;
}
}
-int HostL07Action::unref()
+int L07Action::unref()
{
m_refcount--;
if (!m_refcount) {
return 0;
}
-void HostL07Action::cancel()
+void L07Action::cancel()
{
setState(SURF_ACTION_FAILED);
return;
}
-void HostL07Action::suspend()
+void L07Action::suspend()
{
XBT_IN("(%p))", this);
if (m_suspended != 2) {
XBT_OUT();
}
-void HostL07Action::resume()
+void L07Action::resume()
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
XBT_OUT();
}
-bool HostL07Action::isSuspended()
+bool L07Action::isSuspended()
{
return m_suspended == 1;
}
-void HostL07Action::setMaxDuration(double duration)
+void L07Action::setMaxDuration(double duration)
{ /* FIXME: should inherit */
XBT_IN("(%p,%g)", this, duration);
m_maxDuration = duration;
XBT_OUT();
}
-void HostL07Action::setPriority(double priority)
+void L07Action::setPriority(double priority)
{ /* FIXME: should inherit */
XBT_IN("(%p,%g)", this, priority);
m_priority = priority;
XBT_OUT();
}
-double HostL07Action::getRemains()
+double L07Action::getRemains()
{
XBT_IN("(%p)", this);
XBT_OUT();