1 #include "smpi/smpi_utils.hpp"
2 #include "src/smpi/SmpiHost.hpp"
3 #include <simgrid/s4u/VirtualMachine.hpp>
7 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_host, smpi, "Logging specific to SMPI (host)");
12 simgrid::xbt::Extension<simgrid::s4u::Host, SmpiHost> SmpiHost::EXTENSION_ID;
14 double SmpiHost::orecv(size_t size)
16 if (orecv_parsed_values.empty()) {
17 if (orecv_.empty()) { /* This is currently always true since orecv_ is not really used yet. */
18 /* Get global value */
19 orecv_parsed_values = parse_factor(xbt_cfg_get_string("smpi/or"));
21 else /* Can currently not be reached, see above */
22 orecv_parsed_values = parse_factor(orecv_.c_str());
25 double current=orecv_parsed_values.empty()?0.0:orecv_parsed_values.front().values[0]+orecv_parsed_values.front().values[1]*size;
27 // Iterate over all the sections that were specified and find the right value. (fact.factor represents the interval
28 // sizes; we want to find the section that has fact.factor <= size and no other such fact.factor <= size)
29 // Note: parse_factor() (used before) already sorts the vector we iterate over!
30 for (auto fact : orecv_parsed_values) {
31 if (size <= fact.factor) { // Values already too large, use the previously computed value of current!
32 XBT_DEBUG("or : %zu <= %zu return %.10f", size, fact.factor, current);
35 // If the next section is too large, the current section must be used.
36 // Hence, save the cost, as we might have to use it.
37 current=fact.values[0]+fact.values[1]*size;
40 XBT_DEBUG("smpi_or: %zu is larger than largest boundary, return %.10f", size, current);
45 SmpiHost::SmpiHost(simgrid::s4u::Host *ptr) : host(ptr)
47 if (!SmpiHost::EXTENSION_ID.valid())
48 SmpiHost::EXTENSION_ID = simgrid::s4u::Host::extension_create<SmpiHost>();
50 // if (host->properties() != nullptr) {
51 // char* off_power_str = (char*)xbt_dict_get_or_null(host->properties(), "watt_off");
52 // if (off_power_str != nullptr) {
53 // char *msg = bprintf("Invalid value for property watt_off of host %s: %%s",host->name().c_str());
54 // watts_off = xbt_str_parse_double(off_power_str, msg);
62 SmpiHost::~SmpiHost()=default;
64 static void onCreation(simgrid::s4u::Host& host) {
67 static void onHostDestruction(simgrid::s4u::Host& host) {
68 // Ignore virtual machines
69 if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host))
73 void sg_smpi_host_init()
75 simgrid::s4u::Host::onCreation.connect(&onCreation);
76 simgrid::s4u::Host::onDestruction.connect(&onHostDestruction);