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 = 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;
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), WorkstationCLM03Lmm(model, name, props, NULL, netElm, cpu)
446 double WorkstationL07::getPowerPeakAt(int pstate_index)
448 XBT_DEBUG("[ws_get_power_peak_at] Not implemented for workstation_ptask_L07");
452 int WorkstationL07::getNbPstates()
454 XBT_DEBUG("[ws_get_nb_pstates] Not implemented for workstation_ptask_L07");
458 void WorkstationL07::setPowerPeakAt(int pstate_index)
460 XBT_DEBUG("[ws_set_power_peak_at] Not implemented for workstation_ptask_L07");
463 double WorkstationL07::getConsumedEnergy()
465 XBT_DEBUG("[ws_get_consumed_energy] Not implemented for workstation_ptask_L07");
469 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props)
470 : Resource(model, name, props), CpuLmm(model, name, props) {
474 LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props)
475 : Resource(model, name, props), NetworkCm02LinkLmm(model, name, props) {
479 bool CpuL07::isUsed(){
480 return lmm_constraint_used(ptask_maxmin_system, p_constraint);
483 bool LinkL07::isUsed(){
484 return lmm_constraint_used(ptask_maxmin_system, p_constraint);
487 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double date){
488 XBT_DEBUG("Updating cpu %s (%p) with value %g", m_name, this, value);
489 if (event_type == p_power.event) {
490 m_powerCurrent = value;
491 lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_powerCurrent * p_power.scale);
492 if (tmgr_trace_event_free(event_type))
493 p_power.event = NULL;
494 } else if (event_type == p_stateEvent) {
496 p_stateCurrent = SURF_RESOURCE_ON;
498 p_stateCurrent = SURF_RESOURCE_OFF;
499 if (tmgr_trace_event_free(event_type))
502 XBT_CRITICAL("Unknown event ! \n");
508 void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
509 XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", m_name, this, value, date);
510 if (event_type == p_bwEvent) {
512 lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_bwCurrent);
513 if (tmgr_trace_event_free(event_type))
515 } else if (event_type == p_latEvent) {
516 lmm_variable_t var = NULL;
517 WorkstationL07ActionLmmPtr action;
518 lmm_element_t elem = NULL;
520 m_latCurrent = value;
521 while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, p_constraint, &elem))) {
522 action = (WorkstationL07ActionLmmPtr) lmm_variable_id(var);
523 action->updateBound();
525 if (tmgr_trace_event_free(event_type))
527 } else if (event_type == p_stateEvent) {
529 p_stateCurrent = SURF_RESOURCE_ON;
531 p_stateCurrent = SURF_RESOURCE_OFF;
532 if (tmgr_trace_event_free(event_type))
535 XBT_CRITICAL("Unknown event ! \n");
541 e_surf_resource_state_t WorkstationL07::getState()
543 return p_cpu->p_stateCurrent;
546 e_surf_resource_state_t CpuL07::getState()
548 return p_stateCurrent;
551 double CpuL07::getSpeed(double load)
553 return load * p_power.scale;
556 double CpuL07::getAvailableSpeed()
558 return m_powerCurrent;
561 ActionPtr WorkstationL07::execute(double size)
563 void **workstation_list = xbt_new0(void *, 1);
564 double *computation_amount = xbt_new0(double, 1);
565 double *communication_amount = xbt_new0(double, 1);
567 workstation_list[0] = static_cast<ResourcePtr>(this);
568 communication_amount[0] = 0.0;
569 computation_amount[0] = size;
571 return static_cast<WorkstationL07ModelPtr>(p_model)->executeParallelTask(1, workstation_list,
573 communication_amount, -1);
576 ActionPtr WorkstationL07::sleep(double duration)
578 WorkstationL07ActionLmmPtr action = NULL;
580 XBT_IN("(%s,%g)", m_name, duration);
582 action = dynamic_cast<WorkstationL07ActionLmmPtr>(execute(1.0));
583 action->m_maxDuration = duration;
584 action->m_suspended = 2;
585 lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 0.0);
591 double LinkL07::getBandwidth()
596 double LinkL07::getLatency()
601 bool LinkL07::isShared()
603 return lmm_constraint_is_shared(p_constraint);
610 WorkstationL07ActionLmm::~WorkstationL07ActionLmm(){
611 free(p_workstationList);
612 free(p_communicationAmount);
613 free(p_computationAmount);
615 xbt_free(p_category);
619 void WorkstationL07ActionLmm::updateBound()
621 double lat_current = 0.0;
622 double lat_bound = -1.0;
625 for (i = 0; i < m_workstationNb; i++) {
626 for (j = 0; j < m_workstationNb; j++) {
627 xbt_dynar_t route=NULL;
629 if (p_communicationAmount[i * m_workstationNb + j] > 0) {
631 routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
632 static_cast<ResourcePtr>(((void**)p_workstationList)[i]))->p_netElm,
633 dynamic_cast<WorkstationL07Ptr>(
634 static_cast<ResourcePtr>(((void**)p_workstationList)[j]))->p_netElm,
637 lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_workstationNb + j]);
641 lat_bound = sg_tcp_gamma / (2.0 * lat_current);
642 XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
643 if ((m_latency == 0.0) && (m_suspended == 0)) {
645 lmm_update_variable_bound(ptask_maxmin_system, p_variable, lat_bound);
647 lmm_update_variable_bound(ptask_maxmin_system, p_variable, min(m_rate, lat_bound));
651 int WorkstationL07ActionLmm::unref()
655 xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
657 lmm_variable_free(ptask_maxmin_system, p_variable);
664 void WorkstationL07ActionLmm::cancel()
666 setState(SURF_ACTION_FAILED);
670 void WorkstationL07ActionLmm::suspend()
672 XBT_IN("(%p))", this);
673 if (m_suspended != 2) {
675 lmm_update_variable_weight(ptask_maxmin_system, p_variable, 0.0);
680 void WorkstationL07ActionLmm::resume()
682 XBT_IN("(%p)", this);
683 if (m_suspended != 2) {
684 lmm_update_variable_weight(ptask_maxmin_system, p_variable, 1.0);
690 bool WorkstationL07ActionLmm::isSuspended()
692 return m_suspended == 1;
695 void WorkstationL07ActionLmm::setMaxDuration(double duration)
696 { /* FIXME: should inherit */
697 XBT_IN("(%p,%g)", this, duration);
698 m_maxDuration = duration;
702 void WorkstationL07ActionLmm::setPriority(double priority)
703 { /* FIXME: should inherit */
704 XBT_IN("(%p,%g)", this, priority);
705 m_priority = priority;
709 double WorkstationL07ActionLmm::getRemains()
711 XBT_IN("(%p)", this);
724 static void ptask_finalize(void)
726 xbt_dict_free(&ptask_parallel_task_link_set);
728 delete surf_workstation_model;
729 surf_workstation_model = NULL;
730 delete surf_network_model;
731 surf_network_model = NULL;
733 ptask_host_count = 0;
735 if (ptask_maxmin_system) {
736 lmm_system_free(ptask_maxmin_system);
737 ptask_maxmin_system = NULL;
741 /**************************************/
742 /******* Resource Private **********/
743 /**************************************/
760 /**************************************/
761 /*** Resource Creation & Destruction **/
762 /**************************************/
764 static void ptask_parse_workstation_init(sg_platf_host_cbarg_t host)
766 double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
767 //cpu->power_peak = power_peak;
768 xbt_dynar_free(&(host->power_peak)); /* kill memory leak */
769 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->createResource(
779 static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host)
781 double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
782 static_cast<CpuL07ModelPtr>(surf_cpu_model)->createResource(
794 static void ptask_parse_link_init(sg_platf_link_cbarg_t link)
796 if (link->policy == SURF_LINK_FULLDUPLEX) {
798 link_id = bprintf("%s_UP", link->id);
799 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
801 link->bandwidth_trace,
809 link_id = bprintf("%s_DOWN", link->id);
810 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
812 link->bandwidth_trace,
818 NULL); /* FIXME: We need to deep copy the
819 * properties or we won't be able to free
823 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link->id,
825 link->bandwidth_trace,
834 current_property_set = NULL;
837 static void ptask_add_traces(){
838 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->addTraces();
841 static void ptask_define_callbacks()
843 sg_platf_host_add_cb(ptask_parse_cpu_init);
844 sg_platf_host_add_cb(ptask_parse_workstation_init);
845 sg_platf_link_add_cb(ptask_parse_link_init);
846 sg_platf_postparse_add_cb(ptask_add_traces);
849 /**************************************/
850 /*************** Generic **************/
851 /**************************************/
852 void surf_workstation_model_init_ptask_L07(void)
854 XBT_INFO("surf_workstation_model_init_ptask_L07");
855 xbt_assert(!surf_cpu_model, "CPU model type already defined");
856 xbt_assert(!surf_network_model, "network model type already defined");
857 ptask_define_callbacks();
858 surf_workstation_model = new WorkstationL07Model();
859 ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
860 xbt_dynar_push(model_list, &model);