SimGrid  3.19.1
Versatile Simulation of Distributed Systems
simgrid::s4u::Host Class Reference

Detailed Description

An host represents some physical resource with computing and networking capabilities.

All hosts are automatically created during the call of the method simgrid::s4u::Engine::loadPlatform(). You cannot create a host yourself.

You can retrieve a particular host using simgrid::s4u::Host::byName() and actors can retrieve the host on which they run using simgrid::s4u::Host::current().

Examples:
examples/s4u/actor-migration/s4u-actor-migration.cpp, examples/s4u/energy-boot/s4u-energy-boot.cpp, examples/s4u/energy-exec/s4u-energy-exec.cpp, examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp, examples/s4u/exec-ptask/s4u-exec-ptask.cpp, examples/s4u/exec-remote/s4u-exec-remote.cpp, and examples/s4u/platform-properties/s4u-platform-properties.cpp.

#include <Host.hpp>

Inheritance diagram for simgrid::s4u::Host:
simgrid::xbt::Extendable< Host > simgrid::s4u::VirtualMachine

Public Member Functions

 Host (const char *name)
 
virtual void destroy ()
 Fire the required callbacks and destroy the object. More...
 
 Host (Host const &)=delete
 
Hostoperator= (Host const &)=delete
 
simgrid::xbt::string const & getName () const
 Retrieves the name of that host as a C++ string. More...
 
const char * getCname () const
 Retrieves the name of that host as a C string. More...
 
void actorList (std::vector< ActorPtr > *whereto)
 Return the list of actors attached to an host. More...
 
void turnOn ()
 Turns that host on if it was previously off. More...
 
void turnOff ()
 Turns that host off. More...
 
bool isOn ()
 Returns if that host is currently up and running. More...
 
bool isOff ()
 Returns if that host is currently down and offline. More...
 
double getSpeed ()
 Get the peak processor speed (in flops/s), at the current pstate. More...
 
int getCoreCount ()
 Returns the number of core of the processor. More...
 
std::map< std::string, std::string > * getProperties ()
 Get the properties assigned to a host. More...
 
const char * getProperty (const char *key)
 Retrieve the property value (or nullptr if not set) More...
 
void setProperty (std::string key, std::string value)
 
void getProcesses (std::vector< ActorPtr > *list)
 Get the processes attached to the host. More...
 
double getPstateSpeed (int pstate_index)
 Get the peak processor speed (in flops/s), at the specified pstate. More...
 
int getPstatesCount () const
 
void setPstate (int pstate_index)
 Set the pstate at which the host should run. More...
 
int getPstate ()
 Retrieve the pstate at which the host is currently running. More...
 
void getAttachedStorages (std::vector< const char *> *storages)
 Returns the list of storages attached to an host. More...
 
std::unordered_map< std::string, Storage * > const & getMountedStorages ()
 Get an associative list [mount point]->[Storage] of all local mount points. More...
 
void routeTo (Host *dest, std::vector< Link *> &links, double *latency)
 Find a route toward another host. More...
 
void routeTo (Host *dest, std::vector< surf::LinkImpl *> &links, double *latency)
 Just like Host::routeTo, but filling an array of link implementations. More...
 
void execute (double flops)
 Block the calling actor on an execution located on the called host. More...
 
double getLoad ()
 Returns the current computation load (in flops per second) More...
 
- Public Member Functions inherited from simgrid::xbt::Extendable< Host >
 Extendable ()
 
 ~Extendable ()
 
voidextension (std::size_t rank)
 
U * extension (Extension< Host, U > rank)
 
U * extension ()
 
void extension_set (std::size_t rank, void *value, bool use_dtor=true)
 
void extension_set (Extension< Host, U > rank, U *value, bool use_dtor=true)
 
void extension_set (U *p)
 

Static Public Member Functions

static Hostby_name_or_null (const char *name)
 Retrieves an host from its name, or return nullptr. More...
 
static Hostby_name_or_null (std::string name)
 Retrieves an host from its name, or return nullptr. More...
 
static s4u::Hostby_name (const char *name)
 Retrieves an host from its name, or die. More...
 
static s4u::Hostby_name (std::string name)
 Retrieves an host from its name, or die. More...
 
static s4u::Hostcurrent ()
 Retrieves the host on which the current actor is running. More...
 
- Static Public Member Functions inherited from simgrid::xbt::Extendable< Host >
static size_t extension_create (void(*deleter)(void *))
 
static Extension< Host, U > extension_create (void(*deleter)(void *))
 
static Extension< Host, U > extension_create ()
 

Public Attributes

surf::HostImplpimpl_ = nullptr
 
surf::Cpupimpl_cpu = nullptr
 DO NOT USE DIRECTLY (. More...
 
kernel::routing::NetPointpimpl_netpoint = nullptr
 DO NOT USE DIRECTLY (. More...
 

Static Public Attributes

static simgrid::xbt::signal< void(Host &)> onCreation
 
static simgrid::xbt::signal< void(Host &)> onDestruction
 
static simgrid::xbt::signal< void(Host &)> onStateChange
 
static simgrid::xbt::signal< void(Host &)> onSpeedChange
 

Protected Member Functions

virtual ~Host ()
 Host destruction logic. More...
 

Constructor & Destructor Documentation

◆ Host() [1/2]

simgrid::s4u::Host::Host ( const char *  name)
explicit

◆ ~Host()

simgrid::s4u::Host::~Host ( )
protectedvirtual

Host destruction logic.

◆ Host() [2/2]

simgrid::s4u::Host::Host ( Host const &  )
delete

Member Function Documentation

◆ destroy()

void simgrid::s4u::Host::destroy ( )
virtual

Fire the required callbacks and destroy the object.

Don't delete directly an Host, call h->destroy() instead.

This is cumbersome but this is the simplest solution to ensure that the onDestruction() callback receives a valid object (because of the destructor order in a class hierarchy).

Reimplemented in simgrid::s4u::VirtualMachine.

◆ operator=()

Host& simgrid::s4u::Host::operator= ( Host const &  )
delete

◆ by_name_or_null() [1/2]

Host * simgrid::s4u::Host::by_name_or_null ( const char *  name)
static

Retrieves an host from its name, or return nullptr.

Examples:
examples/s4u/app-pingpong/s4u-app-pingpong.cpp, and examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp.

◆ by_name_or_null() [2/2]

Host * simgrid::s4u::Host::by_name_or_null ( std::string  name)
static

Retrieves an host from its name, or return nullptr.

◆ by_name() [1/2]

◆ by_name() [2/2]

Host * simgrid::s4u::Host::by_name ( std::string  name)
static

Retrieves an host from its name, or die.

◆ current()

◆ getName()

simgrid::xbt::string const& simgrid::s4u::Host::getName ( ) const
inline

Retrieves the name of that host as a C++ string.

◆ getCname()

const char* simgrid::s4u::Host::getCname ( ) const
inline

◆ actorList()

void simgrid::s4u::Host::actorList ( std::vector< ActorPtr > *  whereto)

Return the list of actors attached to an host.

Parameters
wheretoa vector in which we should push actors living on that host

◆ turnOn()

void simgrid::s4u::Host::turnOn ( )

Turns that host on if it was previously off.

All actors on that host which were marked autorestart will be restarted automatically. This call does nothing if the host is already on.

Examples:
examples/s4u/energy-boot/s4u-energy-boot.cpp.

◆ turnOff()

void simgrid::s4u::Host::turnOff ( )

Turns that host off.

All actors are forcefully stopped.

Examples:
examples/s4u/energy-boot/s4u-energy-boot.cpp, and examples/s4u/energy-exec/s4u-energy-exec.cpp.

◆ isOn()

bool simgrid::s4u::Host::isOn ( )

Returns if that host is currently up and running.

◆ isOff()

bool simgrid::s4u::Host::isOff ( )
inline

Returns if that host is currently down and offline.

◆ getSpeed()

double simgrid::s4u::Host::getSpeed ( )

◆ getCoreCount()

int simgrid::s4u::Host::getCoreCount ( )

Returns the number of core of the processor.

◆ getProperties()

std::map< std::string, std::string > * simgrid::s4u::Host::getProperties ( )

Get the properties assigned to a host.

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

◆ getProperty()

const char * simgrid::s4u::Host::getProperty ( const char *  key)

Retrieve the property value (or nullptr if not set)

Examples:
examples/s4u/energy-exec/s4u-energy-exec.cpp, and examples/s4u/platform-properties/s4u-platform-properties.cpp.

◆ setProperty()

void simgrid::s4u::Host::setProperty ( std::string  key,
std::string  value 
)

◆ getProcesses()

void simgrid::s4u::Host::getProcesses ( std::vector< ActorPtr > *  list)

Get the processes attached to the host.

◆ getPstateSpeed()

double simgrid::s4u::Host::getPstateSpeed ( int  pstate_index)

Get the peak processor speed (in flops/s), at the specified pstate.

Examples:
examples/s4u/energy-exec/s4u-energy-exec.cpp, and examples/s4u/exec-dvfs/s4u-exec-dvfs.cpp.

◆ getPstatesCount()

int simgrid::s4u::Host::getPstatesCount ( ) const

◆ setPstate()

void simgrid::s4u::Host::setPstate ( int  pstate_index)

◆ getPstate()

int simgrid::s4u::Host::getPstate ( )

Retrieve the pstate at which the host is currently running.

Examples:
examples/s4u/energy-boot/s4u-energy-boot.cpp, and examples/s4u/energy-exec/s4u-energy-exec.cpp.

◆ getAttachedStorages()

void simgrid::s4u::Host::getAttachedStorages ( std::vector< const char *> *  storages)

Returns the list of storages attached to an host.

Returns
a vector containing all storages attached to the host

◆ getMountedStorages()

std::unordered_map< std::string, Storage * > const & simgrid::s4u::Host::getMountedStorages ( )

Get an associative list [mount point]->[Storage] of all local mount points.

This is defined in the platform file, and cannot be modified programatically (yet).

Examples:
examples/s4u/io-file-system/s4u-io-file-system.cpp, and examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp.

◆ routeTo() [1/2]

void simgrid::s4u::Host::routeTo ( Host dest,
std::vector< Link *> &  links,
double *  latency 
)

Find a route toward another host.

Parameters
dest[IN] where to
links[OUT] where to store the list of links (must exist, cannot be nullptr).
latency[OUT] where to store the latency experienced on the path (or nullptr if not interested) It is the caller responsibility to initialize latency to 0 (we add to provided route)
Precondition
links!=nullptr

walk through the routing components tree and find a route between hosts by calling each "get_route" function in each routing component.

◆ routeTo() [2/2]

void simgrid::s4u::Host::routeTo ( Host dest,
std::vector< surf::LinkImpl *> &  links,
double *  latency 
)

Just like Host::routeTo, but filling an array of link implementations.

◆ execute()

void simgrid::s4u::Host::execute ( double  flops)

Block the calling actor on an execution located on the called host.

It is not a problem if the actor is not located on the called host. The actor will not be migrated in this case. Such remote execution are easy in simulation.

◆ getLoad()

double simgrid::s4u::Host::getLoad ( )

Returns the current computation load (in flops per second)

Examples:
examples/s4u/exec-remote/s4u-exec-remote.cpp.

Member Data Documentation

◆ pimpl_

surf::HostImpl* simgrid::s4u::Host::pimpl_ = nullptr

◆ pimpl_cpu

surf::Cpu* simgrid::s4u::Host::pimpl_cpu = nullptr

DO NOT USE DIRECTLY (.

◆ pimpl_netpoint

kernel::routing::NetPoint* simgrid::s4u::Host::pimpl_netpoint = nullptr

DO NOT USE DIRECTLY (.

◆ onCreation

simgrid::xbt::signal< void(Host &)> simgrid::s4u::Host::onCreation
static

◆ onDestruction

simgrid::xbt::signal< void(Host &)> simgrid::s4u::Host::onDestruction
static

◆ onStateChange

simgrid::xbt::signal< void(Host &)> simgrid::s4u::Host::onStateChange
static

◆ onSpeedChange

simgrid::xbt::signal< void(Host &)> simgrid::s4u::Host::onSpeedChange
static

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