Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add MSG_host_on and MSG_host_off
[simgrid.git] / src / surf / workstation.c
1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "xbt/ex.h"
8 #include "xbt/dict.h"
9 #include "portable.h"
10 #include "surf_private.h"
11 #include "storage_private.h"
12 #include "surf/surf_resource.h"
13 #include "simgrid/sg_config.h"
14 #include "workstation_private.h"
15 #include "vm_workstation_private.h"
16 #include "cpu_cas01_private.h"
17 #include "maxmin_private.h"
18
19 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_workstation, surf,
20                                 "Logging specific to the SURF workstation module");
21
22 surf_model_t surf_workstation_model = NULL;
23
24
25 static void workstation_new(sg_platf_host_cbarg_t host)
26 {
27   const char *name = host->id;
28
29   /* NOTE: The properties object is NULL, because the current code uses that of
30    * that of a cpu resource. */
31   workstation_CLM03_t ws = (workstation_CLM03_t) surf_resource_new(sizeof(s_workstation_CLM03_t), surf_workstation_model, name, NULL);
32
33   ws->storage = xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL);
34   ws->net_elm = xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL);
35
36   XBT_DEBUG("Create ws %s with %ld mounted disks", name, xbt_dynar_length(ws->storage));
37   xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, ws);
38 }
39
40
41 static void ws_parallel_action_cancel(surf_action_t action)
42 {
43   THROW_UNIMPLEMENTED;          /* This model does not implement parallel tasks */
44 }
45
46 static int ws_parallel_action_free(surf_action_t action)
47 {
48   THROW_UNIMPLEMENTED;          /* This model does not implement parallel tasks */
49   return -1;
50 }
51
52 int ws_action_unref(surf_action_t action)
53 {
54   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
55     return surf_network_model->action_unref(action);
56   else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
57     return action->model_obj->action_unref(action);
58       // previously was: Adrien/Arnaud 6 feb
59           // surf_cpu_model->action_unref(action);
60   else if (action->model_obj->type == SURF_MODEL_TYPE_WORKSTATION)
61     return ws_parallel_action_free(action);
62   else
63     DIE_IMPOSSIBLE;
64   return 0;
65 }
66
67 void ws_action_cancel(surf_action_t action)
68 {
69   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
70     surf_network_model->action_cancel(action);
71   else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
72     action->model_obj->action_cancel(action);
73   else if (action->model_obj->type == SURF_MODEL_TYPE_WORKSTATION)
74     ws_parallel_action_cancel(action);
75   else
76     DIE_IMPOSSIBLE;
77   return;
78 }
79
80 static void ws_action_state_set(surf_action_t action,
81                                 e_surf_action_state_t state)
82 {
83   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
84     surf_network_model->action_state_set(action, state);
85   else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
86     action->model_obj->action_state_set(action, state);
87   else if (action->model_obj->type == SURF_MODEL_TYPE_WORKSTATION)
88     surf_action_state_set(action, state);
89   else
90     DIE_IMPOSSIBLE;
91   return;
92 }
93
94
95 /* -- The callback functions at model_private -- */
96 /* These callbacks are also used for the vm workstation model. */
97 int ws_resource_used(void *resource_id)
98 {
99   /* This model does not implement parallel tasks */
100   THROW_IMPOSSIBLE;
101   return -1;
102 }
103
104
105 /* TODO: The current code would be slow due to the iteration. Later, we can
106  * make it faster. */
107 static int constraint_is_active(cpu_Cas01_t cpu_cas01)
108 {
109   surf_model_t cpu_model = cpu_cas01->generic_resource.model;
110   lmm_system_t sys = cpu_model->model_private->maxmin_system;
111   int found = 0;
112   lmm_constraint_t cnst_tmp;
113
114   xbt_swag_foreach(cnst_tmp, &sys->active_constraint_set) {
115     if (cnst_tmp == cpu_cas01->constraint) {
116       found = 1;
117       break;
118     }
119   }
120
121   return found;
122 }
123
124 /* Each VM has a dummy CPU action on the PM layer. This CPU action works as the
125  * constraint (capacity) of the VM in the PM layer. If the VM does not have any
126  * active task, the dummy CPU action must be deactivated, so that the VM does
127  * not get any CPU share in the PM layer. */
128 static void adjust_weight_of_dummy_cpu_actions(void)
129 {
130   /* iterate for all hosts including virtual machines */
131   xbt_lib_cursor_t cursor;
132   char *key;
133   void **ind_host;
134
135   xbt_lib_foreach(host_lib, cursor, key, ind_host) {
136     workstation_CLM03_t ws_clm03 = ind_host[SURF_WKS_LEVEL];
137     cpu_Cas01_t cpu_cas01 = ind_host[SURF_CPU_LEVEL];
138
139     if (!ws_clm03)
140       continue;
141     /* skip if it is not a virtual machine */
142     if (ws_clm03->generic_resource.model != surf_vm_workstation_model)
143       continue;
144     xbt_assert(cpu_cas01, "cpu-less workstation");
145
146     /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
147     workstation_VM2013_t ws_vm2013 = (workstation_VM2013_t) ws_clm03;
148
149     if (constraint_is_active(cpu_cas01)) {
150       /* some tasks exist on this VM */
151       XBT_DEBUG("set the weight of the dummy CPU action on PM to 1");
152
153       /* FIXME: we shoud use lmm_update_variable_weight() ? */
154       /* FIXME: If we assgign 1.05 and 0.05, the system makes apparently wrong values. */
155       surf_action_set_priority(ws_vm2013->cpu_action, 1);
156
157     } else {
158       /* no task exits on this VM */
159       XBT_DEBUG("set the weight of the dummy CPU action on PM to 0");
160
161       surf_action_set_priority(ws_vm2013->cpu_action, 0);
162     }
163   }
164 }
165
166
167 double ws_share_resources(surf_model_t workstation_model, double now)
168 {
169   if (workstation_model->type == SURF_MODEL_TYPE_WORKSTATION)
170     adjust_weight_of_dummy_cpu_actions();
171
172   /* Invoke the share_resources() callback of the physical cpu model object and
173    * the network model objects. */
174   surf_model_t cpu_model = workstation_model->extension.workstation.cpu_model;
175   surf_model_t net_model = surf_network_model;
176
177   double min_by_cpu = cpu_model->model_private->share_resources(cpu_model, now);
178   double min_by_net = net_model->model_private->share_resources(net_model, now);
179
180   XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f",
181       workstation_model, cpu_model->name, min_by_cpu, net_model->name, min_by_net);
182
183   if (min_by_cpu >= 0.0 && min_by_net >= 0.0)
184     return min(min_by_cpu, min_by_net);
185   else if (min_by_cpu >= 0.0)
186     return min_by_cpu;
187   else if (min_by_net >= 0.0)
188     return min_by_net;
189   else
190     return min_by_cpu;  /* probably min_by_cpu == min_by_net == -1 */
191 }
192
193 void ws_update_actions_state(surf_model_t workstation_model, double now, double delta)
194 {
195   return;
196 }
197
198 void ws_update_resource_state(void *id, tmgr_trace_event_t event_type, double value, double date)
199 {
200   /* This model does not implement parallel tasks */
201   THROW_IMPOSSIBLE;
202 }
203
204 void ws_finalize(surf_model_t workstation_model)
205 {
206   surf_model_exit(workstation_model);
207   workstation_model = NULL;
208 }
209
210
211
212 surf_action_t ws_execute(void *workstation, double size)
213 {
214   surf_resource_t cpu = ((surf_resource_t) surf_cpu_resource_priv(workstation));
215   return cpu->model->extension.cpu.execute(workstation, size);
216 }
217
218 surf_action_t ws_action_sleep(void *workstation, double duration)
219 {
220   surf_resource_t cpu = ((surf_resource_t) surf_cpu_resource_priv(workstation));
221   return cpu->model->extension.cpu.sleep(workstation, duration);
222 }
223
224 void ws_action_suspend(surf_action_t action)
225 {
226   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
227     surf_network_model->suspend(action);
228   else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
229     action->model_obj->suspend(action);
230   else
231     DIE_IMPOSSIBLE;
232 }
233
234 void ws_action_resume(surf_action_t action)
235 {
236   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
237     surf_network_model->resume(action);
238   else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
239     action->model_obj->resume(action);
240   else
241     DIE_IMPOSSIBLE;
242 }
243
244 static int ws_action_is_suspended(surf_action_t action)
245 {
246   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
247     return surf_network_model->is_suspended(action);
248   if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
249     return action->model_obj->is_suspended(action);
250   DIE_IMPOSSIBLE;
251   return -1;
252 }
253
254 static void ws_action_set_max_duration(surf_action_t action,
255                                        double duration)
256 {
257   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
258     surf_network_model->set_max_duration(action, duration);
259   else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
260     action->model_obj->set_max_duration(action, duration);
261   else
262     DIE_IMPOSSIBLE;
263 }
264
265 void ws_action_set_priority(surf_action_t action, double priority)
266 {
267   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
268     surf_network_model->set_priority(action, priority);
269   else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
270     action->model_obj->set_priority(action, priority);
271   else
272     DIE_IMPOSSIBLE;
273 }
274
275 void ws_action_set_bound(surf_action_t action, double bound)
276 {
277   /* FIXME: only for CPU model object? */
278   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
279     surf_network_model->set_bound(action, bound);
280   else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
281     action->model_obj->set_bound(action, bound);
282   else
283     DIE_IMPOSSIBLE;
284 }
285
286 #ifdef HAVE_TRACING
287 static void ws_action_set_category(surf_action_t action, const char *category)
288 {
289   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
290     surf_network_model->set_category(action, category);
291   else if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
292     action->model_obj->set_category(action, category);
293   else
294     DIE_IMPOSSIBLE;
295 }
296 #endif
297
298 #ifdef HAVE_LATENCY_BOUND_TRACKING
299 static int ws_get_latency_limited(surf_action_t action)
300 {
301   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
302     return surf_network_model->get_latency_limited(action);
303   else
304     return 0;
305 }
306 #endif
307
308 double ws_action_get_remains(surf_action_t action)
309 {
310   if (action->model_obj->type == SURF_MODEL_TYPE_NETWORK)
311     return surf_network_model->get_remains(action);
312   if (action->model_obj->type == SURF_MODEL_TYPE_CPU)
313     return action->model_obj->get_remains(action);
314   DIE_IMPOSSIBLE;
315   return -1.0;
316 }
317
318 static surf_action_t ws_communicate(void *workstation_src,
319                                     void *workstation_dst, double size,
320                                     double rate)
321 {
322   workstation_CLM03_t src = surf_workstation_resource_priv(workstation_src);
323   workstation_CLM03_t dst = surf_workstation_resource_priv(workstation_dst);
324   return surf_network_model->extension.network.
325       communicate(src->net_elm,
326                   dst->net_elm, size, rate);
327 }
328
329 e_surf_resource_state_t ws_get_state(void *workstation)
330 {
331   surf_resource_t cpu = ((surf_resource_t) surf_cpu_resource_priv(workstation));
332   return cpu->model->extension.cpu.get_state(workstation);
333 }
334
335 void ws_set_state(void *workstation, e_surf_resource_state_t state)
336 {
337   surf_resource_t cpu = ((surf_resource_t) surf_cpu_resource_priv(workstation));
338   cpu->model->extension.cpu.set_state(workstation, state);
339 }
340
341 double ws_get_speed(void *workstation, double load)
342 {
343   surf_resource_t cpu = ((surf_resource_t) surf_cpu_resource_priv(workstation));
344   return cpu->model->extension.cpu.get_speed(workstation, load);
345 }
346
347 static double ws_get_available_speed(void *workstation)
348 {
349   surf_resource_t cpu = ((surf_resource_t) surf_cpu_resource_priv(workstation));
350   return cpu->model->extension.cpu.get_available_speed(workstation);
351 }
352
353 static surf_action_t ws_execute_parallel_task(int workstation_nb,
354                                               void **workstation_list,
355                                               double *computation_amount,
356                                               double *communication_amount,
357                                               double rate)
358 {
359 #define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
360   if ((workstation_nb == 1)
361       && (cost_or_zero(communication_amount, 0) == 0.0))
362     return ws_execute(workstation_list[0], computation_amount[0]);
363   else if ((workstation_nb == 1)
364            && (cost_or_zero(computation_amount, 0) == 0.0))
365     return ws_communicate(workstation_list[0], workstation_list[0],communication_amount[0], rate);
366   else if ((workstation_nb == 2)
367              && (cost_or_zero(computation_amount, 0) == 0.0)
368              && (cost_or_zero(computation_amount, 1) == 0.0)) {
369     int i,nb = 0;
370     double value = 0.0;
371
372     for (i = 0; i < workstation_nb * workstation_nb; i++) {
373       if (cost_or_zero(communication_amount, i) > 0.0) {
374         nb++;
375         value = cost_or_zero(communication_amount, i);
376       }
377     }
378     if (nb == 1)
379       return ws_communicate(workstation_list[0], workstation_list[1],value, rate);
380   }
381 #undef cost_or_zero
382
383   THROW_UNIMPLEMENTED;          /* This model does not implement parallel tasks */
384   return NULL;
385 }
386
387
388 /* returns an array of network_link_CM02_t */
389 static xbt_dynar_t ws_get_route(void *workstation_src, void *workstation_dst)
390 {
391   XBT_DEBUG("ws_get_route");
392   workstation_CLM03_t src = surf_workstation_resource_priv(workstation_src);
393   workstation_CLM03_t dst = surf_workstation_resource_priv(workstation_dst);
394   return surf_network_model->extension.
395       network.get_route(src->net_elm,
396                   dst->net_elm);
397 }
398
399 static double ws_get_link_bandwidth(const void *link)
400 {
401   return surf_network_model->extension.network.get_link_bandwidth(link);
402 }
403
404 static double ws_get_link_latency(const void *link)
405 {
406   return surf_network_model->extension.network.get_link_latency(link);
407 }
408
409 static int ws_link_shared(const void *link)
410 {
411   return surf_network_model->extension.network.link_shared(link);
412 }
413
414 static xbt_dict_t ws_get_properties(const void *ws)
415 {
416   return surf_resource_properties(surf_cpu_resource_priv(ws));
417 }
418
419 static storage_t find_storage_on_mount_list(void *workstation,const char* storage)
420 {
421   storage_t st = NULL;
422   s_mount_t mnt;
423   unsigned int cursor;
424   workstation_CLM03_t ws = (workstation_CLM03_t) surf_workstation_resource_priv(workstation);
425   xbt_dynar_t storage_list = ws->storage;
426
427   XBT_DEBUG("Search for storage name '%s' on '%s'",storage,ws->generic_resource.name);
428   xbt_dynar_foreach(storage_list,cursor,mnt)
429   {
430     XBT_DEBUG("See '%s'",mnt.name);
431     if(!strcmp(storage,mnt.name)){
432       st = mnt.id;
433       break;
434     }
435   }
436   if(!st) xbt_die("Can't find mount '%s' for '%s'",storage,ws->generic_resource.name);
437   return st;
438 }
439
440 static surf_action_t ws_action_open(void *workstation, const char* mount, const char* path, const char* mode)
441 {
442   storage_t st = find_storage_on_mount_list(workstation, mount);
443   XBT_DEBUG("OPEN on disk '%s'",st->generic_resource.name);
444   surf_model_t model = st->generic_resource.model;
445   return model->extension.storage.open(st, mount, path, mode);
446 }
447
448 static surf_action_t ws_action_close(void *workstation, surf_file_t fp)
449 {
450   storage_t st = find_storage_on_mount_list(workstation, fp->storage);
451   XBT_DEBUG("CLOSE on disk '%s'",st->generic_resource.name);
452   surf_model_t model = st->generic_resource.model;
453   return model->extension.storage.close(st, fp);
454 }
455
456 static surf_action_t ws_action_read(void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream)
457 {
458   storage_t st = find_storage_on_mount_list(workstation, stream->storage);
459   XBT_DEBUG("READ on disk '%s'",st->generic_resource.name);
460   surf_model_t model = st->generic_resource.model;
461   return model->extension.storage.read(st, ptr, (double)size, nmemb, stream);
462 }
463
464 static surf_action_t ws_action_write(void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream)
465 {
466   storage_t st = find_storage_on_mount_list(workstation, stream->storage);
467   XBT_DEBUG("WRITE on disk '%s'",st->generic_resource.name);
468   surf_model_t model = st->generic_resource.model;
469   return model->extension.storage.write(st,  ptr, size, nmemb, stream);
470 }
471
472 static surf_action_t ws_action_stat(void *workstation, surf_file_t stream)
473 {
474   storage_t st = find_storage_on_mount_list(workstation, stream->storage);
475   XBT_DEBUG("STAT on disk '%s'",st->generic_resource.name);
476   surf_model_t model = st->generic_resource.model;
477   return model->extension.storage.stat(st,  stream);
478 }
479
480 static surf_action_t ws_action_unlink(void *workstation, surf_file_t stream)
481 {
482   storage_t st = find_storage_on_mount_list(workstation, stream->storage);
483   XBT_DEBUG("UNLINK on disk '%s'",st->generic_resource.name);
484   surf_model_t model = st->generic_resource.model;
485   return model->extension.storage.unlink(st,  stream);
486 }
487
488 static surf_action_t ws_action_ls(void *workstation, const char* mount, const char *path)
489 {
490   XBT_DEBUG("LS on mount '%s' and file '%s'",mount, path);
491   storage_t st = find_storage_on_mount_list(workstation, mount);
492   surf_model_t model = st->generic_resource.model;
493   return model->extension.storage.ls(st, path);
494 }
495
496 void ws_get_params(void *ws, ws_params_t params)
497 {
498   workstation_CLM03_t ws_clm03 = surf_workstation_resource_priv(ws);
499   memcpy(params, &ws_clm03->params, sizeof(s_ws_params_t));
500 }
501
502 void ws_set_params(void *ws, ws_params_t params)
503 {
504   workstation_CLM03_t ws_clm03 = surf_workstation_resource_priv(ws);
505   /* may check something here. */
506   memcpy(&ws_clm03->params, params, sizeof(s_ws_params_t));
507 }
508
509 static xbt_dynar_t ws_get_vms(void *pm)
510 {
511   xbt_dynar_t dyn = xbt_dynar_new(sizeof(smx_host_t), NULL);
512
513   /* iterate for all hosts including virtual machines */
514   xbt_lib_cursor_t cursor;
515   char *key;
516   void **ind_host;
517   xbt_lib_foreach(host_lib, cursor, key, ind_host) {
518     workstation_CLM03_t ws_clm03 = ind_host[SURF_WKS_LEVEL];
519     if (!ws_clm03)
520       continue;
521     /* skip if it is not a virtual machine */
522     if (ws_clm03->generic_resource.model != surf_vm_workstation_model)
523       continue;
524
525     /* It is a virtual machine, so we can cast it to workstation_VM2013_t */
526     workstation_VM2013_t ws_vm2013 = (workstation_VM2013_t) ws_clm03;
527     if (pm == ws_vm2013->sub_ws)
528       xbt_dynar_push(dyn, &ws_vm2013->sub_ws);
529   }
530
531   return dyn;
532 }
533
534
535 static void surf_workstation_model_init_internal(void)
536 {
537   surf_model_t model = surf_model_init();
538
539   model->name = "Workstation";
540   model->type = SURF_MODEL_TYPE_WORKSTATION;
541   model->action_unref     = ws_action_unref;
542   model->action_cancel    = ws_action_cancel;
543   model->action_state_set = ws_action_state_set;
544
545   model->model_private->resource_used         = ws_resource_used;
546   model->model_private->share_resources       = ws_share_resources;
547   model->model_private->update_actions_state  = ws_update_actions_state;
548   model->model_private->update_resource_state = ws_update_resource_state;
549   model->model_private->finalize              = ws_finalize;
550
551   model->suspend          = ws_action_suspend;
552   model->resume           = ws_action_resume;
553   model->is_suspended     = ws_action_is_suspended;
554   model->set_max_duration = ws_action_set_max_duration;
555   model->set_priority     = ws_action_set_priority;
556   model->set_bound        = ws_action_set_bound;
557   #ifdef HAVE_TRACING
558   model->set_category     = ws_action_set_category;
559   #endif
560   model->get_remains      = ws_action_get_remains;
561   #ifdef HAVE_LATENCY_BOUND_TRACKING
562   model->get_latency_limited = ws_get_latency_limited;
563   #endif
564
565   /* For VM support, we have a surf cpu model object for each workstation model
566    * object. The physical workstation model object has the cpu model object of
567    * the physical machine layer. */
568   xbt_assert(surf_cpu_model_pm);
569   model->extension.workstation.cpu_model = surf_cpu_model_pm;
570
571   model->extension.workstation.execute   = ws_execute;
572   model->extension.workstation.sleep     = ws_action_sleep;
573   model->extension.workstation.get_state = ws_get_state;
574   model->extension.workstation.set_state = ws_set_state;
575   model->extension.workstation.get_speed = ws_get_speed;
576   model->extension.workstation.get_available_speed = ws_get_available_speed;
577
578   model->extension.workstation.communicate           = ws_communicate;
579   model->extension.workstation.get_route             = ws_get_route;
580   model->extension.workstation.execute_parallel_task = ws_execute_parallel_task;
581   model->extension.workstation.get_link_bandwidth    = ws_get_link_bandwidth;
582   model->extension.workstation.get_link_latency      = ws_get_link_latency;
583   model->extension.workstation.link_shared           = ws_link_shared;
584   model->extension.workstation.get_properties        = ws_get_properties;
585
586   model->extension.workstation.open   = ws_action_open;
587   model->extension.workstation.close  = ws_action_close;
588   model->extension.workstation.read   = ws_action_read;
589   model->extension.workstation.write  = ws_action_write;
590   model->extension.workstation.stat   = ws_action_stat;
591   model->extension.workstation.unlink = ws_action_unlink;
592   model->extension.workstation.ls     = ws_action_ls;
593
594   model->extension.workstation.get_params = ws_get_params;
595   model->extension.workstation.set_params = ws_set_params;
596   model->extension.workstation.get_vms    = ws_get_vms;
597
598   surf_workstation_model = model;
599 }
600
601 void surf_workstation_model_init_current_default(void)
602 {
603   xbt_cfg_setdefault_int(_sg_cfg_set, "network/crosstraffic", 1);
604   surf_cpu_model_init_Cas01();
605   surf_network_model_init_LegrandVelho();
606
607   /* surf_cpu_mode_pm and surf_network_model must be initialized in advance. */
608   xbt_assert(surf_cpu_model_pm);
609   xbt_assert(surf_network_model);
610   surf_workstation_model_init_internal();
611
612   xbt_dynar_push(model_list, &surf_workstation_model);
613   xbt_dynar_push(model_list_invoke, &surf_workstation_model);
614   sg_platf_host_add_cb(workstation_new);
615 }
616
617 void surf_workstation_model_init_compound()
618 {
619   xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
620   xbt_assert(surf_network_model, "No network model defined yet!");
621
622   surf_workstation_model_init_internal();
623   xbt_dynar_push(model_list, &surf_workstation_model);
624   xbt_dynar_push(model_list_invoke, &surf_workstation_model);
625   sg_platf_host_add_cb(workstation_new);
626 }