1 /* Copyright (c) 2007-2010, 2013. 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*/)
47 WorkstationL07ActionLmmPtr action;
49 xbt_swag_t running_actions = getRunningActionSet();
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->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 void *_action, *_next_action;
78 WorkstationL07ActionLmmPtr action;
80 xbt_swag_t actionSet = getRunningActionSet();
81 xbt_swag_foreach_safe(_action, _next_action, actionSet) {
82 action = dynamic_cast<WorkstationL07ActionLmmPtr>(static_cast<ActionPtr>(_action));
85 if (action->m_latency > 0) {
86 if (action->m_latency > deltap) {
87 double_update(&(action->m_latency), deltap);
90 double_update(&(deltap), action->m_latency);
91 action->m_latency = 0.0;
93 if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) {
94 action->updateBound();
95 lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 1.0);
98 XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
99 action, action->getRemains(), lmm_variable_getvalue(action->getVariable()) * delta);
100 action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
102 if (action->getMaxDuration() != NO_MAX_DURATION)
103 action->updateMaxDuration(delta);
105 XBT_DEBUG("Action (%p) : remains (%g).",
106 action, action->getRemains());
107 if ((action->getRemains() <= 0) &&
108 (lmm_get_variable_weight(action->getVariable()) > 0)) {
110 action->setState(SURF_ACTION_DONE);
111 } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
112 (action->getMaxDuration() <= 0)) {
114 action->setState(SURF_ACTION_DONE);
116 /* Need to check that none of the model has failed */
117 lmm_constraint_t cnst = NULL;
119 void *constraint_id = NULL;
121 while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(),
123 constraint_id = lmm_constraint_id(cnst);
125 if (static_cast<WorkstationLmmPtr>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
126 XBT_DEBUG("Action (%p) Failed!!", action);
128 action->setState(SURF_ACTION_FAILED);
137 ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
138 void **workstation_list,
140 *computation_amount, double
141 *communication_amount,
144 WorkstationL07ActionLmmPtr action;
149 double latency = 0.0;
151 if (ptask_parallel_task_link_set == NULL)
152 ptask_parallel_task_link_set = xbt_dict_new_homogeneous(NULL);
154 xbt_dict_reset(ptask_parallel_task_link_set);
156 /* Compute the number of affected resources... */
157 for (i = 0; i < workstation_nb; i++) {
158 for (j = 0; j < workstation_nb; j++) {
159 xbt_dynar_t route=NULL;
161 if (communication_amount[i * workstation_nb + j] > 0) {
167 routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
168 static_cast<ResourcePtr>(
169 workstation_list[i]))->p_netElm,
170 dynamic_cast<WorkstationL07Ptr>(
171 static_cast<ResourcePtr>(
172 workstation_list[j]))->p_netElm,
175 latency = MAX(latency, lat);
177 xbt_dynar_foreach(route, cpt, _link) {
178 link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
179 xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL);
185 nb_link = xbt_dict_length(ptask_parallel_task_link_set);
186 xbt_dict_reset(ptask_parallel_task_link_set);
188 for (i = 0; i < workstation_nb; i++)
189 if (computation_amount[i] > 0)
192 action = new WorkstationL07ActionLmm(this, 1, 0);
193 XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
194 action, workstation_nb, nb_link);
195 action->m_suspended = 0; /* Should be useless because of the
196 calloc but it seems to help valgrind... */
197 action->m_workstationNb = workstation_nb;
198 action->p_workstationList = (WorkstationPtr *) workstation_list;
199 action->p_computationAmount = computation_amount;
200 action->p_communicationAmount = communication_amount;
201 action->m_latency = latency;
202 action->m_rate = rate;
204 action->p_variable = lmm_variable_new(ptask_maxmin_system, action, 1.0,
205 (action->m_rate > 0) ? action->m_rate : -1.0,
206 workstation_nb + nb_link);
208 if (action->m_latency > 0)
209 lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
211 for (i = 0; i < workstation_nb; i++)
212 lmm_expand(ptask_maxmin_system,
213 static_cast<CpuLmmPtr>(dynamic_cast<WorkstationL07Ptr>(
214 static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->constraint(),
215 action->getVariable(), computation_amount[i]);
217 for (i = 0; i < workstation_nb; i++) {
218 for (j = 0; j < workstation_nb; j++) {
222 xbt_dynar_t route=NULL;
223 if (communication_amount[i * workstation_nb + j] == 0.0)
226 routing_platf->getRouteAndLatency(dynamic_cast<WorkstationL07Ptr>(
227 static_cast<ResourcePtr>(workstation_list[i]))->p_netElm,
228 dynamic_cast<WorkstationL07Ptr>(
229 static_cast<ResourcePtr>(workstation_list[j]))->p_netElm,
232 xbt_dynar_foreach(route, cpt, _link) {
233 link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
234 lmm_expand_add(ptask_maxmin_system, link->constraint(),
235 action->getVariable(),
236 communication_amount[i * workstation_nb + j]);
241 if (nb_link + nb_host == 0) {
242 action->setCost(1.0);
243 action->setRemains(0.0);
246 return static_cast<ActionPtr>(action);
249 ResourcePtr WorkstationL07Model::createResource(const char *name, double /*power_scale*/,
250 double /*power_initial*/,
251 tmgr_trace_t /*power_trace*/,
252 e_surf_resource_state_t /*state_initial*/,
253 tmgr_trace_t /*state_trace*/,
254 xbt_dict_t /*cpu_properties*/)
256 WorkstationL07Ptr wk = NULL;
257 xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
258 "Host '%s' declared several times in the platform file.",
261 wk = new WorkstationL07(this, name, NULL,
262 static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL)),
263 dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL))));
265 xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(wk));
267 return wk;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
270 ActionPtr WorkstationL07Model::communicate(WorkstationPtr src, WorkstationPtr dst,
271 double size, double rate)
273 void **workstation_list = xbt_new0(void *, 2);
274 double *computation_amount = xbt_new0(double, 2);
275 double *communication_amount = xbt_new0(double, 4);
276 ActionPtr res = NULL;
278 workstation_list[0] = static_cast<ResourcePtr>(src);
279 workstation_list[1] = static_cast<ResourcePtr>(dst);
280 communication_amount[1] = size;
282 res = executeParallelTask(2, workstation_list,
284 communication_amount, rate);
289 xbt_dynar_t WorkstationL07Model::getRoute(WorkstationPtr src, WorkstationPtr dst)
291 xbt_dynar_t route=NULL;
292 routing_platf->getRouteAndLatency(src->p_netElm, dst->p_netElm, &route, NULL);
296 ResourcePtr CpuL07Model::createResource(const char *name, double power_scale,
297 double power_initial,
298 tmgr_trace_t power_trace,
299 e_surf_resource_state_t state_initial,
300 tmgr_trace_t state_trace,
301 xbt_dict_t cpu_properties)
303 xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
304 "Host '%s' declared several times in the platform file.",
307 CpuL07Ptr cpu = new CpuL07(this, name, cpu_properties,
308 power_scale, power_initial, power_trace,state_initial, state_trace);
310 xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
312 return cpu;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
315 NetworkLinkPtr NetworkL07Model::createResource(const char *name,
317 tmgr_trace_t bw_trace,
319 tmgr_trace_t lat_trace,
320 e_surf_resource_state_t
322 tmgr_trace_t state_trace,
323 e_surf_link_sharing_policy_t policy,
324 xbt_dict_t properties)
326 xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
327 "Link '%s' declared several times in the platform file.",
330 LinkL07Ptr nw_link = new LinkL07(this, name, properties,
331 bw_initial, bw_trace,
332 lat_initial, lat_trace,
333 state_initial, state_trace,
336 xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, static_cast<ResourcePtr>(nw_link));
340 void WorkstationL07Model::addTraces()
342 xbt_dict_cursor_t cursor = NULL;
343 char *trace_name, *elm;
345 if (!trace_connect_list_host_avail)
348 /* Connect traces relative to cpu */
349 xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
350 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
351 CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
352 static_cast<ResourcePtr>(
353 surf_cpu_resource_priv(
354 surf_cpu_resource_by_name(elm))));
356 xbt_assert(host, "Host %s undefined", elm);
357 xbt_assert(trace, "Trace %s undefined", trace_name);
359 host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
362 xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
363 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
364 CpuL07Ptr host = dynamic_cast<CpuL07Ptr>(
365 static_cast<ResourcePtr>(
366 surf_cpu_resource_priv(
367 surf_cpu_resource_by_name(elm))));
369 xbt_assert(host, "Host %s undefined", elm);
370 xbt_assert(trace, "Trace %s undefined", trace_name);
372 host->p_power.event = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
375 /* Connect traces relative to network */
376 xbt_dict_foreach(trace_connect_list_link_avail, 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 = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(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_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
386 xbt_dict_foreach(trace_connect_list_bandwidth, 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 = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(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_bwEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
396 xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
397 tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
398 LinkL07Ptr link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
400 xbt_assert(link, "Link %s undefined", elm);
401 xbt_assert(trace, "Trace %s undefined", trace_name);
403 link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(link));
411 WorkstationL07::WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
412 : Resource(model, name, props),
413 Workstation(NULL, netElm, cpu),
418 double WorkstationL07::getPowerPeakAt(int /*pstate_index*/)
420 XBT_DEBUG("[ws_get_power_peak_at] Not implemented for workstation_ptask_L07");
424 int WorkstationL07::getNbPstates()
426 XBT_DEBUG("[ws_get_nb_pstates] Not implemented for workstation_ptask_L07");
430 void WorkstationL07::setPowerPeakAt(int /*pstate_index*/)
432 XBT_DEBUG("[ws_set_power_peak_at] Not implemented for workstation_ptask_L07");
435 double WorkstationL07::getConsumedEnergy()
437 XBT_DEBUG("[ws_get_consumed_energy] Not implemented for workstation_ptask_L07");
441 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props,
443 double power_initial, tmgr_trace_t power_trace,
444 e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
445 : Resource(model, name, props)
446 , CpuLmm(lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale))
448 p_power.scale = power_scale;
449 xbt_assert(p_power.scale > 0, "Power has to be >0");
451 m_powerCurrent = power_initial;
453 p_power.event = tmgr_history_add_trace(history, power_trace, 0.0, 0, static_cast<ResourcePtr>(this));
455 m_stateCurrent = state_initial;
457 p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
460 LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
462 tmgr_trace_t bw_trace,
464 tmgr_trace_t lat_trace,
465 e_surf_resource_state_t state_initial,
466 tmgr_trace_t state_trace,
467 e_surf_link_sharing_policy_t policy)
468 : Resource(model, name, props)
469 , NetworkLinkLmm(lmm_constraint_new(ptask_maxmin_system, this, bw_initial), history, state_trace)
471 m_bwCurrent = bw_initial;
473 p_bwEvent = tmgr_history_add_trace(history, bw_trace, 0.0, 0, static_cast<ResourcePtr>(this));
475 m_stateCurrent = state_initial;
476 m_latCurrent = lat_initial;
479 p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(this));
481 if (policy == SURF_LINK_FATPIPE)
482 lmm_constraint_shared(constraint());
485 bool CpuL07::isUsed(){
486 return lmm_constraint_used(ptask_maxmin_system, constraint());
489 bool LinkL07::isUsed(){
490 return lmm_constraint_used(ptask_maxmin_system, constraint());
493 void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
494 XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value);
495 if (event_type == p_power.event) {
496 m_powerCurrent = value;
497 lmm_update_constraint_bound(ptask_maxmin_system, constraint(), m_powerCurrent * p_power.scale);
498 if (tmgr_trace_event_free(event_type))
499 p_power.event = NULL;
500 } else if (event_type == p_stateEvent) {
502 m_stateCurrent = SURF_RESOURCE_ON;
504 m_stateCurrent = SURF_RESOURCE_OFF;
505 if (tmgr_trace_event_free(event_type))
508 XBT_CRITICAL("Unknown event ! \n");
514 void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
515 XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", getName(), this, value, date);
516 if (event_type == p_bwEvent) {
518 lmm_update_constraint_bound(ptask_maxmin_system, constraint(), m_bwCurrent);
519 if (tmgr_trace_event_free(event_type))
521 } else if (event_type == p_latEvent) {
522 lmm_variable_t var = NULL;
523 WorkstationL07ActionLmmPtr action;
524 lmm_element_t elem = NULL;
526 m_latCurrent = value;
527 while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, constraint(), &elem))) {
528 action = (WorkstationL07ActionLmmPtr) lmm_variable_id(var);
529 action->updateBound();
531 if (tmgr_trace_event_free(event_type))
533 } else if (event_type == p_stateEvent) {
535 m_stateCurrent = SURF_RESOURCE_ON;
537 m_stateCurrent = SURF_RESOURCE_OFF;
538 if (tmgr_trace_event_free(event_type))
541 XBT_CRITICAL("Unknown event ! \n");
547 e_surf_resource_state_t WorkstationL07::getState()
549 return p_cpu->getState();
552 e_surf_resource_state_t CpuL07::getState()
554 return m_stateCurrent;
557 double CpuL07::getSpeed(double load)
559 return load * p_power.scale;
562 double CpuL07::getAvailableSpeed()
564 return m_powerCurrent;
567 ActionPtr WorkstationL07::execute(double size)
569 void **workstation_list = xbt_new0(void *, 1);
570 double *computation_amount = xbt_new0(double, 1);
571 double *communication_amount = xbt_new0(double, 1);
573 workstation_list[0] = static_cast<ResourcePtr>(this);
574 communication_amount[0] = 0.0;
575 computation_amount[0] = size;
577 return static_cast<WorkstationL07ModelPtr>(getModel())->executeParallelTask(1, workstation_list,
579 communication_amount, -1);
582 ActionPtr WorkstationL07::sleep(double duration)
584 WorkstationL07ActionLmmPtr action = NULL;
586 XBT_IN("(%s,%g)", getName(), duration);
588 action = dynamic_cast<WorkstationL07ActionLmmPtr>(execute(1.0));
589 action->m_maxDuration = duration;
590 action->m_suspended = 2;
591 lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
597 double LinkL07::getBandwidth()
602 double LinkL07::getLatency()
607 bool LinkL07::isShared()
609 return lmm_constraint_is_shared(constraint());
616 WorkstationL07ActionLmm::~WorkstationL07ActionLmm(){
617 free(p_workstationList);
618 free(p_communicationAmount);
619 free(p_computationAmount);
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, getVariable(), lat_bound);
650 lmm_update_variable_bound(ptask_maxmin_system, getVariable(), 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, getVariable());
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, getVariable(), 0.0);
683 void WorkstationL07ActionLmm::resume()
685 XBT_IN("(%p)", this);
686 if (m_suspended != 2) {
687 lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 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);
719 /*FIXME:remove static void ptask_finalize(void)
721 xbt_dict_free(&ptask_parallel_task_link_set);
723 delete surf_workstation_model;
724 surf_workstation_model = NULL;
725 delete surf_network_model;
726 surf_network_model = NULL;
728 ptask_host_count = 0;
730 if (ptask_maxmin_system) {
731 lmm_system_free(ptask_maxmin_system);
732 ptask_maxmin_system = NULL;
736 /**************************************/
737 /******* Resource Private **********/
738 /**************************************/
740 /**************************************/
741 /*** Resource Creation & Destruction **/
742 /**************************************/
744 static void ptask_parse_workstation_init(sg_platf_host_cbarg_t host)
746 double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
747 //cpu->power_peak = power_peak;
748 xbt_dynar_free(&(host->power_peak)); /* kill memory leak */
749 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->createResource(
759 static void ptask_parse_cpu_init(sg_platf_host_cbarg_t host)
761 double power_peak = xbt_dynar_get_as(host->power_peak, host->pstate, double);
762 static_cast<CpuL07ModelPtr>(surf_cpu_model_pm)->createResource(
774 static void ptask_parse_link_init(sg_platf_link_cbarg_t link)
776 if (link->policy == SURF_LINK_FULLDUPLEX) {
778 link_id = bprintf("%s_UP", link->id);
779 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
781 link->bandwidth_trace,
789 link_id = bprintf("%s_DOWN", link->id);
790 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link_id,
792 link->bandwidth_trace,
798 NULL); /* FIXME: We need to deep copy the
799 * properties or we won't be able to free
803 static_cast<NetworkL07ModelPtr>(surf_network_model)->createResource(link->id,
805 link->bandwidth_trace,
814 current_property_set = NULL;
817 static void ptask_add_traces(){
818 static_cast<WorkstationL07ModelPtr>(surf_workstation_model)->addTraces();
821 static void ptask_define_callbacks()
823 sg_platf_host_add_cb(ptask_parse_cpu_init);
824 sg_platf_host_add_cb(ptask_parse_workstation_init);
825 sg_platf_link_add_cb(ptask_parse_link_init);
826 sg_platf_postparse_add_cb(ptask_add_traces);
829 /**************************************/
830 /*************** Generic **************/
831 /**************************************/
832 void surf_workstation_model_init_ptask_L07(void)
834 XBT_INFO("surf_workstation_model_init_ptask_L07");
835 xbt_assert(!surf_cpu_model_pm, "CPU model type already defined");
836 xbt_assert(!surf_network_model, "network model type already defined");
837 ptask_define_callbacks();
838 surf_workstation_model = new WorkstationL07Model();
839 ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
840 xbt_dynar_push(model_list, &model);
841 xbt_dynar_push(model_list_invoke, &model);