1 /* Copyright (c) 2007, 2008, 2009, 2010. 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"
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(p_networkModel->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*/)
47 WorkstationL07ActionLmmPtr action;
49 xbt_swag_t running_actions = this->p_runningActionSet;
50 double min = this->shareResourcesMaxMin(running_actions,
54 xbt_swag_foreach(_action, running_actions) {
55 action = dynamic_cast<WorkstationL07ActionLmmPtr>(static_cast<ActionPtr>(_action));
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->m_start, 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->m_start, min);
69 XBT_DEBUG("min value : %f", min);
74 void WorkstationL07Model::updateActionsState(double /*now*/, double delta)
77 void *_action, *_next_action;
78 WorkstationL07ActionLmmPtr action;
80 xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
81 action = dynamic_cast<WorkstationL07ActionLmmPtr>(static_cast<ActionPtr>(_action));
84 if (action->m_latency > 0) {
85 if (action->m_latency > deltap) {
86 double_update(&(action->m_latency), deltap);
89 double_update(&(deltap), action->m_latency);
90 action->m_latency = 0.0;
92 if ((action->m_latency == 0.0) && (action->m_suspended == 0)) {
93 action->updateBound();
94 lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 1.0);
97 XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
98 action, action->m_remains, lmm_variable_getvalue(action->p_variable) * delta);
99 double_update(&(action->m_remains), lmm_variable_getvalue(action->p_variable) * delta);
101 if (action->m_maxDuration != NO_MAX_DURATION)
102 double_update(&(action->m_maxDuration), delta);
104 XBT_DEBUG("Action (%p) : remains (%g).",
105 action, action->m_remains);
106 if ((action->m_remains <= 0) &&
107 (lmm_get_variable_weight(action->p_variable) > 0)) {
108 action->m_finish = surf_get_clock();
109 action->setState(SURF_ACTION_DONE);
110 } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
111 (action->m_maxDuration <= 0)) {
112 action->m_finish = surf_get_clock();
113 action->setState(SURF_ACTION_DONE);
115 /* Need to check that none of the model has failed */
116 lmm_constraint_t cnst = NULL;
118 void *constraint_id = NULL;
120 while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->p_variable,
122 constraint_id = lmm_constraint_id(cnst);
124 if (static_cast<WorkstationCLM03LmmPtr>(constraint_id)->p_stateCurrent == SURF_RESOURCE_OFF) {
125 XBT_DEBUG("Action (%p) Failed!!", action);
126 action->m_finish = surf_get_clock();
127 action->setState(SURF_ACTION_FAILED);
136 ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
137 void **workstation_list,
139 *computation_amount, double
140 *communication_amount,
143 WorkstationL07ActionLmmPtr action;
148 double latency = 0.0;
150 if (ptask_parallel_task_link_set == NULL)
151 ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
153 xbt_dict_reset(ptask_parallel_task_link_set);
155 /* Compute the number of affected resources... */
156 for (i = 0; i < workstation_nb; i++) {
157 for (j = 0; j < workstation_nb; j++) {
158 xbt_dynar_t route=NULL;
160 if (communication_amount[i * workstation_nb + j] > 0) {
166 routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
167 static_cast<ResourcePtr>(
168 workstation_list[i]))->p_netElm,
169 dynamic_cast<WorkstationL07Ptr>(
170 static_cast<ResourcePtr>(
171 workstation_list[j]))->p_netElm,
174 latency = MAX(latency, lat);
176 xbt_dynar_foreach(route, cpt, _link) {
177 link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
178 xbt_dict_set(ptask_parallel_task_link_set, link->m_name, link, NULL);
184 nb_link = xbt_dict_length(ptask_parallel_task_link_set);
185 xbt_dict_reset(ptask_parallel_task_link_set);
187 for (i = 0; i < workstation_nb; i++)
188 if (computation_amount[i] > 0)
191 action = new WorkstationL07ActionLmm(this, 1, 0);
192 XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
193 action, workstation_nb, nb_link);
194 action->m_suspended = 0; /* Should be useless because of the
195 calloc but it seems to help valgrind... */
196 action->m_workstationNb = workstation_nb;
197 action->p_workstationList = (WorkstationCLM03Ptr *) workstation_list;
198 action->p_computationAmount = computation_amount;
199 action->p_communicationAmount = communication_amount;
200 action->m_latency = latency;
201 action->m_rate = rate;
203 action->p_variable = lmm_variable_new(ptask_maxmin_system, action, 1.0,
204 (action->m_rate > 0) ? action->m_rate : -1.0,
205 workstation_nb + nb_link);
207 if (action->m_latency > 0)
208 lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 0.0);
210 for (i = 0; i < workstation_nb; i++)
211 lmm_expand(ptask_maxmin_system,
212 static_cast<CpuLmmPtr>(dynamic_cast<WorkstationL07Ptr>(
213 static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->p_constraint,
214 action->p_variable, computation_amount[i]);
216 for (i = 0; i < workstation_nb; i++) {
217 for (j = 0; j < workstation_nb; j++) {
221 xbt_dynar_t route=NULL;
222 if (communication_amount[i * workstation_nb + j] == 0.0)
225 routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
226 static_cast<ResourcePtr>(workstation_list[i]))->p_netElm,
227 dynamic_cast<WorkstationL07Ptr>(
228 static_cast<ResourcePtr>(workstation_list[j]))->p_netElm,
231 xbt_dynar_foreach(route, cpt, _link) {
232 link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
233 lmm_expand_add(ptask_maxmin_system, link->p_constraint,
235 communication_amount[i * workstation_nb + j]);
240 if (nb_link + nb_host == 0) {
241 action->m_cost = 1.0;
242 action->m_remains = 0.0;
245 return static_cast<ActionPtr>(action);
248 ResourcePtr WorkstationL07Model::createResource(const char *name, double /*power_scale*/,
249 double /*power_initial*/,
250 tmgr_trace_t /*power_trace*/,
251 e_surf_resource_state_t /*state_initial*/,
252 tmgr_trace_t /*state_trace*/,
253 xbt_dict_t cpu_properties)
255 WorkstationL07Ptr wk = NULL;
256 xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
257 "Host '%s' declared several times in the platform file.",
260 wk = new WorkstationL07(this, name, cpu_properties,
261 static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL)),
262 dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL))));
264 xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(wk));
266 return wk;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
269 ActionPtr WorkstationL07Model::communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst,
270 double size, double rate)
272 void **workstation_list = xbt_new0(void *, 2);
273 double *computation_amount = xbt_new0(double, 2);
274 double *communication_amount = xbt_new0(double, 4);
275 ActionPtr res = NULL;
277 workstation_list[0] = static_cast<ResourcePtr>(src);
278 workstation_list[1] = static_cast<ResourcePtr>(dst);
279 communication_amount[1] = size;
281 res = executeParallelTask(2, workstation_list,
283 communication_amount, rate);
288 xbt_dynar_t WorkstationL07Model::getRoute(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst)
290 xbt_dynar_t route=NULL;
291 routing_platf->getRouteAndLatency(src->p_netElm, dst->p_netElm, &route, NULL);
295 ResourcePtr CpuL07Model::createResource(const char *name, double power_scale,
296 double power_initial,
297 tmgr_trace_t power_trace,
298 e_surf_resource_state_t state_initial,
299 tmgr_trace_t state_trace,
300 xbt_dict_t cpu_properties)
302 CpuL07Ptr cpu = NULL;
303 xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
304 "Host '%s' declared several times in the platform file.",
307 cpu = new CpuL07(this, name, cpu_properties);
309 cpu->p_power.scale = power_scale;
310 xbt_assert(cpu->p_power.scale > 0, "Power has to be >0");
312 cpu->m_powerCurrent = power_initial;
315 tmgr_history_add_trace(history, power_trace, 0.0, 0, static_cast<ResourcePtr>(cpu));
317 cpu->p_stateCurrent = state_initial;
320 tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(cpu));
323 lmm_constraint_new(ptask_maxmin_system, cpu,
324 cpu->m_powerCurrent * cpu->p_power.scale);
326 xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
328 return cpu;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
331 ResourcePtr NetworkL07Model::createResource(const char *name,
333 tmgr_trace_t bw_trace,
335 tmgr_trace_t lat_trace,
336 e_surf_resource_state_t
338 tmgr_trace_t state_trace,
339 e_surf_link_sharing_policy_t
340 policy, xbt_dict_t properties)
342 LinkL07Ptr nw_link = new LinkL07(this, name, properties);
343 xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
344 "Link '%s' declared several times in the platform file.",
347 nw_link->m_bwCurrent = bw_initial;
350 tmgr_history_add_trace(history, bw_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
351 nw_link->p_stateCurrent = state_initial;
352 nw_link->m_latCurrent = lat_initial;
354 nw_link->p_latEvent =
355 tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
357 nw_link->p_stateEvent =
358 tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
360 nw_link->p_constraint =
361 lmm_constraint_new(ptask_maxmin_system, nw_link,
362 nw_link->m_bwCurrent);
364 if (policy == SURF_LINK_FATPIPE)
365 lmm_constraint_shared(nw_link->p_constraint);
367 xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, static_cast<ResourcePtr>(nw_link));
371 void WorkstationL07Model::addTraces()
373 xbt_dict_cursor_t cursor = NULL;
374 char *trace_name, *elm;
376 if (!trace_connect_list_host_avail)
379 /* Connect traces relative to cpu */
380 xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
381 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
382 CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
383 static_cast<ResourcePtr>(
384 surf_cpu_resource_priv(
385 surf_cpu_resource_by_name(elm))));
387 xbt_assert(host, "Host %s undefined", elm);
388 xbt_assert(trace, "Trace %s undefined", trace_name);
390 host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
393 xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
394 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
395 CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
396 static_cast<ResourcePtr>(
397 surf_cpu_resource_priv(
398 surf_cpu_resource_by_name(elm))));
400 xbt_assert(host, "Host %s undefined", elm);
401 xbt_assert(trace, "Trace %s undefined", trace_name);
403 host->p_power.event = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
406 /* Connect traces relative to network */
407 xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
408 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
409 LinkL07Ptr link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
411 xbt_assert(link, "Link %s undefined", elm);
412 xbt_assert(trace, "Trace %s undefined", trace_name);
414 link->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
417 xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
418 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
419 LinkL07Ptr link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
421 xbt_assert(link, "Link %s undefined", elm);
422 xbt_assert(trace, "Trace %s undefined", trace_name);
424 link->p_bwEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
427 xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
428 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
429 LinkL07Ptr link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
431 xbt_assert(link, "Link %s undefined", elm);
432 xbt_assert(trace, "Trace %s undefined", trace_name);
434 link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
442 WorkstationL07::WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
443 : Resource(model, name, props),
444 WorkstationCLM03(model, name, props, NULL, netElm, cpu),
445 WorkstationCLM03Lmm(model, name, props, NULL, netElm, cpu)
449 double WorkstationL07::getPowerPeakAt(int /*pstate_index*/)
451 XBT_DEBUG("[ws_get_power_peak_at] Not implemented for workstation_ptask_L07");
455 int WorkstationL07::getNbPstates()
457 XBT_DEBUG("[ws_get_nb_pstates] Not implemented for workstation_ptask_L07");
461 void WorkstationL07::setPowerPeakAt(int /*pstate_index*/)
463 XBT_DEBUG("[ws_set_power_peak_at] Not implemented for workstation_ptask_L07");
466 double WorkstationL07::getConsumedEnergy()
468 XBT_DEBUG("[ws_get_consumed_energy] Not implemented for workstation_ptask_L07");
472 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props)
473 : Resource(model, name, props), CpuLmm(model, name, props) {
477 LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props)
478 : Resource(model, name, props), NetworkCm02LinkLmm(model, name, props) {
482 bool CpuL07::isUsed(){
483 return lmm_constraint_used(ptask_maxmin_system, p_constraint);
486 bool LinkL07::isUsed(){
487 return lmm_constraint_used(ptask_maxmin_system, p_constraint);
490 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
491 XBT_DEBUG("Updating cpu %s (%p) with value %g", m_name, this, value);
492 if (event_type == p_power.event) {
493 m_powerCurrent = value;
494 lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_powerCurrent * p_power.scale);
495 if (tmgr_trace_event_free(event_type))
496 p_power.event = NULL;
497 } else if (event_type == p_stateEvent) {
499 p_stateCurrent = SURF_RESOURCE_ON;
501 p_stateCurrent = SURF_RESOURCE_OFF;
502 if (tmgr_trace_event_free(event_type))
505 XBT_CRITICAL("Unknown event ! \n");
511 void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
512 XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", m_name, this, value, date);
513 if (event_type == p_bwEvent) {
515 lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_bwCurrent);
516 if (tmgr_trace_event_free(event_type))
518 } else if (event_type == p_latEvent) {
519 lmm_variable_t var = NULL;
520 WorkstationL07ActionLmmPtr action;
521 lmm_element_t elem = NULL;
523 m_latCurrent = value;
524 while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, p_constraint, &elem))) {
525 action = (WorkstationL07ActionLmmPtr) lmm_variable_id(var);
526 action->updateBound();
528 if (tmgr_trace_event_free(event_type))
530 } else if (event_type == p_stateEvent) {
532 p_stateCurrent = SURF_RESOURCE_ON;
534 p_stateCurrent = SURF_RESOURCE_OFF;
535 if (tmgr_trace_event_free(event_type))
538 XBT_CRITICAL("Unknown event ! \n");
544 e_surf_resource_state_t WorkstationL07::getState()
546 return p_cpu->p_stateCurrent;
549 e_surf_resource_state_t CpuL07::getState()
551 return p_stateCurrent;
554 double CpuL07::getSpeed(double load)
556 return load * p_power.scale;
559 double CpuL07::getAvailableSpeed()
561 return m_powerCurrent;
564 ActionPtr WorkstationL07::execute(double size)
566 void **workstation_list = xbt_new0(void *, 1);
567 double *computation_amount = xbt_new0(double, 1);
568 double *communication_amount = xbt_new0(double, 1);
570 workstation_list[0] = static_cast<ResourcePtr>(this);
571 communication_amount[0] = 0.0;
572 computation_amount[0] = size;
574 return static_cast<WorkstationL07ModelPtr>(p_model)->executeParallelTask(1, workstation_list,
576 communication_amount, -1);
579 ActionPtr WorkstationL07::sleep(double duration)
581 WorkstationL07ActionLmmPtr action = NULL;
583 XBT_IN("(%s,%g)", m_name, duration);
585 action = dynamic_cast<WorkstationL07ActionLmmPtr>(execute(1.0));
586 action->m_maxDuration = duration;
587 action->m_suspended = 2;
588 lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 0.0);
594 double LinkL07::getBandwidth()
599 double LinkL07::getLatency()
604 bool LinkL07::isShared()
606 return lmm_constraint_is_shared(p_constraint);
613 WorkstationL07ActionLmm::~WorkstationL07ActionLmm(){
614 free(p_workstationList);
615 free(p_communicationAmount);
616 free(p_computationAmount);
618 xbt_free(p_category);
622 void WorkstationL07ActionLmm::updateBound()
624 double lat_current = 0.0;
625 double lat_bound = -1.0;
628 for (i = 0; i < m_workstationNb; i++) {
629 for (j = 0; j < m_workstationNb; j++) {
630 xbt_dynar_t route=NULL;
632 if (p_communicationAmount[i * m_workstationNb + j] > 0) {
634 routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
635 static_cast<ResourcePtr>(((void**)p_workstationList)[i]))->p_netElm,
636 dynamic_cast<WorkstationL07Ptr>(
637 static_cast<ResourcePtr>(((void**)p_workstationList)[j]))->p_netElm,
640 lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_workstationNb + j]);
644 lat_bound = sg_tcp_gamma / (2.0 * lat_current);
645 XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
646 if ((m_latency == 0.0) && (m_suspended == 0)) {
648 lmm_update_variable_bound(ptask_maxmin_system, p_variable, lat_bound);
650 lmm_update_variable_bound(ptask_maxmin_system, p_variable, min(m_rate, lat_bound));
654 int WorkstationL07ActionLmm::unref()
658 xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
660 lmm_variable_free(ptask_maxmin_system, p_variable);
667 void WorkstationL07ActionLmm::cancel()
669 setState(SURF_ACTION_FAILED);
673 void WorkstationL07ActionLmm::suspend()
675 XBT_IN("(%p))", this);
676 if (m_suspended != 2) {
678 lmm_update_variable_weight(ptask_maxmin_system, p_variable, 0.0);
683 void WorkstationL07ActionLmm::resume()
685 XBT_IN("(%p)", this);
686 if (m_suspended != 2) {
687 lmm_update_variable_weight(ptask_maxmin_system, p_variable, 1.0);
693 bool WorkstationL07ActionLmm::isSuspended()
695 return m_suspended == 1;
698 void WorkstationL07ActionLmm::setMaxDuration(double duration)
699 { /* FIXME: should inherit */
700 XBT_IN("(%p,%g)", this, duration);
701 m_maxDuration = duration;
705 void WorkstationL07ActionLmm::setPriority(double priority)
706 { /* FIXME: should inherit */
707 XBT_IN("(%p,%g)", this, priority);
708 m_priority = priority;
712 double WorkstationL07ActionLmm::getRemains()
714 XBT_IN("(%p)", this);
727 static void ptask_finalize(void)
729 xbt_dict_free(&ptask_parallel_task_link_set);
731 delete surf_workstation_model;
732 surf_workstation_model = NULL;
733 delete surf_network_model;
734 surf_network_model = NULL;
736 ptask_host_count = 0;
738 if (ptask_maxmin_system) {
739 lmm_system_free(ptask_maxmin_system);
740 ptask_maxmin_system = NULL;
744 /**************************************/
745 /******* Resource Private **********/
746 /**************************************/
763 /**************************************/
764 /*** Resource Creation & Destruction **/
765 /**************************************/
767 static void ptask_parse_workstation_init(sg_platf_host_cbarg_t host)
769 double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
770 //cpu->power_peak = power_peak;
771 xbt_dynar_free(&(host->power_peak)); /* kill memory leak */
772 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->createResource(
782 static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host)
784 double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
785 static_cast<CpuL07ModelPtr>(surf_cpu_model_pm)->createResource(
797 static void ptask_parse_link_init(sg_platf_link_cbarg_t link)
799 if (link->policy == SURF_LINK_FULLDUPLEX) {
801 link_id = bprintf("%s_UP", link->id);
802 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
804 link->bandwidth_trace,
812 link_id = bprintf("%s_DOWN", link->id);
813 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
815 link->bandwidth_trace,
821 NULL); /* FIXME: We need to deep copy the
822 * properties or we won't be able to free
826 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link->id,
828 link->bandwidth_trace,
837 current_property_set = NULL;
840 static void ptask_add_traces(){
841 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->addTraces();
844 static void ptask_define_callbacks()
846 sg_platf_host_add_cb(ptask_parse_cpu_init);
847 sg_platf_host_add_cb(ptask_parse_workstation_init);
848 sg_platf_link_add_cb(ptask_parse_link_init);
849 sg_platf_postparse_add_cb(ptask_add_traces);
852 /**************************************/
853 /*************** Generic **************/
854 /**************************************/
855 void surf_workstation_model_init_ptask_L07(void)
857 XBT_INFO("surf_workstation_model_init_ptask_L07");
858 xbt_assert(!surf_cpu_model_pm, "CPU model type already defined");
859 xbt_assert(!surf_network_model, "network model type already defined");
860 ptask_define_callbacks();
861 surf_workstation_model = new WorkstationL07Model();
862 ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
863 xbt_dynar_push(model_list, &model);
864 xbt_dynar_push(model_list_invoke, &model);