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). More...

#include <Simulation.h>

Public Member Functions

 Simulation ()
 Constructor.
 
 ~Simulation ()
 Destructor.
 
template<class T >
std::shared_ptr< T > add (T *t)
 Method to add a service to the simulation. More...
 
double getEnergyConsumed (const std::string &hostname)
 Obtains the current energy consumption of a host. More...
 
double getEnergyConsumed (const std::string &hostname, bool record_as_time_stamp)
 Obtains the current energy consumption of a host and will add SimulationTimestampEnergyConsumption to simulation output if can_record is set to true. More...
 
std::map< std::string, double > getEnergyConsumed (const std::vector< std::string > &hostnames)
 Obtains the current energy consumption of a host. More...
 
std::map< std::string, double > getEnergyConsumed (const std::vector< std::string > &hostnames, bool record_as_time_stamps)
 Obtains the current energy consumption of a host and will add SimulationTimestampEnergyConsumption to simulation output if can_record is set to true. More...
 
double getLinkUsage (const std::string &link_name, bool record_as_time_stamp)
 Obtains the current link bandwidth usage on a link and will add SimulationTimestampLinkUsage to simulation output if record_as_time_stamp is set to true. More...
 
MemoryManagergetMemoryManagerByHost (std::string hostname)
 Find MemoryManager running on a host based on hostname. More...
 
SimulationOutputgetOutput ()
 Get the simulation output object. More...
 
void init (int *, char **)
 Initialize the simulation, which parses out WRENCH-specific and SimGrid-specific command-line arguments, if any. More...
 
void instantiatePlatform (std::string)
 Instantiate a simulated platform. More...
 
void launch ()
 Launch the simulation. More...
 
void readFromDisk (double num_bytes, std::string hostname, std::string mount_point)
 Wrapper enabling timestamps for disk reads. More...
 
void readFromDiskAndWriteToDiskConcurrently (double num_bytes_to_read, double num_bytes_to_write, std::string hostname, std::string read_mount_point, std::string write_mount_point)
 Wrapper enabling timestamps for concurrent disk read/writes. More...
 
void readWithMemoryCache (WorkflowFile *file, double n_bytes, std::shared_ptr< FileLocation > location)
 Read file locally, only available if writeback is activated. More...
 
void setPstate (const std::string &hostname, int pstate)
 Set the power state of the host. More...
 
void stageFile (WorkflowFile *file, std::shared_ptr< StorageService > ss)
 Stage a copy of a file at a storage service in the root of the (unique) mount point. More...
 
void stageFile (WorkflowFile *file, std::shared_ptr< StorageService > ss, std::string directory_absolute_path)
 Stage a copy of a file at a storage service in a particular directory. More...
 
std::shared_ptr< ComputeServicestartNewService (ComputeService *service)
 Starts a new compute service during WMS execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor. More...
 
std::shared_ptr< FileRegistryServicestartNewService (FileRegistryService *service)
 Starts a new file registry service during WMS execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor. More...
 
std::shared_ptr< MemoryManagerstartNewService (MemoryManager *service)
 Starts a new memory_manager_service manager service during execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor. More...
 
std::shared_ptr< NetworkProximityServicestartNewService (NetworkProximityService *service)
 Starts a new network proximity service during WMS execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor. More...
 
std::shared_ptr< StorageServicestartNewService (StorageService *service)
 Starts a new storage service during WMS execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor. More...
 
void writebackWithMemoryCache (WorkflowFile *file, double n_bytes, std::shared_ptr< FileLocation > location, bool is_dirty)
 Write a file locally with writeback strategy, only available if writeback is activated. More...
 
void writeThroughWithMemoryCache (WorkflowFile *file, double n_bytes, std::shared_ptr< FileLocation > location)
 Write-through a file locally, only available if writeback is activated. More...
 
void writeToDisk (double num_bytes, std::string hostname, std::string mount_point)
 Wrapper enabling timestamps for disk writes. More...
 

Static Public Member Functions

static void compute (double flops)
 Make the calling process compute. More...
 
static bool doesHostExist (std::string hostname)
 Wrapper for S4U_Simulation hostExists() More...
 
static bool doesLinkExist (std::string linkname)
 Wrapper for S4U_Simulation linkExists() More...
 
static int getCurrentPstate (const std::string &hostname)
 Get the current power state of a host. More...
 
static double getCurrentSimulatedDate ()
 Get the current simulated date. More...
 
static double getFlopRate ()
 Get the flop rate of one core of the host on which the calling process is running. More...
 
static double getHostFlopRate (std::string hostname)
 Get the flop rate of one core of a host given a hostname. More...
 
static double getHostMemoryCapacity (std::string hostname)
 Get the memory_manager_service capacity of a host given a hostname. More...
 
static std::string getHostName ()
 Get the name of the host on which the calling process is running. More...
 
static std::vector< std::string > getHostnameList ()
 Get the list of names of all the hosts in the platform. More...
 
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. More...
 
static unsigned long getHostNumCores (std::string hostname)
 Get the number of cores of a host given a hostname. More...
 
static double getLinkBandwidth (std::string linkname)
 Get the max bandwidth of a particular link. More...
 
static std::vector< std::string > getLinknameList ()
 Get the list of names of all the links in the platform. More...
 
static double getLinkUsage (std::string linkname)
 Get the current usage of a particular link. More...
 
static std::vector< int > getListOfPstates (const std::string &hostname)
 Get the list of power states available for a host. More...
 
static double getMaxPowerConsumption (const std::string &hostname)
 Get the maximum power consumption for the host (i.e., 100% utilization) at its current pstate. More...
 
static double getMemoryCapacity ()
 Get the memory_manager_service capacity of the host on which the calling process is running. More...
 
static double getMinPowerConsumption (const std::string &hostname)
 Get the minimum power consumption for the host (i.e., idling) at its current pstate. More...
 
static int getNumberofPstates (const std::string &hostname)
 Get the total number of power states of a host. More...
 
static unsigned long getNumCores ()
 Get the number of cores of the host on which the calling process is running. More...
 
static std::vector< std::string > getRoute (std::string &src_host, std::string &dst_host)
 Get the list of link names on the route between two hosts. More...
 
static bool isHostOn (std::string hostname)
 Returns whether a host is on or not. More...
 
static bool isLinkOn (std::string linkname)
 Returns whether a link is on or not. More...
 
static bool isPageCachingEnabled ()
 
static void sleep (double duration)
 Make the calling process sleep for a number of (simulated) seconds. More...
 
static void turnOffHost (std::string hostname)
 Turns off a host. More...
 
static void turnOffLink (std::string linkname)
 Turns off a link. More...
 
static void turnOnHost (std::string hostname)
 Turns on a host. More...
 
static void turnOnLink (std::string linkname)
 Turns on a link. More...
 

Detailed Description

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).

Member Function Documentation

◆ add()

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

Method to add a service to the simulation.

Template Parameters
TThe service class (base class is Service)
Parameters
tthe service object
Returns
a shared_ptr to the service object

◆ compute()

void wrench::Simulation::compute ( double  flops)
static

Make the calling process compute.

Parameters
flopsa number of floating point operations

◆ doesHostExist()

bool wrench::Simulation::doesHostExist ( std::string  hostname)
static

Wrapper for S4U_Simulation hostExists()

Parameters
hostname- name of host being queried
Returns
boolean of existence

◆ doesLinkExist()

bool wrench::Simulation::doesLinkExist ( std::string  linkname)
static

Wrapper for S4U_Simulation linkExists()

Parameters
linkname- name of link being queried
Returns
boolean of existence

◆ getCurrentPstate()

int wrench::Simulation::getCurrentPstate ( const std::string &  hostname)
static

Get the current power state of a host.

Parameters
hostnamethe host name
Returns
The index of the current pstate of the host (as specified in the platform xml description file)

◆ getCurrentSimulatedDate()

double wrench::Simulation::getCurrentSimulatedDate ( )
static

Get the current simulated date.

Returns
a date

◆ getEnergyConsumed() [1/4]

double wrench::Simulation::getEnergyConsumed ( const std::string &  hostname)

Obtains the current energy consumption of a host.

Parameters
hostnamethe host name
Returns
current energy consumption in joules
Exceptions
std::invalid_argument

◆ getEnergyConsumed() [2/4]

double wrench::Simulation::getEnergyConsumed ( const std::string &  hostname,
bool  record_as_time_stamp 
)

Obtains the current energy consumption of a host and will add SimulationTimestampEnergyConsumption to simulation output if can_record is set to true.

Parameters
hostnamethe host name
record_as_time_stampbool signaling whether or not to record a SimulationTimestampEnergyConsumption object
Returns
current energy consumption in joules
Exceptions
std::invalid_argument

◆ getEnergyConsumed() [3/4]

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

Obtains the current energy consumption of a host.

Parameters
hostnamesthe list of hostnames
Returns
current energy consumption in joules for each host, as a map indexed by hostnames
Exceptions
std::invalid_argument

◆ getEnergyConsumed() [4/4]

std::map< std::string, double > wrench::Simulation::getEnergyConsumed ( const std::vector< std::string > &  hostnames,
bool  record_as_time_stamps 
)

Obtains the current energy consumption of a host and will add SimulationTimestampEnergyConsumption to simulation output if can_record is set to true.

Parameters
hostnamesthe list of hostnames
record_as_time_stampswhether or not to record a SimulationTimestampEnergyConsumption object for each host when this method is called
Returns
current energy consumption in joules for each host, as a map indexed by hostnames
Exceptions
std::invalid_argument

◆ getFlopRate()

double wrench::Simulation::getFlopRate ( )
static

Get the flop rate of one core of the host on which the calling process is running.

Returns
a flop rate

◆ getHostFlopRate()

double wrench::Simulation::getHostFlopRate ( std::string  hostname)
static

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

Parameters
hostnamethe hostname
Returns
a flop rate (flop / sec)

◆ getHostMemoryCapacity()

double wrench::Simulation::getHostMemoryCapacity ( std::string  hostname)
static

Get the memory_manager_service capacity of a host given a hostname.

Parameters
hostnamethe hostname
Returns
a memory_manager_service capacity in bytes

◆ getHostName()

std::string wrench::Simulation::getHostName ( )
static

Get the name of the host on which the calling process is running.

Returns
a host name

◆ getHostnameList()

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

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

Returns
a vector of hostnames

◆ getHostnameListByCluster()

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

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

Retrieve MemoryManager by hostname

Parameters
hostname
Returns
a map of lists of hosts, indexed by cluster name

◆ getHostNumCores()

unsigned long wrench::Simulation::getHostNumCores ( std::string  hostname)
static

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

Parameters
hostnamethe hostname
Returns
a number of cores

◆ getLinkBandwidth()

double wrench::Simulation::getLinkBandwidth ( std::string  link_name)
static

Get the max bandwidth of a particular link.

Parameters
link_namethe link's name
Returns
a bandwidth in Bps

◆ getLinknameList()

std::vector< std::string > wrench::Simulation::getLinknameList ( )
static

Get the list of names of all the links in the platform.

Returns
a vector of link names

◆ getLinkUsage() [1/2]

double wrench::Simulation::getLinkUsage ( const std::string &  link_name,
bool  record_as_time_stamp 
)

Obtains the current link bandwidth usage on a link and will add SimulationTimestampLinkUsage to simulation output if record_as_time_stamp is set to true.

Parameters
link_namethe link name
record_as_time_stampbool signaling whether or not to record a SimulationTimestampLinkUsage object
Returns
current bandwidth usage in Bps
Exceptions
std::invalid_argument

◆ getLinkUsage() [2/2]

double wrench::Simulation::getLinkUsage ( std::string  link_name)
static

Get the current usage of a particular link.

Parameters
link_namethe link's name
Returns
a bandwidth usage

◆ getListOfPstates()

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

Get the list of power states available for a host.

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

◆ getMaxPowerConsumption()

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

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

Parameters
hostnamethe host name
Returns
The "100% used" power consumption (as specified in the platform xml description file)

◆ getMemoryCapacity()

double wrench::Simulation::getMemoryCapacity ( )
static

Get the memory_manager_service capacity of the host on which the calling process is running.

Returns
a memory_manager_service capacity in bytes

◆ getMemoryManagerByHost()

MemoryManager * wrench::Simulation::getMemoryManagerByHost ( std::string  hostname)

Find MemoryManager running on a host based on hostname.

Parameters
hostnamename of the host
Returns
pointer to the memory manager running on the host (or nullptr)

◆ getMinPowerConsumption()

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

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

Parameters
hostnamethe host name
Returns
The "idling" power consumption (as specified in the platform xml description file)

◆ getNumberofPstates()

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

Get the total number of power states of a host.

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

◆ getNumCores()

unsigned long wrench::Simulation::getNumCores ( )
static

Get the number of cores of the host on which the calling process is running.

Returns
a number of cores

◆ getOutput()

SimulationOutput & wrench::Simulation::getOutput ( )

Get the simulation output object.

Returns
simulation output object

◆ getRoute()

std::vector< std::string > wrench::Simulation::getRoute ( std::string &  src_host,
std::string &  dst_host 
)
static

Get the list of link names on the route between two hosts.

Parameters
src_hostsrc hostname
dst_hostdst hostname
Returns
a vector of link names

◆ init()

void wrench::Simulation::init ( int *  argc,
char **  argv 
)

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

Parameters
argcmain()'s argument count
argvmain()'s argument list
Exceptions
std::invalid_argument

◆ instantiatePlatform()

void wrench::Simulation::instantiatePlatform ( std::string  filename)

Instantiate a simulated platform.

Parameters
filenamethe path to a SimGrid XML platform description file
Exceptions
std::runtime_error

◆ isHostOn()

bool wrench::Simulation::isHostOn ( std::string  hostname)
static

Returns whether a host is on or not.

Parameters
hostnamethe hostname
Returns
true or false

◆ isLinkOn()

bool wrench::Simulation::isLinkOn ( std::string  linkname)
static

Returns whether a link is on or not.

Parameters
linknamethe linkname
Returns
true or false

◆ isPageCachingEnabled()

bool wrench::Simulation::isPageCachingEnabled ( )
static

Check if writeback mode is activated

Returns

◆ launch()

void wrench::Simulation::launch ( )

Launch the simulation.

Exceptions
std::runtime_error

◆ readFromDisk()

void wrench::Simulation::readFromDisk ( double  num_bytes,
std::string  hostname,
std::string  mount_point 
)

Wrapper enabling timestamps for disk reads.

Parameters
num_bytes- number of bytes read
hostname- hostname to read from
mount_point- mount point of disk to read from
Exceptions
invalid_argument

◆ readFromDiskAndWriteToDiskConcurrently()

void wrench::Simulation::readFromDiskAndWriteToDiskConcurrently ( double  num_bytes_to_read,
double  num_bytes_to_write,
std::string  hostname,
std::string  read_mount_point,
std::string  write_mount_point 
)

Wrapper enabling timestamps for concurrent disk read/writes.

Parameters
num_bytes_to_read- number of bytes read
num_bytes_to_write- number of bytes written
hostname- hostname where disk is located
read_mount_point- mount point of disk to read from
write_mount_point- mount point of disk to write to
Exceptions
invalid_argument

◆ readWithMemoryCache()

void wrench::Simulation::readWithMemoryCache ( WorkflowFile file,
double  n_bytes,
std::shared_ptr< FileLocation location 
)

Read file locally, only available if writeback is activated.

Parameters
fileworkflow file
n_bytesnumber of read bytes
locationfile location

◆ setPstate()

void wrench::Simulation::setPstate ( const std::string &  hostname,
int  pstate 
)

Set the power state of the host.

Parameters
hostnamethe host name
pstatethe power state index (as specified in the platform xml description file)

◆ sleep()

void wrench::Simulation::sleep ( double  duration)
static

Make the calling process sleep for a number of (simulated) seconds.

Parameters
durationa number of seconds

◆ stageFile() [1/2]

void wrench::Simulation::stageFile ( WorkflowFile file,
std::shared_ptr< StorageService storage_service 
)

Stage a copy of a file at a storage service in the root of the (unique) mount point.

Parameters
filea file to stage on a storage service
storage_servicea storage service
Exceptions
std::runtime_error
std::invalid_argument

◆ stageFile() [2/2]

void wrench::Simulation::stageFile ( WorkflowFile file,
std::shared_ptr< StorageService storage_service,
std::string  directory_absolute_path 
)

Stage a copy of a file at a storage service in a particular directory.

Parameters
filea file to stage on a storage service
storage_servicea storage service
directory_absolute_paththe absolute path of the directory where the file should be stored
Exceptions
std::runtime_error
std::invalid_argument

◆ startNewService() [1/5]

std::shared_ptr< ComputeService > wrench::Simulation::startNewService ( ComputeService service)

Starts a new compute service during WMS execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor.

Parameters
serviceAn instance of a service
Returns
A pointer to the service instance
Exceptions
std::invalid_argument
std::runtime_error

◆ startNewService() [2/5]

std::shared_ptr< FileRegistryService > wrench::Simulation::startNewService ( FileRegistryService service)

Starts a new file registry service during WMS execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor.

Parameters
serviceAn instance of a service
Returns
A pointer to the service instance
Exceptions
std::invalid_argument
std::runtime_error

◆ startNewService() [3/5]

std::shared_ptr< MemoryManager > wrench::Simulation::startNewService ( MemoryManager service)

Starts a new memory_manager_service manager service during execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor.

Parameters
serviceAn instance of a service
Returns
A pointer to the service instance
Exceptions
std::invalid_argument
std::runtime_error

◆ startNewService() [4/5]

std::shared_ptr< NetworkProximityService > wrench::Simulation::startNewService ( NetworkProximityService service)

Starts a new network proximity service during WMS execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor.

Parameters
serviceAn instance of a service
Returns
A pointer to the service instance
Exceptions
std::invalid_argument
std::runtime_error

◆ startNewService() [5/5]

std::shared_ptr< StorageService > wrench::Simulation::startNewService ( StorageService service)

Starts a new storage service during WMS execution (i.e., one that was not passed to Simulation::add() before Simulation::launch() was called). The simulation takes ownership of the reference and will call the destructor.

Parameters
serviceAn instance of a service
Returns
A pointer to the service instance
Exceptions
std::invalid_argument
std::runtime_error

◆ turnOffHost()

void wrench::Simulation::turnOffHost ( std::string  hostname)
static

Turns off a host.

Parameters
hostnamethe hostname

◆ turnOffLink()

void wrench::Simulation::turnOffLink ( std::string  linkname)
static

Turns off a link.

Parameters
linknamethe linkname

◆ turnOnHost()

void wrench::Simulation::turnOnHost ( std::string  hostname)
static

Turns on a host.

Parameters
hostnamethe hostname

◆ turnOnLink()

void wrench::Simulation::turnOnLink ( std::string  linkname)
static

Turns on a link.

Parameters
linknamethe linkname

◆ writebackWithMemoryCache()

void wrench::Simulation::writebackWithMemoryCache ( WorkflowFile file,
double  n_bytes,
std::shared_ptr< FileLocation location,
bool  is_dirty 
)

Write a file locally with writeback strategy, only available if writeback is activated.

Parameters
fileworkflow file
n_bytesnumber of written bytes
locationfile location
is_dirtytrue or false

◆ writeThroughWithMemoryCache()

void wrench::Simulation::writeThroughWithMemoryCache ( WorkflowFile file,
double  n_bytes,
std::shared_ptr< FileLocation location 
)

Write-through a file locally, only available if writeback is activated.

Parameters
fileworkflow file
n_bytesnumber of written bytes
locationfile location

◆ writeToDisk()

void wrench::Simulation::writeToDisk ( double  num_bytes,
std::string  hostname,
std::string  mount_point 
)

Wrapper enabling timestamps for disk writes.

Parameters
num_bytesnumber of bytes written
hostnamename of the host to write to
mount_pointmount point of the disk to write to at the host
Exceptions
invalid_argument

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