- .def("load_platform", &Engine::load_platform,
- "Load a platform file describing the environment, see :cpp:func:`simgrid::s4u::Engine::load_platform()`")
- .def("load_deployment", &Engine::load_deployment,
- "Load a deployment file and launch the actors that it contains, see "
- ":cpp:func:`simgrid::s4u::Engine::load_deployment()`")
- .def("run", &Engine::run, "Run the simulation")
- .def("register_actor",
- [](Engine* e, const std::string& name, py::object fun_or_class) {
- e->register_actor(name, [fun_or_class](std::vector<std::string> args) {
- try {
- /* Convert the std::vector into a py::tuple */
- py::tuple params(args.size() - 1);
- for (size_t i = 1; i < args.size(); i++)
- params[i - 1] = py::cast(args[i]);
-
- py::object res = fun_or_class(*params);
-
- /* If I was passed a class, I just built an instance, so I need to call it now */
- if (py::isinstance<py::function>(res))
- res();
- } catch (const py::error_already_set& ex) {
- if (ex.matches(pyForcefulKillEx)) {
- XBT_VERB("Actor killed");
- /* Stop here that ForcefulKill exception which was meant to free the RAII stuff on the stack */
- } else {
- throw;
- }
- }
- });
- },
- "Registers the main function of an actor, see :cpp:func:`simgrid::s4u::Engine::register_actor()`");
+ .def("load_platform", &Engine::load_platform, "Load a platform file describing the environment")
+ .def("load_deployment", &Engine::load_deployment, "Load a deployment file and launch the actors that it contains")
+ .def("run", &Engine::run, py::call_guard<GilScopedRelease>(), "Run the simulation")
+ .def(
+ "register_actor",
+ [](Engine* e, const std::string& name, py::object fun_or_class) {
+ e->register_actor(name, [fun_or_class](std::vector<std::string> args) {
+ GilScopedAcquire py_context;
+ try {
+ /* Convert the std::vector into a py::tuple */
+ py::tuple params(args.size() - 1);
+ for (size_t i = 1; i < args.size(); i++)
+ params[i - 1] = py::cast(args[i]);
+
+ py::object res = fun_or_class(*params);
+ /* If I was passed a class, I just built an instance, so I need to call it now */
+ if (py::isinstance<py::function>(res))
+ res();
+ } catch (const py::error_already_set& ex) {
+ bool ffk = ex.matches(pyForcefulKillEx);
+ py_context.reset();
+ if (ffk) {
+ XBT_VERB("Actor killed");
+ simgrid::ForcefulKillException::do_throw(); // Forward that ForcefulKill exception
+ }
+ throw;
+ }
+ });
+ },
+ "Registers the main function of an actor");
+
+ /* Class Netzone */
+ py::class_<simgrid::s4u::NetZone, std::unique_ptr<simgrid::s4u::NetZone, py::nodelete>> netzone(m, "NetZone",
+ "Networking Zones");
+ netzone.def_static("create_full_zone", &simgrid::s4u::create_full_zone, "Creates a zone of type FullZone")
+ .def_static("create_torus_zone", &simgrid::s4u::create_torus_zone, "Creates a cluster of type Torus")
+ .def_static("create_fatTree_zone", &simgrid::s4u::create_fatTree_zone, "Creates a cluster of type Fat-Tree")
+ .def_static("create_dragonfly_zone", &simgrid::s4u::create_dragonfly_zone, "Creates a cluster of type Dragonfly")
+ .def_static("create_star_zone", &simgrid::s4u::create_star_zone, "Creates a zone of type Star")
+ .def_static("create_floyd_zone", &simgrid::s4u::create_floyd_zone, "Creates a zone of type Floyd")
+ .def_static("create_dijkstra_zone", &simgrid::s4u::create_floyd_zone, "Creates a zone of type Dijkstra")
+ .def_static("create_vivaldi_zone", &simgrid::s4u::create_vivaldi_zone, "Creates a zone of type Vivaldi")
+ .def_static("create_empty_zone", &simgrid::s4u::create_empty_zone, "Creates a zone of type Empty")
+ .def_static("create_wifi_zone", &simgrid::s4u::create_wifi_zone, "Creates a zone of type Wi-Fi")
+ .def("add_route",
+ py::overload_cast<simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*,
+ simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*,
+ const std::vector<simgrid::s4u::LinkInRoute>&, bool>(&simgrid::s4u::NetZone::add_route),
+ "Add a route between 2 netpoints")
+ .def("create_host", py::overload_cast<const std::string&, double>(&simgrid::s4u::NetZone::create_host),
+ "Creates a host")
+ .def("create_host",
+ py::overload_cast<const std::string&, const std::string&>(&simgrid::s4u::NetZone::create_host),
+ "Creates a host")
+ .def("create_host",
+ py::overload_cast<const std::string&, const std::vector<double>&>(&simgrid::s4u::NetZone::create_host),
+ "Creates a host")
+ .def("create_host",
+ py::overload_cast<const std::string&, const std::vector<std::string>&>(&simgrid::s4u::NetZone::create_host),
+ "Creates a host")
+ .def("create_link", py::overload_cast<const std::string&, double>(&simgrid::s4u::NetZone::create_link),
+ "Creates a network link")
+ .def("create_link",
+ py::overload_cast<const std::string&, const std::string&>(&simgrid::s4u::NetZone::create_link),
+ "Creates a network link")
+ .def("create_link",
+ py::overload_cast<const std::string&, const std::vector<double>&>(&simgrid::s4u::NetZone::create_link),
+ "Creates a network link")
+ .def("create_link",
+ py::overload_cast<const std::string&, const std::vector<std::string>&>(&simgrid::s4u::NetZone::create_link),
+ "Creates a network link")
+ .def("create_split_duplex_link",
+ py::overload_cast<const std::string&, double>(&simgrid::s4u::NetZone::create_split_duplex_link),
+ "Creates a split-duplex link")
+ .def("create_split_duplex_link",
+ py::overload_cast<const std::string&, const std::string&>(&simgrid::s4u::NetZone::create_split_duplex_link),
+ "Creates a split-duplex link")
+ .def("create_router", &simgrid::s4u::NetZone::create_router, "Create a router")
+ .def("set_parent", &simgrid::s4u::NetZone::set_parent, "Set the parent of this zone")
+ .def("set_property", &simgrid::s4u::NetZone::set_property, "Add a property to this zone")
+ .def("get_netpoint", &simgrid::s4u::NetZone::get_netpoint, "Retrieve the netpoint associated to this zone")
+ .def("seal", &simgrid::s4u::NetZone::seal, "Seal this NetZone")
+ .def_property_readonly(
+ "name", [](const simgrid::s4u::NetZone* self) { return self->get_name(); }, "The name of this network zone");
+
+ /* Class ClusterCallbacks */
+ py::class_<simgrid::s4u::ClusterCallbacks>(m, "ClusterCallbacks", "Callbacks used to create cluster zones")
+ .def(py::init<const std::function<simgrid::s4u::ClusterCallbacks::ClusterNetPointCb>&,
+ const std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb>&,
+ const std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb>&>());
+
+ /* Class FatTreeParams */
+ py::class_<simgrid::s4u::FatTreeParams>(m, "FatTreeParams", "Parameters to create a Fat-Tree zone")
+ .def(py::init<unsigned int, const std::vector<unsigned int>&, const std::vector<unsigned int>&,
+ const std::vector<unsigned int>&>());
+
+ /* Class DragonflyParams */
+ py::class_<simgrid::s4u::DragonflyParams>(m, "DragonflyParams", "Parameters to create a Dragonfly zone")
+ .def(py::init<const std::pair<unsigned int, unsigned int>&, const std::pair<unsigned int, unsigned int>&,
+ const std::pair<unsigned int, unsigned int>&, unsigned int>());