mutex
platform-properties plugin-hostload
replay-comm replay-storage
+ routing-get-clusters
trace-platform)
add_executable (s4u-${example} ${example}/s4u-${example}.cpp)
target_link_libraries(s4u-${example} simgrid)
exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote
platform-properties plugin-hostload mutex
io-file-system io-file-remote io-storage-raw
- replay-comm replay-storage)
+ replay-comm replay-storage
+ routing-get-clusters
+ )
ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost"
--setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
--setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
--- /dev/null
+/* Copyright (c) 2009-2017. 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. */
+
+#include "simgrid/s4u.hpp"
+#include "src/kernel/routing/ClusterZone.hpp"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ e.loadPlatform(argv[1]);
+
+ std::vector<simgrid::kernel::routing::ClusterZone*>* clusters =
+ new std::vector<simgrid::kernel::routing::ClusterZone*>;
+
+ e.getNetzoneByType<simgrid::kernel::routing::ClusterZone>(clusters);
+
+ for (auto c : *clusters) {
+ XBT_INFO("%s", c->getCname());
+ std::vector<simgrid::s4u::Host*>* hosts = new std::vector<simgrid::s4u::Host*>;
+ c->getHosts(hosts);
+ for (auto h : *hosts)
+ XBT_INFO(" %s", h->getCname());
+ delete hosts;
+ }
+
+ delete clusters;
+
+ return 0;
+}
--- /dev/null
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-routing-get-clusters$EXEEXT ${platfdir}/cluster_backbone.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n"
+> [ 0.000000] (maestro@) simple
+> [ 0.000000] (maestro@) node-0.1core.org
+> [ 0.000000] (maestro@) node-1.1core.org
+> [ 0.000000] (maestro@) node-2.1core.org
+> [ 0.000000] (maestro@) node-3.1core.org
+> [ 0.000000] (maestro@) node-4.1core.org
+> [ 0.000000] (maestro@) node-5.1core.org
+> [ 0.000000] (maestro@) node-6.1core.org
+> [ 0.000000] (maestro@) node-7.1core.org
+> [ 0.000000] (maestro@) backboned
+> [ 0.000000] (maestro@) node-0.2cores.org
+> [ 0.000000] (maestro@) node-1.2cores.org
+> [ 0.000000] (maestro@) node-2.2cores.org
+> [ 0.000000] (maestro@) node-3.2cores.org
+> [ 0.000000] (maestro@) node-4.2cores.org
+> [ 0.000000] (maestro@) node-5.2cores.org
+> [ 0.000000] (maestro@) node-6.2cores.org
+> [ 0.000000] (maestro@) node-7.2cores.org
+> [ 0.000000] (maestro@) halfduplex
+> [ 0.000000] (maestro@) node-0.4cores.org
+> [ 0.000000] (maestro@) node-1.4cores.org
+> [ 0.000000] (maestro@) node-2.4cores.org
+> [ 0.000000] (maestro@) node-3.4cores.org
+> [ 0.000000] (maestro@) node-4.4cores.org
+> [ 0.000000] (maestro@) node-5.4cores.org
+> [ 0.000000] (maestro@) node-6.4cores.org
+> [ 0.000000] (maestro@) node-7.4cores.org
#include <simgrid/simix.hpp>
+#include <simgrid/s4u/NetZone.hpp>
#include <simgrid/s4u/forward.hpp>
namespace simgrid {
simgrid::s4u::NetZone* getNetzoneByNameOrNull(const char* name);
/** @brief Retrieves all netzones of the same type than the subtype of the whereto vector */
- template <class T> void getNetzoneByType(std::vector<T*> * whereto);
-
+ template <class T> void getNetzoneByType(std::vector<T*> * whereto) { netzoneByTypeRecursive(getNetRoot(), whereto); }
/** @brief Retrieve the netcard of the given name (or nullptr if not found) */
simgrid::kernel::routing::NetPoint* getNetpointByNameOrNull(std::string name);
void getNetpointList(std::vector<simgrid::kernel::routing::NetPoint*> * list);
/** Callback fired when the time cannot jump because of inter-actors deadlock */
extern XBT_PUBLIC(xbt::signal<void(void)>) onDeadlock;
+
+template <class T> XBT_PRIVATE void netzoneByTypeRecursive(s4u::NetZone* current, std::vector<T*>* whereto)
+{
+ for (auto const& elem : *(current->getChildren())) {
+ netzoneByTypeRecursive(elem, whereto);
+ if (elem == dynamic_cast<T*>(elem))
+ whereto->push_back(dynamic_cast<T*>(elem));
+ }
+}
}
} // namespace simgrid::s4u
* (because the private router is directly connected to the cluster core).
*/
-class XBT_PRIVATE ClusterZone : public NetZoneImpl {
+class ClusterZone : public NetZoneImpl {
public:
explicit ClusterZone(NetZone* father, std::string name);
Engine *Engine::instance_ = nullptr; /* That singleton is awful, but I don't see no other solution right now. */
-
Engine::Engine(int *argc, char **argv) {
xbt_assert(s4u::Engine::instance_ == nullptr, "It is currently forbidden to create more than one instance of s4u::Engine");
TRACE_global_init();
return netzoneByNameRecursive(getNetRoot(), name);
}
-template <class T> void netzoneByTypeRecursive(s4u::NetZone* current, std::vector<T*>* whereto)
-{
- for (auto const& elem : *(current->getChildren())) {
- netzoneByTypeRecursive(elem, whereto);
- if (elem == dynamic_cast<T*>(elem))
- whereto->push_back(elem);
- }
-}
-
-/** @brief Retrieve all existing NetZones of the subtype of the whereto vector */
-template <class T> void Engine::getNetzoneByType(std::vector<T*>* whereto)
-{
- netzoneByTypeRecursive(getNetRoot(), whereto);
-}
-
/** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
simgrid::kernel::routing::NetPoint* Engine::getNetpointByNameOrNull(std::string name)
{