wrench::Simulation

class Simulation

A class that provides basic simulation methods. Once the simulation object has been explicitly or implicitly destroyed, then any call to the WRENCH APIs has undefied behavior (due to memory_manager_service being de-allocated).

Public Functions

~Simulation()

Destructor.

template<class T>
inline std::shared_ptr<T> add(std::shared_ptr<T> t)

Method to add a service to the simulation.

Template Parameters:

T – The service class (base class is Service)

Parameters:

t – the service object (shared ptr)

Returns:

a shared_ptr to the service object

template<class T>
inline std::shared_ptr<T> add(T *t)

Method to add a service to the simulation.

Template Parameters:

T – The service class (base class is Service)

Parameters:

t – the service object

Returns:

a shared_ptr to the service object

double getEnergyConsumed(const std::string &hostname)

Obtains the current energy consumption of a host.

Parameters:

hostname – the host name

Throws:

std::invalid_argument

Returns:

current energy consumption in joules

std::map<std::string, double> getEnergyConsumed(const std::vector<std::string> &hostnames)

Obtains the current energy consumption of a host.

Parameters:

hostnames – the list of hostnames

Throws:

std::invalid_argument

Returns:

current energy consumption in joules for each host, as a map indexed by hostnames

SimulationOutput &getOutput()

Get the simulation output object.

Returns:

simulation output object

void init(int*, char**)

Initialize the simulation, which parses out WRENCH-specific and SimGrid-specific command-line arguments, if any.

Parameters:
  • argc – main()’s argument count

  • argv – main()’s argument list

Throws:

std::invalid_argument

void instantiatePlatform(const std::function<void()>&)

Instantiate a simulated platform.

Parameters:

creation_function – void() function to create the platform

void instantiatePlatform(const std::string&)

Instantiate a simulated platform.

Parameters:

filename – the path to a SimGrid XML platform description file

Throws:

std::runtime_error

void instantiatePlatformFromString(const std::string &platform)

Instantiate a simulated platform.

Parameters:

platform – the string representation of a SimGrid XML platform description

Throws:

std::runtime_error

void launch()

Launch the simulation.

Throws:

std::runtime_error

inline void stageFile(const std::shared_ptr<DataFile> file, const std::shared_ptr<StorageService> &storage_service)

Creates a file copy on a storage service before the simulation begins.

Parameters:
  • file – a file

  • storage_service – a storage service

inline void stageFile(const std::shared_ptr<DataFile> file, const std::shared_ptr<StorageService> &storage_service, const std::string &path)

@brief Creates a file copy on a storage service before the simulation begins
@param file: a file
@param storage_service: a storage service

Parameters:

path – a path

void stageFile(const std::shared_ptr<FileLocation> &location)

Stage a copy of a file at a location (and add entries to all file registry services, if any)

Parameters:

location – the file location

Public Static Functions

static std::shared_ptr<DataFile> addFile(const std::string&, double)

Add a new file to the simulation (use at your own peril if you’re using the workflow API - use Workflow::addFile() instead)

Parameters:
  • id – a unique string id

  • size – a file size in bytes

Throws:

std::invalid_argument

Returns:

the DataFile instance

static std::shared_ptr<Simulation> createSimulation()

Create a simulation.

Returns:

a simulation

static std::shared_ptr<DataFile> getFileByID(const std::string &id)

Find a DataFile based on its ID.

Parameters:

id – a string id

Throws:

std::invalid_argument

Returns:

the DataFile instance (or throws a std::invalid_argument if not found)

static std::map<std::string, std::shared_ptr<DataFile>> &getFileMap()

Get the list of all files in the simulation.

Returns:

a reference to the map of files in the simulation, indexed by file ID

static double getHostFlopRate(const std::string &hostname)

Get the flop rate of one core of a host given a hostname.

Parameters:

hostname – the hostname

Returns:

a flop rate (flop / sec)

static double getHostMemoryCapacity(const std::string &hostname)

Get the memory_manager_service capacity of a host given a hostname.

Parameters:

hostname – the hostname

Returns:

a memory_manager_service capacity in bytes

static std::vector<std::string> getHostnameList()

Get the list of names of all the physical hosts in the platform.

Returns:

a vector of hostnames

static std::map<std::string, std::vector<std::string>> getHostnameListByCluster()

**

Get the list of names of all the hosts in each cluster composing the platform

Returns:

a map of lists of hosts, indexed by cluster name

static unsigned long getHostNumCores(const std::string &hostname)

Get the number of cores of a host given a hostname.

Parameters:

hostname – the hostname

Returns:

a number of cores

static std::vector<int> getListOfPstates(const std::string &hostname)

Get the list of power states available for a host.

Parameters:

hostname – the host name

Returns:

a list of power states available for the host (as specified in the platform xml description file)

static double getMaxPowerConsumption(const std::string &hostname)

Get the maximum power consumption for the host (i.e., 100% utilization) at its current pstate.

Parameters:

hostname – the host name

Returns:

The “100% used” power consumption (as specified in the platform xml description file)

static double getMinPowerConsumption(const std::string &hostname)

Get the minimum power consumption for the host (i.e., idling) at its current pstate.

Parameters:

hostname – the host name

Returns:

The “idling” power consumption (as specified in the platform xml description file)

static int getNumberofPstates(const std::string &hostname)

Get the total number of power states of a host.

Parameters:

hostname – the host name

Returns:

The number of power states available for the host (as specified in the platform xml description file)

static bool hostHasMountPoint(const std::string &hostname, const std::string &scratch_space_mount_point)

Determine if a host has a disk mounted at some mount point.

Parameters:
  • hostname – the hostname

  • mount_point – the mount point

Returns:

true or false

static bool isInitialized()

Determine if the simulation has been initialized.

Returns:

true or false

static void removeAllFiles()

Remove all files from the simulation (use at your own peril if you’re using the workflow API)

static void removeFile(const std::shared_ptr<DataFile> &file)

Remove a file from the simulation (use at your own peril if you’re using the workflow API - use Workflow::removeFile() instead)

Parameters:

file – : file to remove