-/* Copyright (c) 2017-2018. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
namespace filter {
/* First example of thing that we can use as a filtering criteria: a simple boolean function */
-static bool filter_speed_more_than_50Mf(simgrid::s4u::Host* host)
+static bool filter_speed_more_than_50Mf(const simgrid::s4u::Host* host)
{
- return host->getSpeed() > 50E6;
+ return host->get_speed() > 50E6;
}
/* Second kind of thing that we can use as a filtering criteria: a functor (=function object).
*/
class SingleCore {
public:
- bool operator()(simgrid::s4u::Host* host) { return host->get_core_count() == 1; }
+ bool operator()(const simgrid::s4u::Host* host) const { return host->get_core_count() == 1; }
};
/* This functor is a bit more complex, as it saves the current state when created.
- * Then, it allows to easily retrieve the hosts which frequency changed since the functor creation.
+ * Then, it allows one to easily retrieve the hosts which frequency changed since the functor creation.
*/
class FrequencyChanged {
std::map<simgrid::s4u::Host*, int> host_list;
/* Use a lambda function to filter hosts: We only want multicore hosts */
XBT_INFO("Hosts currently registered with this engine: %zu", e.get_host_count());
std::vector<simgrid::s4u::Host*> list =
- e.get_filtered_hosts([](simgrid::s4u::Host* host) { return host->get_core_count() > 1; });
+ e.get_filtered_hosts([](const simgrid::s4u::Host* host) { return host->get_core_count() > 1; });
for (auto& host : list)
XBT_INFO("The following hosts have more than one core: %s", host->get_cname());
list = e.get_filtered_hosts(filter);
for (auto& host : list)
- XBT_INFO("The following hosts changed their frequency: %s (from %.1ff to %.1ff)", host->get_cname(), host->getPstateSpeed(filter.get_old_speed(host)), host->getSpeed());
+ XBT_INFO("The following hosts changed their frequency: %s (from %.1ff to %.1ff)", host->get_cname(),
+ host->get_pstate_speed(filter.get_old_speed(host)), host->get_speed());
/* You can also just use any regular function (namespaced on need) to filter */
list = e.get_filtered_hosts(filter::filter_speed_more_than_50Mf);