A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Kill the now useless type xbt::string
[simgrid.git]
/
examples
/
cpp
/
platform-properties
/
s4u-platform-properties.cpp
diff --git
a/examples/cpp/platform-properties/s4u-platform-properties.cpp
b/examples/cpp/platform-properties/s4u-platform-properties.cpp
index 63c655e6f0c49f8e8541ab114c82ea1ae46e571e..05de2f310e048d75bccd01d19409f7eac0a2ec20 100644
(file)
--- a/
examples/cpp/platform-properties/s4u-platform-properties.cpp
+++ b/
examples/cpp/platform-properties/s4u-platform-properties.cpp
@@
-1,4
+1,4
@@
-/* Copyright (c) 2017-202
1
. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2017-202
2
. 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. */
/* 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. */
@@
-10,10
+10,11
@@
#include <string>
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Property test");
#include <string>
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Property test");
+namespace sg4 = simgrid::s4u;
static void test_host(const std::string& hostname)
{
static void test_host(const std::string& hostname)
{
- s
imgrid::s4u::Host* thehost = simgrid::s4u
::Host::by_name(hostname);
+ s
g4::Host* thehost = sg4
::Host::by_name(hostname);
const std::unordered_map<std::string, std::string>* hostprops = thehost->get_properties();
const char* noexist = "Unknown";
const char* exist = "Hdd";
const std::unordered_map<std::string, std::string>* hostprops = thehost->get_properties();
const char* noexist = "Unknown";
const char* exist = "Hdd";
@@
-22,8
+23,8
@@
static void test_host(const std::string& hostname)
XBT_INFO("== Print the properties of the host '%s'", hostname.c_str());
// Sort the properties before displaying them, so that the tests are perfectly reproducible
std::vector<std::string> keys;
XBT_INFO("== Print the properties of the host '%s'", hostname.c_str());
// Sort the properties before displaying them, so that the tests are perfectly reproducible
std::vector<std::string> keys;
- for (auto const&
kv
: *hostprops)
- keys.push_back(k
v.first
);
+ for (auto const&
[key, _]
: *hostprops)
+ keys.push_back(k
ey
);
std::sort(keys.begin(), keys.end());
for (const std::string& key : keys)
XBT_INFO(" Host property: '%s' -> '%s'", key.c_str(), hostprops->at(key).c_str());
std::sort(keys.begin(), keys.end());
for (const std::string& key : keys)
XBT_INFO(" Host property: '%s' -> '%s'", key.c_str(), hostprops->at(key).c_str());
@@
-55,75
+56,75
@@
static void test_host(const std::string& hostname)
XBT_INFO("== Print the properties of the zone '%s' that contains '%s'", thezone->get_cname(), hostname.c_str());
const std::unordered_map<std::string, std::string>* zoneprops = thezone->get_properties();
keys.clear();
XBT_INFO("== Print the properties of the zone '%s' that contains '%s'", thezone->get_cname(), hostname.c_str());
const std::unordered_map<std::string, std::string>* zoneprops = thezone->get_properties();
keys.clear();
- for (auto const&
kv
: *zoneprops)
- keys.push_back(k
v.first
);
+ for (auto const&
[key, _]
: *zoneprops)
+ keys.push_back(k
ey
);
std::sort(keys.begin(), keys.end());
for (const std::string& key : keys)
XBT_INFO(" Zone property: '%s' -> '%s'", key.c_str(), zoneprops->at(key).c_str());
}
std::sort(keys.begin(), keys.end());
for (const std::string& key : keys)
XBT_INFO(" Zone property: '%s' -> '%s'", key.c_str(), zoneprops->at(key).c_str());
}
-static void alice(
std::vector<std::string> /*args*/
)
+static void alice()
{
/* Dump what we have on the current host */
test_host("host1");
}
{
/* Dump what we have on the current host */
test_host("host1");
}
-static void carole(
std::vector<std::string> /*args*/
)
+static void carole()
{
/* Dump what we have on a remote host */
{
/* Dump what we have on a remote host */
- s
imgrid::s4u
::this_actor::sleep_for(1); // Wait for alice to be done with its experiment
+ s
g4
::this_actor::sleep_for(1); // Wait for alice to be done with its experiment
test_host("host1");
}
test_host("host1");
}
-static void david(
std::vector<std::string> /*args*/
)
+static void david()
{
/* Dump what we have on a remote host */
{
/* Dump what we have on a remote host */
- s
imgrid::s4u
::this_actor::sleep_for(2); // Wait for alice and carole to be done with its experiment
+ s
g4
::this_actor::sleep_for(2); // Wait for alice and carole to be done with its experiment
test_host("node-0.simgrid.org");
}
test_host("node-0.simgrid.org");
}
-static void bob(
std::vector<std::string> /*args*/
)
+static void bob()
{
/* this host also tests the properties of the AS*/
{
/* this host also tests the properties of the AS*/
- const s
imgrid::s4u::NetZone* root = simgrid::s4u
::Engine::get_instance()->get_netzone_root();
+ const s
g4::NetZone* root = sg4
::Engine::get_instance()->get_netzone_root();
XBT_INFO("== Print the properties of the root zone");
XBT_INFO(" Zone property: filename -> %s", root->get_property("filename"));
XBT_INFO(" Zone property: date -> %s", root->get_property("date"));
XBT_INFO(" Zone property: author -> %s", root->get_property("author"));
/* Get the property list of current bob actor */
XBT_INFO("== Print the properties of the root zone");
XBT_INFO(" Zone property: filename -> %s", root->get_property("filename"));
XBT_INFO(" Zone property: date -> %s", root->get_property("date"));
XBT_INFO(" Zone property: author -> %s", root->get_property("author"));
/* Get the property list of current bob actor */
- const std::unordered_map<std::string, std::string>* props = s
imgrid::s4u
::Actor::self()->get_properties();
+ const std::unordered_map<std::string, std::string>* props = s
g4
::Actor::self()->get_properties();
const char* noexist = "UnknownProcessProp";
const char* noexist = "UnknownProcessProp";
- XBT_ATTRIB_UNUSED const char* value;
XBT_INFO("== Print the properties of the actor");
XBT_INFO("== Print the properties of the actor");
- for (const auto&
kv
: *props)
- XBT_INFO(" Actor property: %s -> %s", k
v.first.c_str(), kv.second
.c_str());
+ for (const auto&
[key, value]
: *props)
+ XBT_INFO(" Actor property: %s -> %s", k
ey.c_str(), value
.c_str());
XBT_INFO("== Try to get an actor property that does not exist");
XBT_INFO("== Try to get an actor property that does not exist");
-
value = simgrid::s4u
::Actor::self()->get_property(noexist);
+
const char* value = sg4
::Actor::self()->get_property(noexist);
xbt_assert(not value, "The property is defined (it should not)");
}
int main(int argc, char* argv[])
{
xbt_assert(not value, "The property is defined (it should not)");
}
int main(int argc, char* argv[])
{
- s
imgrid::s4u
::Engine e(&argc, argv);
+ s
g4
::Engine e(&argc, argv);
e.load_platform(argv[1]);
e.load_platform(argv[1]);
-
- e.register_function("alice", alice);
- e.register_function("bob", bob);
- e.register_function("carole", carole);
- e.register_function("david", david);
+ auto* host1 = e.host_by_name("host1");
+ auto* host2 = e.host_by_name("host2");
size_t totalHosts = e.get_host_count();
XBT_INFO("There are %zu hosts in the environment", totalHosts);
size_t totalHosts = e.get_host_count();
XBT_INFO("There are %zu hosts in the environment", totalHosts);
- std::vector<s
imgrid::s4u
::Host*> hosts = e.get_all_hosts();
- for (s
imgrid::s4u
::Host const* host : hosts)
+ std::vector<s
g4
::Host*> hosts = e.get_all_hosts();
+ for (s
g4
::Host const* host : hosts)
XBT_INFO("Host '%s' runs at %.0f flops/s", host->get_cname(), host->get_speed());
XBT_INFO("Host '%s' runs at %.0f flops/s", host->get_cname(), host->get_speed());
- e.load_deployment(argv[2]);
+ sg4::Actor::create("alice", host1, alice);
+ sg4::Actor::create("bob", host1, bob)->set_property("SomeProp", "SomeValue");
+ sg4::Actor::create("carole", host2, carole);
+ sg4::Actor::create("david", host2, david);
+
e.run();
return 0;
e.run();
return 0;