#! tesh
-! output sort 19
-
$ java -classpath ${classpath:=.} app/masterworker/Main ${srcdir:=.}/../platforms/small_platform.xml ${srcdir:=.}/app/masterworker/masterworker.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (0:maestro@) Using regular java threads.
> [ 0.000000] (1:app.masterworker.Master@Jacquelin) Hello! Got 7 workers and 5 tasks to process
> [ 1.752187] (3:app.masterworker.Worker@Fafard) Received "Task_1". Processing it.
> [ 1.757531] (4:app.masterworker.Worker@Bourassa) Received "Task_2". Processing it.
> [ 2.806417] (5:app.masterworker.Worker@Boivin) Received "Task_3". Processing it.
-> [ 2.811761] (1:app.masterworker.Master@Jacquelin) All tasks have been dispatched. Let's tell everybody the computation is over.
> [ 2.811761] (6:app.masterworker.Worker@Ginette) Received "Task_4". Processing it.
+> [ 2.811761] (1:app.masterworker.Master@Jacquelin) All tasks have been dispatched. Let's tell everybody the computation is over.
> [ 3.671783] (2:app.masterworker.Worker@Tremblay) Received Finalize. I'm done. See you!
> [ 4.563940] (3:app.masterworker.Worker@Fafard) Received Finalize. I'm done. See you!
> [ 4.569280] (4:app.masterworker.Worker@Bourassa) Received Finalize. I'm done. See you!
> [ 5.618161] (5:app.masterworker.Worker@Boivin) Received Finalize. I'm done. See you!
> [ 5.623501] (6:app.masterworker.Worker@Ginette) Received Finalize. I'm done. See you!
> [ 5.628842] (7:app.masterworker.Worker@Jupiter) Received Finalize. I'm done. See you!
-> [ 5.629037] (0:maestro@) MSG_main finished; Cleaning up the simulation...
-> [ 5.629037] (1:app.masterworker.Master@Jacquelin) Goodbye now!
> [ 5.629037] (8:app.masterworker.Worker@Jacquelin) Received Finalize. I'm done. See you!
+> [ 5.629037] (1:app.masterworker.Master@Jacquelin) Goodbye now!
+> [ 5.629037] (0:maestro@) MSG_main finished; Cleaning up the simulation...
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/EngineImpl.hpp"
+#include "src/kernel/routing/NetCard.hpp"
#include "src/kernel/routing/NetZoneImpl.hpp"
#include <simgrid/s4u/host.hpp>
+xbt_dict_t netcards_dict;
+
namespace simgrid {
namespace kernel {
EngineImpl::EngineImpl()
{
+ netcards_dict = xbt_dict_new_homogeneous([](void* p) {
+ delete static_cast<simgrid::kernel::routing::NetCard*>(p);
+ });
}
EngineImpl::~EngineImpl()
{
delete netRoot_;
+ xbt_dict_free(&netcards_dict);
}
}
}
namespace routing {
simgrid::xbt::signal<void(NetCard*)> NetCard::onCreation;
+
+NetCard::NetCard(std::string name, NetCard::Type componentType, NetZoneImpl* netzone_p)
+ : name_(name), componentType_(componentType), netzone_(netzone_p)
+{
+ if (netzone_p != nullptr)
+ id_ = netzone_p->addComponent(this);
+ xbt_dict_set(netcards_dict, name.c_str(), static_cast<void*>(this), nullptr);
+ simgrid::kernel::routing::NetCard::onCreation(this);
+}
}
}
} // namespace simgrid::kernel::routing
*/
simgrid::kernel::routing::NetCard* sg_netcard_by_name_or_null(const char* name)
{
- sg_host_t host = sg_host_by_name(name);
- return (host != nullptr) ? host->pimpl_netcard : simgrid::s4u::Engine::instance()->netcardByNameOrNull(name);
+ return simgrid::s4u::Engine::instance()->netcardByNameOrNull(name);
}
public:
enum class Type { Host, Router, NetZone };
- NetCard(std::string name, NetCard::Type componentType, NetZoneImpl* netzone_p)
- : name_(name), componentType_(componentType), netzone_(netzone_p)
- {
- if (netzone_p != nullptr)
- id_ = netzone_p->addComponent(this);
- simgrid::kernel::routing::NetCard::onCreation(this);
- }
+ NetCard(std::string name, NetCard::Type componentType, NetZoneImpl* netzone_p);
~NetCard() = default;
// Our rank in the vertices_ array of our containing AS.
"Refusing to create a second NetZone called '%s'.", name);
netcard_ = new NetCard(name, NetCard::Type::NetZone, static_cast<NetZoneImpl*>(father));
- xbt_dict_set(netcards_dict, name, static_cast<void*>(netcard_), nullptr);
XBT_DEBUG("NetZone '%s' created with the id '%d'", name, netcard_->id());
}
NetZoneImpl::~NetZoneImpl()
{
for (auto& kv : bypassRoutes_)
delete kv.second;
+
+ xbt_dict_remove(netcards_dict, name_);
}
simgrid::s4u::Host* NetZoneImpl::createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount)
xbt_assert(currentlyDestroying_, "Please call h->destroy() instead of manually deleting it.");
delete pimpl_;
+ if (pimpl_netcard != nullptr) // not removed yet by a children class
+ xbt_dict_remove(netcards_dict, name_.c_str());
delete pimpl_cpu;
- delete pimpl_netcard;
delete mounts;
}
simgrid::kernel::routing::NetCard* netcard =
new simgrid::kernel::routing::NetCard(router->id, simgrid::kernel::routing::NetCard::Type::Router, current_routing);
- xbt_dict_set(netcards_dict, router->id, netcard, nullptr);
XBT_DEBUG("Router '%s' has the id %d", router->id, netcard->id());
if (router->coord && strcmp(router->coord, ""))
auto cluster = dynamic_cast<simgrid::kernel::routing::ClusterZone*>(current_routing);
if(cluster != nullptr)
- cluster->router_ = static_cast<simgrid::kernel::routing::NetCard*>(xbt_dict_get_or_null(netcards_dict, router->id));
+ cluster->router_ = simgrid::s4u::Engine::instance()->netcardByNameOrNull(router->id);
if (TRACE_is_enabled() && TRACE_needs_platform())
sg_instr_new_router(router);
XBT_DEBUG("Create all Libs");
USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr);
- netcards_dict = xbt_dict_new_homogeneous([](void* p) {
- delete static_cast<simgrid::kernel::routing::NetCard*>(p);
- });
storage_lib = xbt_lib_new();
storage_type_lib = xbt_lib_new();
file_lib = xbt_lib_new();
xbt_dynar_free(&surf_path);
sg_host_exit();
- xbt_dict_free(&netcards_dict);
xbt_lib_free(&storage_lib);
sg_link_exit();
xbt_lib_free(&storage_type_lib);
#include "xbt/dict.h"
-xbt_dict_t netcards_dict;
SD_create_environment(argv[1]);
xbt_dynar_t hosts = sg_hosts_as_dynar();
- int size = sg_host_count() + xbt_dict_length(netcards_dict);
-
- printf("Host number: %zu, link number: %d, elmts number: %d\n", sg_host_count(), sg_link_count(), size);
+ printf("Host count: %zu, link number: %d\n", sg_host_count(), sg_link_count());
int it;
sg_host_t host;
}
xbt_dynar_free(&hosts);
+ printf("NetCards count: %d\n", xbt_dict_length(netcards_dict));
xbt_lib_cursor_t cursor = nullptr;
char* key;
void *ignored;
#! ./tesh
-! output sort
+
$ ${bindir:=.}/is-router ../platforms/test_of_is_router.xml "--log=root.fmt:[%10.6r]%e[%i:%P@%h]%e%m%n"
> [ 0.000000] [0:maestro@] Switching to the L07 model to handle parallel tasks.
-> Host number: 10, link number: 1, elmts number: 21
+> Host count: 10, link number: 1
> - Seen: "host01". Type: host
> - Seen: "host02". Type: host
> - Seen: "host03". Type: host
> - Seen: "host08". Type: host
> - Seen: "host09". Type: host
> - Seen: "host10". Type: host
+> NetCards count: 21
+> - Seen: "host01". Type: host
+> - Seen: "host02". Type: host
+> - Seen: "host03". Type: host
+> - Seen: "host04". Type: host
+> - Seen: "host05". Type: host
+> - Seen: "host06". Type: host
+> - Seen: "host07". Type: host
+> - Seen: "host08". Type: host
+> - Seen: "host09". Type: host
> - Seen: "router1". Type: router
> - Seen: "router2". Type: router
> - Seen: "router3". Type: router
> - Seen: "router4". Type: router
> - Seen: "router5". Type: router
+> - Seen: "host10". Type: host
> - Seen: "AS0". Type: netzone
> - Seen: "AS1". Type: netzone
> - Seen: "AS2". Type: netzone