Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[PLUGINS] Initial commit for the Dvfs plugin (frequency governors)
[simgrid.git] / src / surf / host_clm03.cpp
1 /* Copyright (c) 2013-2015. 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 <cstdlib>
8
9 #include <algorithm>
10
11 #include "host_clm03.hpp"
12
13 #include "cpu_cas01.hpp"
14 #include "simgrid/sg_config.h"
15
16 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host);
17
18 /*************
19  * CallBacks *
20  *************/
21
22 /*********
23  * Model *
24  *********/
25
26 void surf_host_model_init_current_default()
27 {
28   surf_host_model = new simgrid::surf::HostCLM03Model();
29   xbt_cfg_setdefault_boolean("network/crosstraffic", "yes");
30   surf_cpu_model_init_Cas01();
31   surf_network_model_init_LegrandVelho();
32
33   all_existing_models->push_back(surf_host_model);
34 }
35
36 void surf_host_model_init_compound()
37 {
38   xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
39   xbt_assert(surf_network_model, "No network model defined yet!");
40
41   surf_host_model = new simgrid::surf::HostCLM03Model();
42   all_existing_models->push_back(surf_host_model);
43 }
44
45 namespace simgrid {
46 namespace surf {
47
48 double HostCLM03Model::nextOccuringEvent(double now){
49   ignoreEmptyVmInPmLMM();
50
51   double min_by_cpu = surf_cpu_model_pm->nextOccuringEvent(now);
52   double min_by_net = surf_network_model->nextOccuringEventIsIdempotent() ? surf_network_model->nextOccuringEvent(now) : -1;
53   double min_by_sto = surf_storage_model->nextOccuringEvent(now);
54
55   XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
56       this, typeid(surf_cpu_model_pm).name(), min_by_cpu,
57       typeid(surf_network_model).name(), min_by_net,
58       typeid(surf_storage_model).name(), min_by_sto);
59
60   double res = std::max({min_by_cpu, min_by_net, min_by_sto});
61   if (min_by_cpu >= 0.0 && min_by_cpu < res)
62     res = min_by_cpu;
63   if (min_by_net >= 0.0 && min_by_net < res)
64     res = min_by_net;
65   if (min_by_sto >= 0.0 && min_by_sto < res)
66     res = min_by_sto;
67   return res;
68 }
69
70 void HostCLM03Model::updateActionsState(double /*now*/, double /*delta*/){
71   /* I won't do what you tell me */
72 }
73
74 }
75 }