1 #include "smpi/smpi_utils.hpp"
2 #include "src/smpi/SmpiHost.hpp"
3 #include "src/surf/virtual_machine.hpp"
8 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_host, smpi, "Logging specific to SMPI (host)");
13 simgrid::xbt::Extension<simgrid::s4u::Host, SmpiHost> SmpiHost::EXTENSION_ID;
15 double SmpiHost::orecv(size_t size)
17 if (orecv_parsed_values.empty()) {
19 std::string test = xbt_cfg_get_string("smpi/or");
20 orecv_parsed_values = parse_factor(xbt_cfg_get_string("smpi/or"));
23 orecv_parsed_values = parse_factor(orecv_.c_str());
26 double current=orecv_parsed_values.empty()?0.0:orecv_parsed_values.front().values[0]+orecv_parsed_values.front().values[1]*size;
28 // Iterate over all the sections that were specified and find the right value. (fact.factor represents the interval
29 // sizes; we want to find the section that has fact.factor <= size and no other such fact.factor <= size)
30 // Note: parse_factor() (used before) already sorts the vector we iterate over!
31 for (auto fact : orecv_parsed_values) {
32 if (size <= fact.factor) { // Values already too large, use the previously computed value of current!
33 XBT_DEBUG("or : %zu <= %zu return %.10f", size, fact.factor, current);
36 // If the next section is too large, the current section must be used.
37 // Hence, save the cost, as we might have to use it.
38 current=fact.values[0]+fact.values[1]*size;
41 XBT_DEBUG("smpi_or: %zu is larger than largest boundary, return %.10f", size, current);
46 SmpiHost::SmpiHost(simgrid::s4u::Host *ptr) : host(ptr)
48 if (!SmpiHost::EXTENSION_ID.valid())
49 SmpiHost::EXTENSION_ID = simgrid::s4u::Host::extension_create<SmpiHost>();
51 // if (host->properties() != nullptr) {
52 // char* off_power_str = (char*)xbt_dict_get_or_null(host->properties(), "watt_off");
53 // if (off_power_str != nullptr) {
54 // char *msg = bprintf("Invalid value for property watt_off of host %s: %%s",host->name().c_str());
55 // watts_off = xbt_str_parse_double(off_power_str, msg);
63 SmpiHost::~SmpiHost()=default;
65 static void onCreation(simgrid::s4u::Host& host) {
68 static void onHostDestruction(simgrid::s4u::Host& host) {
69 // Ignore virtual machines
70 simgrid::surf::HostImpl* surf_host = host.extension<simgrid::surf::HostImpl>();
71 if (dynamic_cast<simgrid::surf::VirtualMachine*>(surf_host))
75 void sg_smpi_host_init()
77 simgrid::s4u::Host::onCreation.connect(&onCreation);
78 simgrid::s4u::Host::onDestruction.connect(&onHostDestruction);