- s4u::Host::onSpeedChange: when the pstate is changed, or when an
event from the availability_file changes the avail speed.
- Links are now usable from s4u
+ - New: Engine::hostList() and Engine::hostCount(). Still clumsy.
- Drop Host::getPstateSpeedCurrent() which dupplicates Host::speed()
SimDag
#include <vector>
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_app_token_ring, "Messages specific for this s4u example");
-// FIXME: The following duplicates the content of s4u::Host
-extern std::map<std::string, simgrid::s4u::Host*> host_list;
class RelayRunner {
size_t task_comm_size = 1000000; /* The token is 1MB long*/
rank = xbt_str_parse_int(simgrid::s4u::this_actor::name().c_str(),
"Any process of this example must have a numerical name, not %s");
my_mailbox = simgrid::s4u::Mailbox::byName(std::to_string(rank));
- if (rank + 1 == host_list.size())
+ if (rank + 1 == simgrid::s4u::Engine::instance()->hostCount())
/* The last process, which sends the token back to rank 0 */
neighbor_mailbox = simgrid::s4u::Mailbox::byName("0");
else
xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]);
e->loadPlatform(argv[1]);
- XBT_INFO("Number of hosts '%zu'", host_list.size());
+ XBT_INFO("Number of hosts '%zu'", e->hostCount());
int id = 0;
- for (auto h : host_list) {
- simgrid::s4u::Host* host = h.second;
+ std::vector<simgrid::s4u::Host*> list;
+ e->hostList(&list);
+ for (auto host : list) {
/* - Give a unique rank to each host and create a @ref relay_runner process on each */
simgrid::s4u::Actor::createActor((std::to_string(id)).c_str(), host, RelayRunner());
id++;
/** @brief Load a deployment file and launch the actors that it contains */
void loadDeployment(const char *deploy);
+ unsigned int hostCount();
+ void hostList(std::vector<Host*>*);
+
/** @brief Run the simulation */
void run();
{
SIMIX_launch_application(deploy);
}
+// FIXME: The following duplicates the content of s4u::Host
+extern std::map<std::string, simgrid::s4u::Host*> host_list;
+/** @brief Returns the amount of hosts in the platform */
+unsigned int Engine::hostCount()
+{
+ return host_list.size();
+}
+/** @brief Fills the passed list with all hosts found in the platform */
+void Engine::hostList(std::vector<Host*>* list)
+{
+ for (auto kv : host_list)
+ list->push_back(kv.second);
+}
void Engine::run() {
if (MC_is_active()) {
XBT_LOG_EXTERNAL_CATEGORY(surf_route);
-std::map<std::string, simgrid::s4u::Host*> host_list; // FIXME: move it to Engine
-
int USER_HOST_LEVEL = -1;
namespace simgrid {
namespace s4u {
+std::map<std::string, simgrid::s4u::Host*> host_list; // FIXME: move it to Engine
+
simgrid::xbt::signal<void(Host&)> Host::onCreation;
simgrid::xbt::signal<void(Host&)> Host::onDestruction;
simgrid::xbt::signal<void(Host&)> Host::onStateChange;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sg_host, sd, "Logging specific to sg_hosts");
// FIXME: The following duplicates the content of s4u::Host
+namespace simgrid {
+namespace s4u {
extern std::map<std::string, simgrid::s4u::Host*> host_list;
+}
+}
extern "C" {
* the tests.
*/
std::vector<std::string> names = std::vector<std::string>();
- for (auto kv : host_list)
+ for (auto kv : simgrid::s4u::host_list)
names.push_back(kv.second->name());
std::sort(names.begin(), names.end());
for (auto name : names)
- host_list.at(name)->destroy();
+ simgrid::s4u::host_list.at(name)->destroy();
// host_list.clear(); This would be sufficient if the dict would contain smart_ptr. It's now useless
}
size_t sg_host_count()
{
- return host_list.size();
+ return simgrid::s4u::host_list.size();
}
/** @brief Returns the host list
*
{
xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t),nullptr);
- for (auto kv : host_list) {
+ for (auto kv : simgrid::s4u::host_list) {
simgrid::s4u::Host* host = kv.second;
if (host && host->pimpl_netpoint && host->pimpl_netpoint->isHost())
xbt_dynar_push(res, &host);