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));
30 WorkstationL07Model::~WorkstationL07Model() {
31 xbt_dict_free(&ptask_parallel_task_link_set);
33 delete surf_cpu_model_pm;
34 delete surf_network_model;
37 if (ptask_maxmin_system) {
38 lmm_system_free(ptask_maxmin_system);
39 ptask_maxmin_system = NULL;
43 double WorkstationL07Model::shareResources(double now)
46 WorkstationL07ActionLmmPtr action;
48 xbt_swag_t running_actions = this->p_runningActionSet;
49 double min = this->shareResourcesMaxMin(running_actions,
53 xbt_swag_foreach(_action, running_actions) {
54 action = dynamic_cast<WorkstationL07ActionLmmPtr>(static_cast<ActionPtr>(_action));
55 if (action->m_latency > 0) {
57 min = action->m_latency;
58 XBT_DEBUG("Updating min (value) with %p (start %f): %f", action,
59 action->m_start, min);
60 } else if (action->m_latency < min) {
61 min = action->m_latency;
62 XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action,
63 action->m_start, min);
68 XBT_DEBUG("min value : %f", min);
73 void WorkstationL07Model::updateActionsState(double now, double delta)
76 void *_action, *_next_action;
77 WorkstationL07ActionLmmPtr action;
79 xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
80 action = dynamic_cast<WorkstationL07ActionLmmPtr>(static_cast<ActionPtr>(_action));
83 if (action->m_latency > 0) {
84 if (action->m_latency > deltap) {
85 double_update(&(action->m_latency), deltap);
88 double_update(&(deltap), action->m_latency);
89 action->m_latency = 0.0;
91 if ((action->m_latency == 0.0) && (action->m_suspended == 0)) {
92 action->updateBound();
93 lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 1.0);
96 XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
97 action, action->m_remains, lmm_variable_getvalue(action->p_variable) * delta);
98 double_update(&(action->m_remains), lmm_variable_getvalue(action->p_variable) * delta);
100 if (action->m_maxDuration != NO_MAX_DURATION)
101 double_update(&(action->m_maxDuration), delta);
103 XBT_DEBUG("Action (%p) : remains (%g).",
104 action, action->m_remains);
105 if ((action->m_remains <= 0) &&
106 (lmm_get_variable_weight(action->p_variable) > 0)) {
107 action->m_finish = surf_get_clock();
108 action->setState(SURF_ACTION_DONE);
109 } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
110 (action->m_maxDuration <= 0)) {
111 action->m_finish = surf_get_clock();
112 action->setState(SURF_ACTION_DONE);
114 /* Need to check that none of the model has failed */
115 lmm_constraint_t cnst = NULL;
117 void *constraint_id = NULL;
119 while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->p_variable,
121 constraint_id = lmm_constraint_id(cnst);
123 if (static_cast<WorkstationCLM03LmmPtr>(constraint_id)->p_stateCurrent == SURF_RESOURCE_OFF) {
124 XBT_DEBUG("Action (%p) Failed!!", action);
125 action->m_finish = surf_get_clock();
126 action->setState(SURF_ACTION_FAILED);
135 ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
136 void **workstation_list,
138 *computation_amount, double
139 *communication_amount,
142 WorkstationL07ActionLmmPtr action;
147 double latency = 0.0;
149 if (ptask_parallel_task_link_set == NULL)
150 ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
152 xbt_dict_reset(ptask_parallel_task_link_set);
154 /* Compute the number of affected resources... */
155 for (i = 0; i < workstation_nb; i++) {
156 for (j = 0; j < workstation_nb; j++) {
157 xbt_dynar_t route=NULL;
159 if (communication_amount[i * workstation_nb + j] > 0) {
165 routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
166 static_cast<ResourcePtr>(
167 workstation_list[i]))->p_netElm,
168 dynamic_cast<WorkstationL07Ptr>(
169 static_cast<ResourcePtr>(
170 workstation_list[j]))->p_netElm,
173 latency = MAX(latency, lat);
175 xbt_dynar_foreach(route, cpt, _link) {
176 link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
177 xbt_dict_set(ptask_parallel_task_link_set, link->m_name, link, NULL);
183 nb_link = xbt_dict_length(ptask_parallel_task_link_set);
184 xbt_dict_reset(ptask_parallel_task_link_set);
186 for (i = 0; i < workstation_nb; i++)
187 if (computation_amount[i] > 0)
190 action = new WorkstationL07ActionLmm(this, 1, 0);
191 XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
192 action, workstation_nb, nb_link);
193 action->m_suspended = 0; /* Should be useless because of the
194 calloc but it seems to help valgrind... */
195 action->m_workstationNb = workstation_nb;
196 action->p_workstationList = (WorkstationCLM03Ptr *) workstation_list;
197 action->p_computationAmount = computation_amount;
198 action->p_communicationAmount = communication_amount;
199 action->m_latency = latency;
200 action->m_rate = rate;
202 action->p_variable = lmm_variable_new(ptask_maxmin_system, action, 1.0,
203 (action->m_rate > 0) ? action->m_rate : -1.0,
204 workstation_nb + nb_link);
206 if (action->m_latency > 0)
207 lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 0.0);
209 for (i = 0; i < workstation_nb; i++)
210 lmm_expand(ptask_maxmin_system,
211 static_cast<CpuLmmPtr>(dynamic_cast<WorkstationL07Ptr>(
212 static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->p_constraint,
213 action->p_variable, computation_amount[i]);
215 for (i = 0; i < workstation_nb; i++) {
216 for (j = 0; j < workstation_nb; j++) {
220 xbt_dynar_t route=NULL;
221 if (communication_amount[i * workstation_nb + j] == 0.0)
224 routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
225 static_cast<ResourcePtr>(workstation_list[i]))->p_netElm,
226 dynamic_cast<WorkstationL07Ptr>(
227 static_cast<ResourcePtr>(workstation_list[j]))->p_netElm,
230 xbt_dynar_foreach(route, cpt, _link) {
231 link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
232 lmm_expand_add(ptask_maxmin_system, link->p_constraint,
234 communication_amount[i * workstation_nb + j]);
239 if (nb_link + nb_host == 0) {
240 action->m_cost = 1.0;
241 action->m_remains = 0.0;
244 return static_cast<ActionPtr>(action);
247 ResourcePtr WorkstationL07Model::createResource(const char *name, double power_scale,
248 double power_initial,
249 tmgr_trace_t power_trace,
250 e_surf_resource_state_t state_initial,
251 tmgr_trace_t state_trace,
252 xbt_dict_t cpu_properties)
254 WorkstationL07Ptr wk = NULL;
255 xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
256 "Host '%s' declared several times in the platform file.",
259 wk = new WorkstationL07(this, name, cpu_properties,
260 static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL)),
261 dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL))));
263 xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(wk));
265 return wk;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
268 ActionPtr WorkstationL07Model::communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst,
269 double size, double rate)
271 void **workstation_list = xbt_new0(void *, 2);
272 double *computation_amount = xbt_new0(double, 2);
273 double *communication_amount = xbt_new0(double, 4);
274 ActionPtr res = NULL;
276 workstation_list[0] = static_cast<ResourcePtr>(src);
277 workstation_list[1] = static_cast<ResourcePtr>(dst);
278 communication_amount[1] = size;
280 res = executeParallelTask(2, workstation_list,
282 communication_amount, rate);
287 xbt_dynar_t WorkstationL07Model::getRoute(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst)
289 xbt_dynar_t route=NULL;
290 routing_platf->getRouteAndLatency(src->p_netElm, dst->p_netElm, &route, NULL);
294 ResourcePtr CpuL07Model::createResource(const char *name, double power_scale,
295 double power_initial,
296 tmgr_trace_t power_trace,
297 e_surf_resource_state_t state_initial,
298 tmgr_trace_t state_trace,
299 xbt_dict_t cpu_properties)
301 CpuL07Ptr cpu = NULL;
302 xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
303 "Host '%s' declared several times in the platform file.",
306 cpu = new CpuL07(this, name, cpu_properties);
308 cpu->p_power.scale = power_scale;
309 xbt_assert(cpu->p_power.scale > 0, "Power has to be >0");
311 cpu->m_powerCurrent = power_initial;
314 tmgr_history_add_trace(history, power_trace, 0.0, 0, static_cast<ResourcePtr>(cpu));
316 cpu->p_stateCurrent = state_initial;
319 tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(cpu));
322 lmm_constraint_new(ptask_maxmin_system, cpu,
323 cpu->m_powerCurrent * cpu->p_power.scale);
325 xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
327 return cpu;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
330 ResourcePtr NetworkL07Model::createResource(const char *name,
332 tmgr_trace_t bw_trace,
334 tmgr_trace_t lat_trace,
335 e_surf_resource_state_t
337 tmgr_trace_t state_trace,
338 e_surf_link_sharing_policy_t
339 policy, xbt_dict_t properties)
341 LinkL07Ptr nw_link = new LinkL07(this, xbt_strdup(name), properties);
342 xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
343 "Link '%s' declared several times in the platform file.",
346 nw_link->m_bwCurrent = bw_initial;
349 tmgr_history_add_trace(history, bw_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
350 nw_link->p_stateCurrent = state_initial;
351 nw_link->m_latCurrent = lat_initial;
353 nw_link->p_latEvent =
354 tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
356 nw_link->p_stateEvent =
357 tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
359 nw_link->p_constraint =
360 lmm_constraint_new(ptask_maxmin_system, nw_link,
361 nw_link->m_bwCurrent);
363 if (policy == SURF_LINK_FATPIPE)
364 lmm_constraint_shared(nw_link->p_constraint);
366 xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, static_cast<ResourcePtr>(nw_link));
370 void WorkstationL07Model::addTraces()
372 xbt_dict_cursor_t cursor = NULL;
373 char *trace_name, *elm;
375 if (!trace_connect_list_host_avail)
378 /* Connect traces relative to cpu */
379 xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
380 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
381 CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
382 static_cast<ResourcePtr>(
383 surf_cpu_resource_priv(
384 surf_cpu_resource_by_name(elm))));
386 xbt_assert(host, "Host %s undefined", elm);
387 xbt_assert(trace, "Trace %s undefined", trace_name);
389 host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
392 xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
393 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
394 CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
395 static_cast<ResourcePtr>(
396 surf_cpu_resource_priv(
397 surf_cpu_resource_by_name(elm))));
399 xbt_assert(host, "Host %s undefined", elm);
400 xbt_assert(trace, "Trace %s undefined", trace_name);
402 host->p_power.event = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
405 /* Connect traces relative to network */
406 xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
407 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
408 LinkL07Ptr link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
410 xbt_assert(link, "Link %s undefined", elm);
411 xbt_assert(trace, "Trace %s undefined", trace_name);
413 link->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
416 xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
417 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
418 LinkL07Ptr link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
420 xbt_assert(link, "Link %s undefined", elm);
421 xbt_assert(trace, "Trace %s undefined", trace_name);
423 link->p_bwEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
426 xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
427 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
428 LinkL07Ptr link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
430 xbt_assert(link, "Link %s undefined", elm);
431 xbt_assert(trace, "Trace %s undefined", trace_name);
433 link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
441 WorkstationL07::WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
442 : Resource(model, name, props),
443 WorkstationCLM03Lmm(model, name, props, NULL, netElm, cpu),
444 WorkstationCLM03(model, name, props, NULL, netElm, cpu)
448 double WorkstationL07::getPowerPeakAt(int pstate_index)
450 XBT_DEBUG("[ws_get_power_peak_at] Not implemented for workstation_ptask_L07");
454 int WorkstationL07::getNbPstates()
456 XBT_DEBUG("[ws_get_nb_pstates] Not implemented for workstation_ptask_L07");
460 void WorkstationL07::setPowerPeakAt(int pstate_index)
462 XBT_DEBUG("[ws_set_power_peak_at] Not implemented for workstation_ptask_L07");
465 double WorkstationL07::getConsumedEnergy()
467 XBT_DEBUG("[ws_get_consumed_energy] Not implemented for workstation_ptask_L07");
471 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props)
472 : Resource(model, name, props), CpuLmm(model, name, props) {
476 LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props)
477 : Resource(model, name, props), NetworkCm02LinkLmm(model, name, props) {
481 bool CpuL07::isUsed(){
482 return lmm_constraint_used(ptask_maxmin_system, p_constraint);
485 bool LinkL07::isUsed(){
486 return lmm_constraint_used(ptask_maxmin_system, p_constraint);
489 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double date){
490 XBT_DEBUG("Updating cpu %s (%p) with value %g", m_name, this, value);
491 if (event_type == p_power.event) {
492 m_powerCurrent = value;
493 lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_powerCurrent * p_power.scale);
494 if (tmgr_trace_event_free(event_type))
495 p_power.event = NULL;
496 } else if (event_type == p_stateEvent) {
498 p_stateCurrent = SURF_RESOURCE_ON;
500 p_stateCurrent = SURF_RESOURCE_OFF;
501 if (tmgr_trace_event_free(event_type))
504 XBT_CRITICAL("Unknown event ! \n");
510 void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
511 XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", m_name, this, value, date);
512 if (event_type == p_bwEvent) {
514 lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_bwCurrent);
515 if (tmgr_trace_event_free(event_type))
517 } else if (event_type == p_latEvent) {
518 lmm_variable_t var = NULL;
519 WorkstationL07ActionLmmPtr action;
520 lmm_element_t elem = NULL;
522 m_latCurrent = value;
523 while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, p_constraint, &elem))) {
524 action = (WorkstationL07ActionLmmPtr) lmm_variable_id(var);
525 action->updateBound();
527 if (tmgr_trace_event_free(event_type))
529 } else if (event_type == p_stateEvent) {
531 p_stateCurrent = SURF_RESOURCE_ON;
533 p_stateCurrent = SURF_RESOURCE_OFF;
534 if (tmgr_trace_event_free(event_type))
537 XBT_CRITICAL("Unknown event ! \n");
543 e_surf_resource_state_t WorkstationL07::getState()
545 return p_cpu->p_stateCurrent;
548 e_surf_resource_state_t CpuL07::getState()
550 return p_stateCurrent;
553 double CpuL07::getSpeed(double load)
555 return load * p_power.scale;
558 double CpuL07::getAvailableSpeed()
560 return m_powerCurrent;
563 ActionPtr WorkstationL07::execute(double size)
565 void **workstation_list = xbt_new0(void *, 1);
566 double *computation_amount = xbt_new0(double, 1);
567 double *communication_amount = xbt_new0(double, 1);
569 workstation_list[0] = static_cast<ResourcePtr>(this);
570 communication_amount[0] = 0.0;
571 computation_amount[0] = size;
573 return static_cast<WorkstationL07ModelPtr>(p_model)->executeParallelTask(1, workstation_list,
575 communication_amount, -1);
578 ActionPtr WorkstationL07::sleep(double duration)
580 WorkstationL07ActionLmmPtr action = NULL;
582 XBT_IN("(%s,%g)", m_name, duration);
584 action = dynamic_cast<WorkstationL07ActionLmmPtr>(execute(1.0));
585 action->m_maxDuration = duration;
586 action->m_suspended = 2;
587 lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 0.0);
593 double LinkL07::getBandwidth()
598 double LinkL07::getLatency()
603 bool LinkL07::isShared()
605 return lmm_constraint_is_shared(p_constraint);
612 WorkstationL07ActionLmm::~WorkstationL07ActionLmm(){
613 free(p_workstationList);
614 free(p_communicationAmount);
615 free(p_computationAmount);
617 xbt_free(p_category);
621 void WorkstationL07ActionLmm::updateBound()
623 double lat_current = 0.0;
624 double lat_bound = -1.0;
627 for (i = 0; i < m_workstationNb; i++) {
628 for (j = 0; j < m_workstationNb; j++) {
629 xbt_dynar_t route=NULL;
631 if (p_communicationAmount[i * m_workstationNb + j] > 0) {
633 routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
634 static_cast<ResourcePtr>(((void**)p_workstationList)[i]))->p_netElm,
635 dynamic_cast<WorkstationL07Ptr>(
636 static_cast<ResourcePtr>(((void**)p_workstationList)[j]))->p_netElm,
639 lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_workstationNb + j]);
643 lat_bound = sg_tcp_gamma / (2.0 * lat_current);
644 XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
645 if ((m_latency == 0.0) && (m_suspended == 0)) {
647 lmm_update_variable_bound(ptask_maxmin_system, p_variable, lat_bound);
649 lmm_update_variable_bound(ptask_maxmin_system, p_variable, min(m_rate, lat_bound));
653 int WorkstationL07ActionLmm::unref()
657 xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
659 lmm_variable_free(ptask_maxmin_system, p_variable);
666 void WorkstationL07ActionLmm::cancel()
668 setState(SURF_ACTION_FAILED);
672 void WorkstationL07ActionLmm::suspend()
674 XBT_IN("(%p))", this);
675 if (m_suspended != 2) {
677 lmm_update_variable_weight(ptask_maxmin_system, p_variable, 0.0);
682 void WorkstationL07ActionLmm::resume()
684 XBT_IN("(%p)", this);
685 if (m_suspended != 2) {
686 lmm_update_variable_weight(ptask_maxmin_system, p_variable, 1.0);
692 bool WorkstationL07ActionLmm::isSuspended()
694 return m_suspended == 1;
697 void WorkstationL07ActionLmm::setMaxDuration(double duration)
698 { /* FIXME: should inherit */
699 XBT_IN("(%p,%g)", this, duration);
700 m_maxDuration = duration;
704 void WorkstationL07ActionLmm::setPriority(double priority)
705 { /* FIXME: should inherit */
706 XBT_IN("(%p,%g)", this, priority);
707 m_priority = priority;
711 double WorkstationL07ActionLmm::getRemains()
713 XBT_IN("(%p)", this);
726 static void ptask_finalize(void)
728 xbt_dict_free(&ptask_parallel_task_link_set);
730 delete surf_workstation_model;
731 surf_workstation_model = NULL;
732 delete surf_network_model;
733 surf_network_model = NULL;
735 ptask_host_count = 0;
737 if (ptask_maxmin_system) {
738 lmm_system_free(ptask_maxmin_system);
739 ptask_maxmin_system = NULL;
743 /**************************************/
744 /******* Resource Private **********/
745 /**************************************/
762 /**************************************/
763 /*** Resource Creation & Destruction **/
764 /**************************************/
766 static void ptask_parse_workstation_init(sg_platf_host_cbarg_t host)
768 double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
769 //cpu->power_peak = power_peak;
770 xbt_dynar_free(&(host->power_peak)); /* kill memory leak */
771 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->createResource(
781 static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host)
783 double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
784 static_cast<CpuL07ModelPtr>(surf_cpu_model_pm)->createResource(
796 static void ptask_parse_link_init(sg_platf_link_cbarg_t link)
798 if (link->policy == SURF_LINK_FULLDUPLEX) {
800 link_id = bprintf("%s_UP", link->id);
801 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
803 link->bandwidth_trace,
811 link_id = bprintf("%s_DOWN", link->id);
812 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
814 link->bandwidth_trace,
820 NULL); /* FIXME: We need to deep copy the
821 * properties or we won't be able to free
825 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link->id,
827 link->bandwidth_trace,
836 current_property_set = NULL;
839 static void ptask_add_traces(){
840 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->addTraces();
843 static void ptask_define_callbacks()
845 sg_platf_host_add_cb(ptask_parse_cpu_init);
846 sg_platf_host_add_cb(ptask_parse_workstation_init);
847 sg_platf_link_add_cb(ptask_parse_link_init);
848 sg_platf_postparse_add_cb(ptask_add_traces);
851 /**************************************/
852 /*************** Generic **************/
853 /**************************************/
854 void surf_workstation_model_init_ptask_L07(void)
856 XBT_INFO("surf_workstation_model_init_ptask_L07");
857 xbt_assert(!surf_cpu_model_pm, "CPU model type already defined");
858 xbt_assert(!surf_network_model, "network model type already defined");
859 ptask_define_callbacks();
860 surf_workstation_model = new WorkstationL07Model();
861 ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
862 xbt_dynar_push(model_list, &model);