SimGrid  3.21
Versatile Simulation of Distributed Systems
simgrid::s4u::VirtualMachine Class Reference

Detailed Description

A VM represents a virtual machine (or a container) that hosts actors.

The total computing power that the contained actors can get is constrained to the virtual machine size.

#include <VirtualMachine.hpp>

Inherits simgrid::s4u::Host.

Public Types

enum  state { state::CREATED, state::RUNNING, state::SUSPENDED, state::DESTROYED }
 

Public Member Functions

 VirtualMachine (std::string name, s4u::Host *physical_host, int core_amount)
 
 VirtualMachine (std::string name, s4u::Host *physical_host, int core_amount, size_t ramsize)
 
 VirtualMachine (VirtualMachine const &)=delete
 
VirtualMachineoperator= (VirtualMachine const &)=delete
 
simgrid::vm::VirtualMachineImplget_impl ()
 
void start ()
 
void suspend ()
 
void resume ()
 
void shutdown ()
 
void destroy ()
 
simgrid::s4u::Hostget_pm ()
 
void set_pm (simgrid::s4u::Host *pm)
 
size_t get_ramsize ()
 
void set_ramsize (size_t ramsize)
 
void set_bound (double bound)
 Set a CPU bound for a given VM. More...
 
VirtualMachine::state get_state ()
 
VirtualMachine::state getState ()
 
simgrid::vm::VirtualMachineImplgetImpl ()
 
simgrid::s4u::HostgetPm ()
 
void setPm (simgrid::s4u::Host *pm)
 
size_t getRamsize ()
 
void setRamsize (size_t ramsize)
 
void setBound (double bound)
 
- Public Member Functions inherited from simgrid::s4u::Host
 Host (std::string name)
 
 Host (Host const &)=delete
 
Hostoperator= (Host const &)=delete
 
simgrid::xbt::string const & get_name () const
 Retrieves the name of that host as a C++ string. More...
 
const char * get_cname () const
 Retrieves the name of that host as a C string. More...
 
int get_actor_count ()
 
std::vector< ActorPtr > get_all_actors ()
 
void turn_on ()
 Turns that host on if it was previously off. More...
 
void turn_off ()
 Turns that host off. More...
 
bool is_on () const
 Returns if that host is currently up and running. More...
 
bool is_off () const
 Returns if that host is currently down and offline. More...
 
const char * get_property (std::string key) const
 
void set_property (std::string key, std::string value)
 
std::unordered_map< std::string, std::string > * get_properties ()
 
double get_speed () const
 
double get_available_speed () const
 
int get_core_count () const
 
double get_load () const
 
double get_pstate_speed (int pstate_index) const
 
int get_pstate_count () const
 
void set_pstate (int pstate_index)
 
int get_pstate () const
 
std::vector< const char * > get_attached_storages () const
 
void getAttachedStorages (std::vector< const char *> *storages)
 
std::unordered_map< std::string, Storage * > const & get_mounted_storages ()
 Get an associative list [mount point]->[Storage] of all local mount points. More...
 
std::unordered_map< std::string, Storage * > const & getMountedStorages ()
 
void route_to (Host *dest, std::vector< Link *> &links, double *latency)
 
void route_to (Host *dest, std::vector< kernel::resource::LinkImpl *> &links, double *latency)
 
void execute (double flops)
 Block the calling actor on an execution located on the called host. More...
 
ExecPtr exec_async (double flops_amounts)
 Start an asynchronous computation on that host (possibly remote) More...
 
void execute (double flops, double priority)
 Block the calling actor on an execution located on the called host (with explicit priority) More...
 
- Public Member Functions inherited from simgrid::xbt::Extendable< Host >
 Extendable ()
 
 ~Extendable ()
 
void * extension (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 Attributes

static simgrid::xbt::signal< void(VirtualMachine &)> on_start
 
static simgrid::xbt::signal< void(VirtualMachine &)> on_started
 
static simgrid::xbt::signal< void(VirtualMachine &)> on_shutdown
 
static simgrid::xbt::signal< void(VirtualMachine &)> on_suspend
 
static simgrid::xbt::signal< void(VirtualMachine &)> on_resume
 
static simgrid::xbt::signal< void(VirtualMachine &)> on_migration_start
 
static simgrid::xbt::signal< void(VirtualMachine &)> on_migration_end
 
- Static Public Attributes inherited from simgrid::s4u::Host
static simgrid::xbt::signal< void(Host &)> on_creation
 
static simgrid::xbt::signal< void(Host &)> on_destruction
 
static simgrid::xbt::signal< void(Host &)> on_state_change
 
static simgrid::xbt::signal< void(Host &)> on_speed_change
 

Additional Inherited Members

- Static Public Member Functions inherited from simgrid::s4u::Host
static Hostby_name_or_null (std::string name)
 Retrieves an host from its name, or return nullptr. 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 inherited from simgrid::s4u::Host
surf::Cpu * pimpl_cpu = nullptr
 DO NOT USE DIRECTLY (. More...
 
surf::HostImpl * pimpl_ = nullptr
 
kernel::routing::NetPointpimpl_netpoint = nullptr
 DO NOT USE DIRECTLY (. More...
 
- Protected Member Functions inherited from simgrid::s4u::Host
virtual ~Host ()
 Host destruction logic. More...
 

Member Enumeration Documentation

◆ state

Enumerator
CREATED 

created, but not yet started

RUNNING 
SUSPENDED 

Suspend/resume does not involve disk I/O, so we assume there is no transition states.

DESTROYED 

Constructor & Destructor Documentation

◆ VirtualMachine() [1/3]

simgrid::s4u::VirtualMachine::VirtualMachine ( std::string  name,
s4u::Host physical_host,
int  core_amount 
)
explicit

◆ VirtualMachine() [2/3]

simgrid::s4u::VirtualMachine::VirtualMachine ( std::string  name,
s4u::Host physical_host,
int  core_amount,
size_t  ramsize 
)
explicit

◆ VirtualMachine() [3/3]

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

Member Function Documentation

◆ operator=()

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

◆ get_impl()

simgrid::vm::VirtualMachineImpl* simgrid::s4u::VirtualMachine::get_impl ( )
inline

◆ start()

void simgrid::s4u::VirtualMachine::start ( )

◆ suspend()

void simgrid::s4u::VirtualMachine::suspend ( )

◆ resume()

void simgrid::s4u::VirtualMachine::resume ( )

◆ shutdown()

void simgrid::s4u::VirtualMachine::shutdown ( )

◆ destroy()

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

Reimplemented from simgrid::s4u::Host.

◆ get_pm()

simgrid::s4u::Host * simgrid::s4u::VirtualMachine::get_pm ( )

◆ set_pm()

void simgrid::s4u::VirtualMachine::set_pm ( simgrid::s4u::Host pm)

◆ get_ramsize()

size_t simgrid::s4u::VirtualMachine::get_ramsize ( )

◆ set_ramsize()

void simgrid::s4u::VirtualMachine::set_ramsize ( size_t  ramsize)

◆ set_bound()

void simgrid::s4u::VirtualMachine::set_bound ( double  bound)

Set a CPU bound for a given VM.

  1. Note that in some cases MSG_task_set_bound() may not intuitively work for VMs.

For example, On PM0, there are Task1 and VM0. On VM0, there is Task2. Now we bound 75% to Task1@PM0 and bound 25% to Task2@VM0. Then, Task1@PM0 gets 50%. Task2@VM0 gets 25%. This is NOT 75% for Task1@PM0 and 25% for Task2@VM0, respectively.

This is because a VM has the dummy CPU action in the PM layer. Putting a task on the VM does not affect the bound of the dummy CPU action. The bound of the dummy CPU action is unlimited.

There are some solutions for this problem. One option is to update the bound of the dummy CPU action automatically. It should be the sum of all tasks on the VM. But, this solution might be costly, because we have to scan all tasks on the VM in share_resource() or we have to trap both the start and end of task execution.

The current solution is to use setBound(), which allows us to directly set the bound of the dummy CPU action.

  1. Note that bound == 0 means no bound (i.e., unlimited). But, if a host has multiple CPU cores, the CPU share of a computation task (or a VM) never exceeds the capacity of a CPU core.

◆ get_state()

VirtualMachine::state simgrid::s4u::VirtualMachine::get_state ( )

◆ getState()

VirtualMachine::state simgrid::s4u::VirtualMachine::getState ( )
inline

◆ getImpl()

simgrid::vm::VirtualMachineImpl* simgrid::s4u::VirtualMachine::getImpl ( )
inline

◆ getPm()

simgrid::s4u::Host* simgrid::s4u::VirtualMachine::getPm ( )
inline

◆ setPm()

void simgrid::s4u::VirtualMachine::setPm ( simgrid::s4u::Host pm)
inline

◆ getRamsize()

size_t simgrid::s4u::VirtualMachine::getRamsize ( )
inline

◆ setRamsize()

void simgrid::s4u::VirtualMachine::setRamsize ( size_t  ramsize)
inline

◆ setBound()

void simgrid::s4u::VirtualMachine::setBound ( double  bound)
inline

Member Data Documentation

◆ on_start

simgrid::xbt::signal< void(VirtualMachine &)> simgrid::s4u::VirtualMachine::on_start
static

◆ on_started

simgrid::xbt::signal< void(VirtualMachine &)> simgrid::s4u::VirtualMachine::on_started
static

◆ on_shutdown

simgrid::xbt::signal< void(VirtualMachine &)> simgrid::s4u::VirtualMachine::on_shutdown
static

◆ on_suspend

simgrid::xbt::signal< void(VirtualMachine &)> simgrid::s4u::VirtualMachine::on_suspend
static

◆ on_resume

simgrid::xbt::signal< void(VirtualMachine &)> simgrid::s4u::VirtualMachine::on_resume
static

◆ on_migration_start

simgrid::xbt::signal< void(VirtualMachine &)> simgrid::s4u::VirtualMachine::on_migration_start
static

◆ on_migration_end

simgrid::xbt::signal< void(VirtualMachine &)> simgrid::s4u::VirtualMachine::on_migration_end
static

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