SimGrid  3.18
Versatile Simulation of Distributed Systems
simgrid::s4u::Engine Class Reference

Detailed Description

Simulation engine.

This class is an interface to the simulation engine.

Examples:
examples/s4u/actor-create/s4u-actor-create.cpp, examples/s4u/actor-daemon/s4u-actor-daemon.cpp, examples/s4u/actor-join/s4u-actor-join.cpp, examples/s4u/actor-kill/s4u-actor-kill.cpp, examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp, examples/s4u/actor-migration/s4u-actor-migration.cpp, examples/s4u/actor-suspend/s4u-actor-suspend.cpp, examples/s4u/actor-yield/s4u-actor-yield.cpp, examples/s4u/app-bittorrent/s4u-bittorrent.cpp, examples/s4u/app-chainsend/s4u-app-chainsend.cpp, examples/s4u/app-masterworker/s4u-app-masterworker.cpp, examples/s4u/app-pingpong/s4u-app-pingpong.cpp, examples/s4u/app-token-ring/s4u-app-token-ring.cpp, examples/s4u/async-wait/s4u-async-wait.cpp, examples/s4u/async-waitall/s4u-async-waitall.cpp, examples/s4u/async-waitany/s4u-async-waitany.cpp, examples/s4u/dht-chord/s4u-dht-chord.cpp, examples/s4u/energy-boot/s4u-energy-boot.cpp, examples/s4u/energy-exec/s4u-energy-exec.cpp, examples/s4u/energy-link/s4u-energy-link.cpp, examples/s4u/exec-async/s4u-exec-async.cpp, examples/s4u/exec-basic/s4u-exec-basic.cpp, examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp, examples/s4u/exec-monitor/s4u-exec-monitor.cpp, examples/s4u/exec-ptask/s4u-exec-ptask.cpp, examples/s4u/exec-remote/s4u-exec-remote.cpp, examples/s4u/io-file-remote/s4u-io-file-remote.cpp, examples/s4u/io-file-system/s4u-io-file-system.cpp, examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp, examples/s4u/mutex/s4u-mutex.cpp, examples/s4u/platform-properties/s4u-platform-properties.cpp, examples/s4u/replay-comm/s4u-replay-comm.cpp, examples/s4u/replay-storage/s4u-replay-storage.cpp, and examples/s4u/trace-platform/s4u-trace-platform.cpp.

#include <Engine.hpp>

Public Member Functions

 Engine (int *argc, char **argv)
 Constructor, taking the command line parameters of your main function. More...
 
 ~Engine ()
 
void loadPlatform (const char *platf)
 Load a platform file describing the environment. More...
 
void registerFunction (const char *name, int(*code)(int, char **))
 Registers the main function of an actor that will be launched from the deployment file. More...
 
void registerDefault (int(*code)(int, char **))
 Registers a function as the default main function of actors. More...
 
void loadDeployment (const char *deploy)
 Load a deployment file and launch the actors that it contains. More...
 
size_t getHostCount ()
 Returns the amount of hosts in the platform. More...
 
void getHostList (std::vector< Host *> *whereTo)
 Fills the passed list with all hosts found in the platform. More...
 
size_t getLinkCount ()
 Returns the amount of links in the platform. More...
 
void getLinkList (std::vector< Link *> *list)
 Fills the passed list with all hosts found in the platform. More...
 
void run ()
 Run the simulation. More...
 
simgrid::s4u::NetZonegetNetRoot ()
 Retrieve the root netzone, containing all others. More...
 
simgrid::s4u::NetZonegetNetzoneByNameOrNull (const char *name)
 Retrieve the netzone of the given name (or nullptr if not found) More...
 
simgrid::kernel::routing::NetPointgetNetpointByNameOrNull (std::string name)
 Retrieve the netcard of the given name (or nullptr if not found) More...
 
void getNetpointList (std::vector< simgrid::kernel::routing::NetPoint *> *list)
 Fill the provided vector with all existing netpoints. More...
 
void netpointRegister (simgrid::kernel::routing::NetPoint *card)
 Register a new netpoint to the system. More...
 
void netpointUnregister (simgrid::kernel::routing::NetPoint *card)
 Unregister a given netpoint. More...
 
template<class F >
void registerFunction (const char *name)
 
template<class F >
void registerFunction (const char *name, F code)
 
void setConfig (std::string str)
 set a configuration variable More...
 

Static Public Member Functions

static void shutdown ()
 Finalize the default engine and all its dependencies. More...
 
static double getClock ()
 Retrieve the simulation time. More...
 
static s4u::EnginegetInstance ()
 Retrieve the engine singleton. More...
 
static bool isInitialized ()
 Returns whether SimGrid was initialized yet – mostly for internal use. More...
 

Public Attributes

simgrid::kernel::EngineImplpimpl
 

Constructor & Destructor Documentation

◆ Engine()

simgrid::s4u::Engine::Engine ( int *  argc,
char **  argv 
)

Constructor, taking the command line parameters of your main function.

◆ ~Engine()

simgrid::s4u::Engine::~Engine ( )

Member Function Documentation

◆ shutdown()

void simgrid::s4u::Engine::shutdown ( )
static

Finalize the default engine and all its dependencies.

◆ loadPlatform()

void simgrid::s4u::Engine::loadPlatform ( const char *  platf)

Load a platform file describing the environment.

The environment is either a XML file following the simgrid.dtd formalism, or a lua file. Some examples can be found in the directory examples/platforms.

Examples:
examples/s4u/app-bittorrent/s4u-bittorrent.cpp, and examples/s4u/trace-platform/s4u-trace-platform.cpp.

◆ registerFunction() [1/3]

void simgrid::s4u::Engine::registerFunction ( const char *  name,
int(*)(int, char **)  code 
)

Registers the main function of an actor that will be launched from the deployment file.

Examples:
examples/s4u/app-bittorrent/s4u-bittorrent.cpp.

◆ registerDefault()

void simgrid::s4u::Engine::registerDefault ( int(*)(int, char **)  code)

Registers a function as the default main function of actors.

It will be used as fallback when the function requested from the deployment file was not registered. It is used for trace-based simulations (see examples/msg/actions).

◆ loadDeployment()

void simgrid::s4u::Engine::loadDeployment ( const char *  deploy)

Load a deployment file and launch the actors that it contains.

Examples:
examples/s4u/app-bittorrent/s4u-bittorrent.cpp.

◆ getHostCount()

size_t simgrid::s4u::Engine::getHostCount ( )

Returns the amount of hosts in the platform.

◆ getHostList()

void simgrid::s4u::Engine::getHostList ( std::vector< Host *> *  whereTo)

Fills the passed list with all hosts found in the platform.

Examples:
examples/s4u/app-bittorrent/s4u-bittorrent.cpp, and examples/s4u/dht-chord/s4u-dht-chord.cpp.

◆ getLinkCount()

size_t simgrid::s4u::Engine::getLinkCount ( )

Returns the amount of links in the platform.

◆ getLinkList()

void simgrid::s4u::Engine::getLinkList ( std::vector< Link *> *  list)

Fills the passed list with all hosts found in the platform.

◆ run()

void simgrid::s4u::Engine::run ( )

◆ getClock()

◆ getInstance()

◆ getNetRoot()

s4u::NetZone * simgrid::s4u::Engine::getNetRoot ( )

Retrieve the root netzone, containing all others.

Examples:
examples/s4u/platform-properties/s4u-platform-properties.cpp.

◆ getNetzoneByNameOrNull()

NetZone * simgrid::s4u::Engine::getNetzoneByNameOrNull ( const char *  name)

Retrieve the netzone of the given name (or nullptr if not found)

Retrieve the NetZone of the given name (or nullptr if not found)

◆ getNetpointByNameOrNull()

simgrid::kernel::routing::NetPoint * simgrid::s4u::Engine::getNetpointByNameOrNull ( std::string  name)

Retrieve the netcard of the given name (or nullptr if not found)

Retrieve the netpoint of the given name (or nullptr if not found)

◆ getNetpointList()

void simgrid::s4u::Engine::getNetpointList ( std::vector< simgrid::kernel::routing::NetPoint *> *  list)

Fill the provided vector with all existing netpoints.

◆ netpointRegister()

void simgrid::s4u::Engine::netpointRegister ( simgrid::kernel::routing::NetPoint card)

Register a new netpoint to the system.

◆ netpointUnregister()

void simgrid::s4u::Engine::netpointUnregister ( simgrid::kernel::routing::NetPoint card)

Unregister a given netpoint.

◆ registerFunction() [2/3]

template<class F >
void simgrid::s4u::Engine::registerFunction ( const char *  name)
inline

◆ registerFunction() [3/3]

template<class F >
void simgrid::s4u::Engine::registerFunction ( const char *  name,
code 
)
inline

◆ isInitialized()

bool simgrid::s4u::Engine::isInitialized ( )
static

Returns whether SimGrid was initialized yet – mostly for internal use.

◆ setConfig()

void simgrid::s4u::Engine::setConfig ( std::string  str)

set a configuration variable

Do –help on any simgrid binary to see the list of currently existing configuration variables (see Configure SimGrid).

Example: e->setConfig("host/model","ptask_L07");

Member Data Documentation

◆ pimpl

simgrid::kernel::EngineImpl* simgrid::s4u::Engine::pimpl

The documentation for this class was generated from the following files: