wrench::S4U_Simulation

class S4U_Simulation

Wrappers around S4U’s basic simulation methods.

Public Functions

void checkLinkBandwidths()

Method to check that all link bandwidths are >0.

void initialize(int *argc, char **argv)

Initialize the Simgrid simulation.

Parameters:
  • argc – the C-style argument counts

  • argv – the C-style argument list

bool isInitialized() const

Returns true if S4U_Simulation::initialize() has been called successfully previously.

Returns:

true or false

bool isPlatformSetup() const

Returns true if S4U_Simulation::setupPlatform() has been called successfully previously.

Returns:

true or false

void runSimulation()

Start the simulation.

void setupPlatform(const std::function<void()> &creation_function)

Initialize the simulated platform. Must only be called once.

Parameters:

creation_function – void() function to create the platform

void setupPlatform(const std::string &filepath)

Initialize the simulated platform. Must only be called once.

Parameters:

filename – the path to an XML platform description file

void shutdown() const

Shutdown the simulation.

Public Static Functions

static void compute(double)

Simulates a computation on host on which the calling actor is running.

Parameters:

flops – the number of flops

static void compute_multi_threaded(unsigned long num_threads, double thread_creation_overhead, double sequential_work, double parallel_per_thread_work)

Simulates a multi-threaded computation.

Parameters:
  • num_threads – the number of threads

  • thread_creation_overhead – the thread creation overhead in seconds

  • sequential_work – the sequential work (in flops)

  • parallel_per_thread_work – the parallel per thread work (in flops)

static void computeZeroFlop()

Compute zero flop, which take zero time but will block if the host’s pstate has a zero flop/sec speed, until the host’s pstate is changed to a pstate with non-zero flop/sec speed.

static void createNewDisk(const std::string &hostname, const std::string &disk_id, double read_bandwidth_in_bytes_per_sec, double write_bandwidth_in_bytes_per_sec, sg_size_t capacity_in_bytes, const std::string &mount_point)

Method to create, programmatically, a new disk.

Parameters:
  • hostname – the name of the host to which the disk should be attached

  • disk_id – the nae of the disk

  • read_bandwidth_in_bytes_per_sec – the disk’s read bandwidth in byte/sec

  • write_bandwidth_in_bytes_per_sec – the disk’s write bandwidth in byte/sec

  • capacity_in_bytes – the disk’s capacity in bytes

  • mount_point – the disk’s mount point (most people use “/”)

static void enableSMPI()

Enable the use of SMPI.

static simgrid::s4u::Host *get_host_or_vm_by_name(const std::string &name)

Convenient s4u wrapper to retrieve a Host (which can be a VM) based on a name.

Parameters:

name – the host/vm name

Returns:

a SimGrid host or nullptr if name==””

static simgrid::s4u::Host *get_host_or_vm_by_name_or_null(const std::string &name)

Convenient s4u wrapper to retrieve a Host (which can be a VM) based on a name.

Parameters:

name – the host/vm name or null if none

Returns:

a SimGrid host

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

Get the list of ids of all ClusterZone in the platform within each zone (<cluster> XML tag in the platform XML description)

Returns:

a map of zone ids and the list of cluster ids

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

Get the list of physical hostnames.

Returns:

a vector of hostnames

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

Get the list of hostnames in each ClusterZone in the platform (<cluster> XML tag in the platform XML description)

Returns:

a map of all cluster ids and lists of hostnames

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

Get the list of hostnames in each NetZone (<zone> and <cluster> tags in the platform XML description). Note that this method does not recurse into sub-zones, so it only returns the hosts that are declared directly under the <zone> and or <cluster> tags.

Returns:

a map of all zone ids and lists of hostnames

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

Get the list of link names.

Returns:

a vector of link names

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

Get the list of ids of all (sub-)zones in the platform within each zone (<zone> XML tag in the platform XML description)

Returns:

a map of zone ids and the list of (sub-)zone ids

static double getClock()

Get the current simulation date.

Returns:

the simulation clock

static std::string getClusterProperty(const std::string &cluster_id, const std::string &property_name)

Get the property associated to a cluster specified in the platform file.

Parameters:
  • cluster_id – the cluster id

  • property_name – the property name

Returns:

a string relating to the property specified in the platform file

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

Get the current power state of a host.

Parameters:

hostname – the host name

Returns:

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

static sg_size_t getDiskCapacity(const std::string &hostname, std::string mount_point)

Gets the capacity of a disk attached to some host for a given mount point.

Parameters:
  • hostname – the host’s name

  • mount_point – the mount point (e.g., “/home”)

Returns:

the capacity of the disk / mount point

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

Gets set of disks, i.e., mount points, available at a host.

Parameters:

hostname – the host’s name

Returns:

a vector of mount points

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

Get the energy consumed by the host up to now.

Parameters:

hostname – the host name

Returns:

the energy consumed by the host in Joules

static double getFlopRate()

Get the flop rate of the current host.

Returns:

the flop rate in floating point operations per second

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

Get the flop rate of a host.

Parameters:

hostname – the name of the host

Returns:

the flop rate in floating point operations per second

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

Get the memory_manager_service capacity of a host given a hostname.

Parameters:

hostname – the name of the host

Returns:

a memory_manager_service capacity in bytes

static sg_size_t getHostMemoryCapacity(simgrid::s4u::Host *host)

Get the memory_manager_service capacity of a S4U host.

Parameters:

host – the host

Returns:

a memory_manager_service capacity in bytes

static std::string getHostName()

Get the hostname on which the calling actor is running.

Returns:

the hostname as a string

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

Get the number of cores of a host.

Parameters:

hostname – the name of the host

Returns:

the number of cores of the host

static std::string getHostProperty(const std::string &hostname, const std::string &property_name)

Get the property associated to a host specified in the platform file.

Parameters:
  • hostname – the host name

  • property_name – the property name

Returns:

a string relating to the property specified in the platform file

static double getLinkBandwidth(const std::string &name)

Get a link’s bandwidth.

Parameters:

name – the link’s name

Returns:

a bandwidth in Bps

static double getLinkUsage(const std::string &name)

Get a link’s bandwidth usage.

Parameters:

name – the link’s name

Returns:

a bandwidth usage in Bps

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 (i.e., 100% load) for a host at its current pstate.

Parameters:

hostname – the host name

Returns:

The power consumption for this host if 100% used (as specified in the platform xml description file)

static sg_size_t getMemoryCapacity()

Get the memory_manager_service capacity of the current host.

Returns:

a memory_manager_service capacity in bytes

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

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

Parameters:

hostname – the host name

Returns:

The power consumption for this host if idle (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 unsigned int getNumCores()

Get the number of cores of the current host.

Returns:

a number of cores

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.

Parameters:
  • src_host – src hostname

  • dst_host – dst hostname

Returns:

a vector of link names

static bool hostExists(const std::string &hostname)

Determines whether a host exists for a given hostname (does not include VMs)

Parameters:

hostname – the name of the host

Returns:

true or false

static simgrid::s4u::Disk *hostHasMountPoint(const std::string &hostname, const std::string &mount_point)

Determines whether a mount point is defined at a host.

Parameters:
  • hostname – the host’s name

  • mount_point – the mount point

Returns:

a simgrid disk if the host has a disk attached to the specified mount point, nullptr otherwise

static bool isHostOn(const std::string &hostname)

Returns whether a host is on or not.

Parameters:

hostname – the name of the host

Returns:

true or false

static bool isLinkOn(const std::string &link_name)

Returns whether a link is on or not.

Parameters:

link_name – the name of the link

Returns:

true or false

static bool linkExists(const std::string &link_name)

Determines whether a link exists for a given link_name.

Parameters:

link_name – the name of the link

Returns:

true or false

static void readFromDisk(sg_size_t num_bytes, const std::string &hostname, std::string mount_point, simgrid::s4u::Disk *disk)

Simulates a disk read.

Parameters:
  • num_bytes – number of bytes to read

  • hostname – name of host to which disk is attached

  • mount_point – mount point

  • disk – disk to read from (nullptr if not known)

static void readFromDiskAndWriteToDiskConcurrently(sg_size_t num_bytes_to_read, sg_size_t num_bytes_to_write, const std::string &hostname, const std::string &read_mount_point, const std::string &write_mount_point, simgrid::s4u::Disk *src_disk, simgrid::s4u::Disk *dst_disk)

Read from a local disk and write to a local disk concurrently.

Parameters:
  • num_bytes_to_read – number of bytes to read

  • num_bytes_to_write – number of bytes to write

  • hostname – the host at which the disks are located

  • read_mount_point – the mountpoint to read from

  • write_mount_point – the mountpoint to write to

  • src_disk – source disk (nullptr if not known)

  • dst_disk – dst disk (nullptr if not known)

static void setHostProperty(const std::string &hostname, const std::string &property_name, const std::string &property_value)

Set a property associated to a host specified in the platform file (does not include VMs)

Parameters:
  • hostname – the host name

  • property_name – the property name

  • property_value – the property value

static void setLinkBandwidth(const std::string &name, double bandwidth)

Set a link’s new bandwidth.

Parameters:
  • name – the link’s name

  • bandwidth – the new bandwidth

static void setPstate(const std::string &hostname, unsigned long pstate)

Set the power state of the host.

Parameters:
  • hostname – the host name

  • pstate – the power state index (the power state index is specified in the platform xml description file)

static void sleep(double)

Simulates a sleep.

Parameters:

duration – the number of seconds to sleep

static void turnOffHost(const std::string &hostname)

Turn off a host.

Parameters:

hostname – the name of the host to turn off

static void turnOffLink(const std::string &link_name)

Turn off a link.

Parameters:

link_name – the name of the link to turn off

static void turnOnHost(const std::string &hostname)

Turn on a host.

Parameters:

hostname – the name of the host to turn on

static void turnOnLink(const std::string &link_name)

Turn on a link.

Parameters:

link_name – the name of the link to turn on

static void writeToDisk(sg_size_t num_bytes, const std::string &hostname, std::string mount_point, simgrid::s4u::Disk *disk)

Simulates a disk write.

Parameters:
  • num_bytes – number of bytes to write

  • hostname – name of host to which disk is attached (or empty if disk is known)

  • mount_point – mount point (or empty if disk is known)

  • disk – a disk to write to, if known (if known, this method will run much faster)

static void yield()

Simulates a yield.

Public Static Attributes

static constexpr sg_size_t DEFAULT_RAM = LONG_LONG_MAX

The ram capacity of a physical host whenever not specified in the platform description file.