1 /* Copyright (c) 2013-2015. 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. */
11 #include "host_clm03.hpp"
13 #include "cpu_cas01.hpp"
14 #include "simgrid/sg_config.h"
15 #include "virtual_machine.hpp"
17 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_host);
27 void surf_host_model_init_current_default(void)
29 surf_host_model = new simgrid::surf::HostCLM03Model();
30 xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/crosstraffic", "yes");
31 surf_cpu_model_init_Cas01();
32 surf_network_model_init_LegrandVelho();
34 simgrid::surf::Model *model = surf_host_model;
35 xbt_dynar_push(all_existing_models, &model);
38 void surf_host_model_init_compound()
40 xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
41 xbt_assert(surf_network_model, "No network model defined yet!");
43 surf_host_model = new simgrid::surf::HostCLM03Model();
44 xbt_dynar_push(all_existing_models, &surf_host_model);
50 Host *HostCLM03Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu, xbt_dict_t props){
51 Host *host = new simgrid::surf::Host(surf_host_model, name, props,
52 (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
54 XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
58 double HostCLM03Model::shareResources(double now){
59 adjustWeightOfDummyCpuActions();
61 double min_by_cpu = surf_cpu_model_pm->shareResources(now);
62 double min_by_net = surf_network_model->shareResourcesIsIdempotent() ? surf_network_model->shareResources(now) : -1;
63 double min_by_sto = surf_storage_model->shareResources(now);
65 XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
66 this, typeid(surf_cpu_model_pm).name(), min_by_cpu,
67 typeid(surf_network_model).name(), min_by_net,
68 typeid(surf_storage_model).name(), min_by_sto);
70 double res = std::max(std::max(min_by_cpu, min_by_net), min_by_sto);
71 if (min_by_cpu >= 0.0 && min_by_cpu < res)
73 if (min_by_net >= 0.0 && min_by_net < res)
75 if (min_by_sto >= 0.0 && min_by_sto < res)
80 void HostCLM03Model::updateActionsState(double /*now*/, double /*delta*/){
84 Action *HostCLM03Model::executeParallelTask(int host_nb,
89 #define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
92 && (cost_or_zero(bytes_amount, 0) == 0.0)){
93 action = surf_host_execute(host_list[0],flops_amount[0]);
94 } else if ((host_nb == 1)
95 && (cost_or_zero(flops_amount, 0) == 0.0)) {
96 action = surf_network_model->communicate(sg_host_edge(host_list[0]),
97 sg_host_edge(host_list[0]),
98 bytes_amount[0], rate);
99 } else if ((host_nb == 2)
100 && (cost_or_zero(flops_amount, 0) == 0.0)
101 && (cost_or_zero(flops_amount, 1) == 0.0)) {
105 for (i = 0; i < host_nb * host_nb; i++) {
106 if (cost_or_zero(bytes_amount, i) > 0.0) {
108 value = cost_or_zero(bytes_amount, i);
112 action = surf_network_model->communicate(sg_host_edge(host_list[0]),
113 sg_host_edge(host_list[1]),
117 THROW_UNIMPLEMENTED; /* This model does not implement parallel tasks for more than 2 hosts */