1 /* Copyright (c) 2007-2010, 2013-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "workstation_ptask_L07.hpp"
8 #include "cpu_interface.hpp"
9 #include "surf_routing.hpp"
11 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_workstation);
13 static int ptask_host_count = 0;
14 static xbt_dict_t ptask_parallel_task_link_set = NULL;
15 lmm_system_t ptask_maxmin_system = NULL;
17 WorkstationL07Model::WorkstationL07Model() : WorkstationModel("Workstation ptask_L07") {
18 if (!ptask_maxmin_system)
19 ptask_maxmin_system = lmm_system_new(1);
20 surf_workstation_model = NULL;
21 surf_network_model = new NetworkL07Model();
22 surf_cpu_model_pm = new CpuL07Model();
23 routing_model_create(static_cast<ResourcePtr>(surf_network_model->createResource("__loopback__",
26 SURF_RESOURCE_ON, NULL,
27 SURF_LINK_FATPIPE, NULL)));
28 p_cpuModel = surf_cpu_model_pm;
31 WorkstationL07Model::~WorkstationL07Model() {
32 xbt_dict_free(&ptask_parallel_task_link_set);
34 delete surf_cpu_model_pm;
35 delete surf_network_model;
38 if (ptask_maxmin_system) {
39 lmm_system_free(ptask_maxmin_system);
40 ptask_maxmin_system = NULL;
44 double WorkstationL07Model::shareResources(double /*now*/)
46 WorkstationL07ActionPtr action;
48 ActionListPtr running_actions = getRunningActionSet();
49 double min = this->shareResourcesMaxMin(running_actions,
53 for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end())
54 ; it != itend ; ++it) {
55 action = static_cast<WorkstationL07ActionPtr>(&*it);
56 if (action->m_latency > 0) {
58 min = action->m_latency;
59 XBT_DEBUG("Updating min (value) with %p (start %f): %f", action,
60 action->getStartTime(), min);
61 } else if (action->m_latency < min) {
62 min = action->m_latency;
63 XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action,
64 action->getStartTime(), min);
69 XBT_DEBUG("min value : %f", min);
74 void WorkstationL07Model::updateActionsState(double /*now*/, double delta)
77 WorkstationL07ActionPtr action;
79 ActionListPtr actionSet = getRunningActionSet();
81 for(ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end())
82 ; it != itend ; it=itNext) {
84 action = static_cast<WorkstationL07ActionPtr>(&*it);
86 if (action->m_latency > 0) {
87 if (action->m_latency > deltap) {
88 double_update(&(action->m_latency), deltap, sg_surf_precision);
91 double_update(&(deltap), action->m_latency, sg_surf_precision);
92 action->m_latency = 0.0;
94 if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) {
95 action->updateBound();
96 lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 1.0);
99 XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
100 action, action->getRemains(), lmm_variable_getvalue(action->getVariable()) * delta);
101 action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
103 if (action->getMaxDuration() != NO_MAX_DURATION)
104 action->updateMaxDuration(delta);
106 XBT_DEBUG("Action (%p) : remains (%g).",
107 action, action->getRemains());
108 if ((action->getRemains() <= 0) &&
109 (lmm_get_variable_weight(action->getVariable()) > 0)) {
111 action->setState(SURF_ACTION_DONE);
112 } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
113 (action->getMaxDuration() <= 0)) {
115 action->setState(SURF_ACTION_DONE);
117 /* Need to check that none of the model has failed */
118 lmm_constraint_t cnst = NULL;
120 void *constraint_id = NULL;
122 while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(),
124 constraint_id = lmm_constraint_id(cnst);
126 if (static_cast<WorkstationPtr>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
127 XBT_DEBUG("Action (%p) Failed!!", action);
129 action->setState(SURF_ACTION_FAILED);
138 ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
139 void **workstation_list,
141 *computation_amount, double
142 *communication_amount,
145 WorkstationL07ActionPtr action;
150 double latency = 0.0;
152 if (ptask_parallel_task_link_set == NULL)
153 ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
155 xbt_dict_reset(ptask_parallel_task_link_set);
157 /* Compute the number of affected resources... */
158 for (i = 0; i < workstation_nb; i++) {
159 for (j = 0; j < workstation_nb; j++) {
160 xbt_dynar_t route=NULL;
162 if (communication_amount[i * workstation_nb + j] > 0) {
168 routing_platf->getRouteAndLatency(static_cast<WorkstationL07Ptr>(workstation_list[i])->p_netElm,
169 static_cast<WorkstationL07Ptr>(workstation_list[j])->p_netElm,
172 latency = MAX(latency, lat);
174 xbt_dynar_foreach(route, cpt, _link) {
175 link = static_cast<LinkL07Ptr>(_link);
176 xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL);
182 nb_link = xbt_dict_length(ptask_parallel_task_link_set);
183 xbt_dict_reset(ptask_parallel_task_link_set);
185 for (i = 0; i < workstation_nb; i++)
186 if (computation_amount[i] > 0)
189 action = new WorkstationL07Action(this, 1, 0);
190 XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
191 action, workstation_nb, nb_link);
192 action->m_suspended = 0; /* Should be useless because of the
193 calloc but it seems to help valgrind... */
194 action->m_workstationNb = workstation_nb;
195 action->p_workstationList = (WorkstationPtr *) workstation_list;
196 action->p_computationAmount = computation_amount;
197 action->p_communicationAmount = communication_amount;
198 action->m_latency = latency;
199 action->m_rate = rate;
201 action->p_variable = lmm_variable_new(ptask_maxmin_system, action, 1.0,
202 (action->m_rate > 0) ? action->m_rate : -1.0,
203 workstation_nb + nb_link);
205 if (action->m_latency > 0)
206 lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
208 for (i = 0; i < workstation_nb; i++)
209 lmm_expand(ptask_maxmin_system,
210 static_cast<CpuPtr>(static_cast<WorkstationL07Ptr>(workstation_list[i])->p_cpu)->getConstraint(),
211 action->getVariable(), computation_amount[i]);
213 for (i = 0; i < workstation_nb; i++) {
214 for (j = 0; j < workstation_nb; j++) {
218 xbt_dynar_t route=NULL;
219 if (communication_amount[i * workstation_nb + j] == 0.0)
222 routing_platf->getRouteAndLatency(static_cast<WorkstationL07Ptr>(workstation_list[i])->p_netElm,
223 static_cast<WorkstationL07Ptr>(workstation_list[j])->p_netElm,
226 xbt_dynar_foreach(route, cpt, _link) {
227 link = static_cast<LinkL07Ptr>(_link);
228 lmm_expand_add(ptask_maxmin_system, link->getConstraint(),
229 action->getVariable(),
230 communication_amount[i * workstation_nb + j]);
235 if (nb_link + nb_host == 0) {
236 action->setCost(1.0);
237 action->setRemains(0.0);
240 return static_cast<ActionPtr>(action);
243 ResourcePtr WorkstationL07Model::createResource(const char *name, double /*power_scale*/,
244 double /*power_initial*/,
245 tmgr_trace_t /*power_trace*/,
246 e_surf_resource_state_t /*state_initial*/,
247 tmgr_trace_t /*state_trace*/,
248 xbt_dict_t /*cpu_properties*/)
250 WorkstationL07Ptr wk = NULL;
251 xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
252 "Host '%s' declared several times in the platform file.",
255 wk = new WorkstationL07(this, name, NULL,
256 static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL)),
257 static_cast<CpuPtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL)));
259 xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(wk));
261 return wk;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
264 ActionPtr WorkstationL07Model::communicate(WorkstationPtr src, WorkstationPtr dst,
265 double size, double rate)
267 void **workstation_list = xbt_new0(void *, 2);
268 double *computation_amount = xbt_new0(double, 2);
269 double *communication_amount = xbt_new0(double, 4);
270 ActionPtr res = NULL;
272 workstation_list[0] = static_cast<ResourcePtr>(src);
273 workstation_list[1] = static_cast<ResourcePtr>(dst);
274 communication_amount[1] = size;
276 res = executeParallelTask(2, workstation_list,
278 communication_amount, rate);
283 xbt_dynar_t WorkstationL07Model::getRoute(WorkstationPtr src, WorkstationPtr dst)
285 xbt_dynar_t route=NULL;
286 routing_platf->getRouteAndLatency(src->p_netElm, dst->p_netElm, &route, NULL);
290 CpuPtr CpuL07Model::createResource(const char *name, xbt_dynar_t powerPeak,
291 int pstate, double power_scale,
292 tmgr_trace_t power_trace, int core,
293 e_surf_resource_state_t state_initial,
294 tmgr_trace_t state_trace,
295 xbt_dict_t cpu_properties)
297 double power_initial = xbt_dynar_get_as(powerPeak, pstate, double);
299 xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
300 "Host '%s' declared several times in the platform file.",
303 CpuL07Ptr cpu = new CpuL07(this, name, cpu_properties,
304 power_initial, power_scale, power_trace,state_initial, state_trace);
306 xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
308 return cpu;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
311 NetworkLinkPtr NetworkL07Model::createResource(const char *name,
313 tmgr_trace_t bw_trace,
315 tmgr_trace_t lat_trace,
316 e_surf_resource_state_t
318 tmgr_trace_t state_trace,
319 e_surf_link_sharing_policy_t policy,
320 xbt_dict_t properties)
322 xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
323 "Link '%s' declared several times in the platform file.",
326 LinkL07Ptr nw_link = new LinkL07(this, name, properties,
327 bw_initial, bw_trace,
328 lat_initial, lat_trace,
329 state_initial, state_trace,
332 xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, static_cast<ResourcePtr>(nw_link));
336 void WorkstationL07Model::addTraces()
338 xbt_dict_cursor_t cursor = NULL;
339 char *trace_name, *elm;
341 if (!trace_connect_list_host_avail)
344 /* Connect traces relative to cpu */
345 xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
346 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
347 CpuL07Ptr host = static_cast<CpuL07Ptr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
349 xbt_assert(host, "Host %s undefined", elm);
350 xbt_assert(trace, "Trace %s undefined", trace_name);
352 host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
355 xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
356 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
357 CpuL07Ptr host = static_cast<CpuL07Ptr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
359 xbt_assert(host, "Host %s undefined", elm);
360 xbt_assert(trace, "Trace %s undefined", trace_name);
362 host->p_power.event = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
365 /* Connect traces relative to network */
366 xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
367 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
368 LinkL07Ptr link = static_cast<LinkL07Ptr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL));
370 xbt_assert(link, "Link %s undefined", elm);
371 xbt_assert(trace, "Trace %s undefined", trace_name);
373 link->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
376 xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
377 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
378 LinkL07Ptr link = static_cast<LinkL07Ptr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL));
380 xbt_assert(link, "Link %s undefined", elm);
381 xbt_assert(trace, "Trace %s undefined", trace_name);
383 link->p_bwEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
386 xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
387 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
388 LinkL07Ptr link = static_cast<LinkL07Ptr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL));
390 xbt_assert(link, "Link %s undefined", elm);
391 xbt_assert(trace, "Trace %s undefined", trace_name);
393 link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
401 WorkstationL07::WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
402 : Workstation(model, name, props, NULL, netElm, cpu)
406 double WorkstationL07::getPowerPeakAt(int /*pstate_index*/)
408 XBT_DEBUG("[ws_get_power_peak_at] Not implemented for workstation_ptask_L07");
412 int WorkstationL07::getNbPstates()
414 XBT_DEBUG("[ws_get_nb_pstates] Not implemented for workstation_ptask_L07");
418 void WorkstationL07::setPowerPeakAt(int /*pstate_index*/)
420 XBT_DEBUG("[ws_set_power_peak_at] Not implemented for workstation_ptask_L07");
423 double WorkstationL07::getConsumedEnergy()
425 XBT_DEBUG("[ws_get_consumed_energy] Not implemented for workstation_ptask_L07");
429 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props,
431 double power_initial, tmgr_trace_t power_trace,
432 e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
433 : Cpu(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale),
436 p_power.scale = power_scale;
437 xbt_assert(p_power.scale > 0, "Power has to be >0");
439 m_powerCurrent = power_initial;
441 p_power.event = tmgr_history_add_trace(history, power_trace, 0.0, 0,
442 static_cast<ResourcePtr>(this));
444 p_power.event = NULL;
446 setState(state_initial);
448 p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
451 LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
453 tmgr_trace_t bw_trace,
455 tmgr_trace_t lat_trace,
456 e_surf_resource_state_t state_initial,
457 tmgr_trace_t state_trace,
458 e_surf_link_sharing_policy_t policy)
459 : NetworkLink(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, bw_initial), history, state_trace)
461 m_bwCurrent = bw_initial;
463 p_bwEvent = tmgr_history_add_trace(history, bw_trace, 0.0, 0, static_cast<ResourcePtr>(this));
465 setState(state_initial);
466 m_latCurrent = lat_initial;
469 p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(this));
471 if (policy == SURF_LINK_FATPIPE)
472 lmm_constraint_shared(getConstraint());
475 bool CpuL07::isUsed(){
476 return lmm_constraint_used(ptask_maxmin_system, getConstraint());
479 bool LinkL07::isUsed(){
480 return lmm_constraint_used(ptask_maxmin_system, getConstraint());
483 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
484 XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value);
485 if (event_type == p_power.event) {
486 m_powerCurrent = value;
487 lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_powerCurrent * p_power.scale);
488 if (tmgr_trace_event_free(event_type))
489 p_power.event = NULL;
490 } else if (event_type == p_stateEvent) {
492 setState(SURF_RESOURCE_ON);
494 setState(SURF_RESOURCE_OFF);
495 if (tmgr_trace_event_free(event_type))
498 XBT_CRITICAL("Unknown event ! \n");
504 void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
505 XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", getName(), this, value, date);
506 if (event_type == p_bwEvent) {
507 updateBandwidth(value, date);
508 if (tmgr_trace_event_free(event_type))
510 } else if (event_type == p_latEvent) {
511 updateLatency(value, date);
512 if (tmgr_trace_event_free(event_type))
514 } else if (event_type == p_stateEvent) {
516 setState(SURF_RESOURCE_ON);
518 setState(SURF_RESOURCE_OFF);
519 if (tmgr_trace_event_free(event_type))
522 XBT_CRITICAL("Unknown event ! \n");
528 e_surf_resource_state_t WorkstationL07::getState()
530 return p_cpu->getState();
533 double CpuL07::getSpeed(double load)
535 return load * p_power.scale;
538 double CpuL07::getAvailableSpeed()
540 return m_powerCurrent;
543 ActionPtr WorkstationL07::execute(double size)
545 void **workstation_list = xbt_new0(void *, 1);
546 double *computation_amount = xbt_new0(double, 1);
547 double *communication_amount = xbt_new0(double, 1);
549 workstation_list[0] = static_cast<ResourcePtr>(this);
550 communication_amount[0] = 0.0;
551 computation_amount[0] = size;
553 return static_cast<WorkstationL07ModelPtr>(getModel())->executeParallelTask(1, workstation_list,
555 communication_amount, -1);
558 ActionPtr WorkstationL07::sleep(double duration)
560 WorkstationL07ActionPtr action = NULL;
562 XBT_IN("(%s,%g)", getName(), duration);
564 action = static_cast<WorkstationL07ActionPtr>(execute(1.0));
565 action->m_maxDuration = duration;
566 action->m_suspended = 2;
567 lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
573 double LinkL07::getBandwidth()
578 void LinkL07::updateBandwidth(double value, double date)
581 lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_bwCurrent);
584 double LinkL07::getLatency()
589 void LinkL07::updateLatency(double value, double date)
591 lmm_variable_t var = NULL;
592 WorkstationL07ActionPtr action;
593 lmm_element_t elem = NULL;
595 m_latCurrent = value;
596 while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, getConstraint(), &elem))) {
597 action = (WorkstationL07ActionPtr) lmm_variable_id(var);
598 action->updateBound();
603 bool LinkL07::isShared()
605 return lmm_constraint_is_shared(getConstraint());
612 WorkstationL07Action::~WorkstationL07Action(){
613 free(p_workstationList);
614 free(p_communicationAmount);
615 free(p_computationAmount);
618 void WorkstationL07Action::updateBound()
620 double lat_current = 0.0;
621 double lat_bound = -1.0;
624 for (i = 0; i < m_workstationNb; i++) {
625 for (j = 0; j < m_workstationNb; j++) {
626 xbt_dynar_t route=NULL;
628 if (p_communicationAmount[i * m_workstationNb + j] > 0) {
630 routing_platf->getRouteAndLatency(static_cast<WorkstationL07Ptr>(((void**)p_workstationList)[i])->p_netElm,
631 static_cast<WorkstationL07Ptr>(((void**)p_workstationList)[j])->p_netElm,
634 lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_workstationNb + j]);
638 lat_bound = sg_tcp_gamma / (2.0 * lat_current);
639 XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
640 if ((m_latency == 0.0) && (m_suspended == 0)) {
642 lmm_update_variable_bound(ptask_maxmin_system, getVariable(), lat_bound);
644 lmm_update_variable_bound(ptask_maxmin_system, getVariable(), min(m_rate, lat_bound));
648 int WorkstationL07Action::unref()
652 if (actionHook::is_linked())
653 p_stateSet->erase(p_stateSet->iterator_to(*this));
655 lmm_variable_free(ptask_maxmin_system, getVariable());
662 void WorkstationL07Action::cancel()
664 setState(SURF_ACTION_FAILED);
668 void WorkstationL07Action::suspend()
670 XBT_IN("(%p))", this);
671 if (m_suspended != 2) {
673 lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 0.0);
678 void WorkstationL07Action::resume()
680 XBT_IN("(%p)", this);
681 if (m_suspended != 2) {
682 lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 1.0);
688 bool WorkstationL07Action::isSuspended()
690 return m_suspended == 1;
693 void WorkstationL07Action::setMaxDuration(double duration)
694 { /* FIXME: should inherit */
695 XBT_IN("(%p,%g)", this, duration);
696 m_maxDuration = duration;
700 void WorkstationL07Action::setPriority(double priority)
701 { /* FIXME: should inherit */
702 XBT_IN("(%p,%g)", this, priority);
703 m_priority = priority;
707 double WorkstationL07Action::getRemains()
709 XBT_IN("(%p)", this);
714 /*FIXME:remove static void ptask_finalize(void)
716 xbt_dict_free(&ptask_parallel_task_link_set);
718 delete surf_workstation_model;
719 surf_workstation_model = NULL;
720 delete surf_network_model;
721 surf_network_model = NULL;
723 ptask_host_count = 0;
725 if (ptask_maxmin_system) {
726 lmm_system_free(ptask_maxmin_system);
727 ptask_maxmin_system = NULL;
731 /**************************************/
732 /******* Resource Private **********/
733 /**************************************/
735 /**************************************/
736 /*** Resource Creation & Destruction **/
737 /**************************************/
739 static void ptask_parse_workstation_init(sg_platf_host_cbarg_t host)
741 double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
742 //cpu->power_peak = power_peak;
743 xbt_dynar_free(&(host->power_peak)); /* kill memory leak */
744 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->createResource(
754 static void ptask_parse_link_init(sg_platf_link_cbarg_t link)
756 if (link->policy == SURF_LINK_FULLDUPLEX) {
758 link_id = bprintf("%s_UP", link->id);
759 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
761 link->bandwidth_trace,
769 link_id = bprintf("%s_DOWN", link->id);
770 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
772 link->bandwidth_trace,
778 NULL); /* FIXME: We need to deep copy the
779 * properties or we won't be able to free
783 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link->id,
785 link->bandwidth_trace,
794 current_property_set = NULL;
797 static void ptask_add_traces(){
798 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->addTraces();
801 static void ptask_define_callbacks()
803 sg_platf_host_add_cb(parse_cpu_init);
804 sg_platf_host_add_cb(ptask_parse_workstation_init);
805 sg_platf_link_add_cb(ptask_parse_link_init);
806 sg_platf_postparse_add_cb(ptask_add_traces);
809 /**************************************/
810 /*************** Generic **************/
811 /**************************************/
812 void surf_workstation_model_init_ptask_L07(void)
814 XBT_INFO("surf_workstation_model_init_ptask_L07");
815 xbt_assert(!surf_cpu_model_pm, "CPU model type already defined");
816 xbt_assert(!surf_network_model, "network model type already defined");
817 ptask_define_callbacks();
818 surf_workstation_model = new WorkstationL07Model();
819 ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
820 xbt_dynar_push(model_list, &model);
821 xbt_dynar_push(model_list_invoke, &model);