SimGrid  3.12
Versatile Simulation of Distributed Systems
SURF C bindings

Describes the c bindings of SURF. More...

Typedefs

typedef Modelsurf_model_t
 Model datatype. More...
 
typedef Actionsurf_action_t
 Action structure. More...
 
const char * surf_model_name (surf_model_t model)
 Get the name of a surf model (dont rely on exact value) More...
 
surf_action_t surf_model_extract_done_action_set (surf_model_t model)
 Pop an action from the done actions set. More...
 
surf_action_t surf_model_extract_failed_action_set (surf_model_t model)
 Pop an action from the failed actions set. More...
 
surf_action_t surf_model_extract_ready_action_set (surf_model_t model)
 Pop an action from the ready actions set. More...
 
surf_action_t surf_model_extract_running_action_set (surf_model_t model)
 Pop an action from the running actions set. More...
 
int surf_model_running_action_set_size (surf_model_t model)
 Get the size of the running action set of a model. More...
 
surf_action_t surf_host_model_execute_parallel_task (surf_host_model_t model, int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, double rate)
 Execute a parallel task. More...
 
xbt_dynar_t surf_host_model_get_route (surf_host_model_t model, surf_resource_t src, surf_resource_t dst)
 Get the route (dynar of sg_link_t) between two hosts.
 
void surf_vm_model_create (const char *name, surf_resource_t host_PM)
 Create a new VM on the specified host.
 
surf_action_t surf_network_model_communicate (surf_network_model_t model, sg_host_t src, sg_host_t dst, double size, double rate)
 Create a communication between two hosts. More...
 
const char * surf_resource_name (surf_cpp_resource_t resource)
 Get the name of a surf resource (cpu, host, network, …) More...
 
xbt_dict_t surf_resource_get_properties (surf_cpp_resource_t resource)
 Get the properties of a surf resource (cpu, host, network, …)
 
e_surf_resource_state_t surf_resource_get_state (surf_cpp_resource_t resource)
 Get the state of a surf resource (cpu, host, network, …)
 
void surf_resource_set_state (surf_cpp_resource_t resource, e_surf_resource_state_t state)
 Set the state of a surf resource (cpu, host, network, …)
 
double surf_host_get_speed (surf_resource_t resource, double load)
 Get the speed of the cpu associated to a host.
 
double surf_host_get_available_speed (surf_resource_t host)
 Get the available speed of cpu associated to a host.
 
int surf_host_get_core (surf_resource_t host)
 Get the number of cores of the cpu associated to a host.
 
surf_action_t surf_host_execute (surf_resource_t host, double size)
 Create a computation action on the given host.
 
surf_action_t surf_host_sleep (surf_resource_t host, double duration)
 Create a sleep action on the given host.
 
surf_action_t surf_host_open (surf_resource_t host, const char *fullpath)
 Create a file opening action on the given host.
 
surf_action_t surf_host_close (surf_resource_t host, surf_file_t fd)
 Create a file closing action on the given host.
 
surf_action_t surf_host_read (surf_resource_t host, surf_file_t fd, sg_size_t size)
 Create a file reading action on the given host.
 
surf_action_t surf_host_write (surf_resource_t host, surf_file_t fd, sg_size_t size)
 Create a file writing action on the given host.
 
xbt_dynar_t surf_host_get_info (surf_resource_t host, surf_file_t fd)
 Get the informations of a file descriptor. More...
 
sg_size_t surf_host_get_free_size (surf_resource_t resource, const char *name)
 Get the available space of the storage at the mount point. More...
 
sg_size_t surf_host_get_used_size (surf_resource_t resource, const char *name)
 Get the used space of the storage at the mount point. More...
 
xbt_dynar_t surf_host_get_vms (surf_resource_t resource)
 Get the list of VMs hosted on the host.
 
void surf_host_get_params (surf_resource_t resource, vm_params_t params)
 Retrieve the params of that VM. More...
 
void surf_host_set_params (surf_resource_t resource, vm_params_t params)
 Sets the params of that VM/PM. More...
 
void surf_vm_destroy (surf_resource_t resource)
 Destroy a VM. More...
 
void surf_vm_suspend (surf_resource_t resource)
 Suspend a VM.
 
void surf_vm_resume (surf_resource_t resource)
 Resume a VM.
 
void surf_vm_save (surf_resource_t resource)
 Save the VM (Not yet implemented) More...
 
void surf_vm_restore (surf_resource_t resource)
 Restore the VM (Not yet implemented) More...
 
void surf_vm_migrate (surf_resource_t resource, surf_resource_t ind_vm_ws_dest)
 Migrate the VM to the destination host. More...
 
surf_resource_t surf_vm_get_pm (surf_resource_t resource)
 Get the physical machine hosting the VM. More...
 
void surf_vm_set_bound (surf_resource_t resource, double bound)
 [brief description] More...
 
void surf_vm_set_affinity (surf_resource_t resource, surf_resource_t cpu, unsigned long mask)
 [brief description] More...
 
surf_action_t surf_cpu_execute (surf_resource_t cpu, double size)
 Execute some quantity of computation. More...
 
surf_action_t surf_cpu_sleep (surf_resource_t cpu, double duration)
 Make the cpu sleep for duration (in seconds) More...
 
double surf_host_get_current_power_peak (surf_resource_t host)
 Get the host power peak. More...
 
double surf_host_get_power_peak_at (surf_resource_t host, int pstate_index)
 [brief description] More...
 
int surf_host_get_nb_pstates (surf_resource_t host)
 [brief description] More...
 
double surf_host_get_consumed_energy (surf_resource_t host)
 Get the consumed energy (in joules) of an host. More...
 
xbt_dict_t surf_host_get_mounted_storage_list (surf_resource_t host)
 Get the list of storages mounted on an host. More...
 
xbt_dynar_t surf_host_get_attached_storage_list (surf_resource_t host)
 Get the list of storages attached to an host. More...
 
int surf_host_unlink (surf_resource_t host, surf_file_t fd)
 Unlink a file descriptor. More...
 
size_t surf_host_get_size (surf_resource_t host, surf_file_t fd)
 Get the size of a file on a host. More...
 
size_t surf_host_file_tell (surf_resource_t host, surf_file_t fd)
 Get the current position of the file descriptor. More...
 
int surf_host_file_move (surf_resource_t host, surf_file_t fd, const char *fullpath)
 Move a file to another location on the same mount point. More...
 
int surf_host_file_seek (surf_resource_t host, surf_file_t fd, sg_offset_t offset, int origin)
 Set the position indictator assiociated with the file descriptor to a new position. More...
 
xbt_dict_t surf_storage_get_content (surf_resource_t resource)
 Get the content of a storage. More...
 
sg_size_t surf_storage_get_size (surf_resource_t resource)
 Get the size in bytes of a storage. More...
 
sg_size_t surf_storage_get_free_size (surf_resource_t resource)
 Get the available size in bytes of a storage. More...
 
sg_size_t surf_storage_get_used_size (surf_resource_t resource)
 Get the size in bytes of a storage. More...
 
void * surf_action_get_data (surf_action_t action)
 Get the data associated to the action. More...
 
void surf_action_set_data (surf_action_t action, void *data)
 Set the data associated to the action. More...
 
void surf_action_unref (surf_action_t action)
 Unreference an action. More...
 
double surf_action_get_start_time (surf_action_t action)
 Get the start time of an action. More...
 
double surf_action_get_finish_time (surf_action_t action)
 Get the finish time of an action. More...
 
double surf_action_get_remains (surf_action_t action)
 Get the remains amount of work to do of an action. More...
 
void surf_action_suspend (surf_action_t action)
 Suspend an action. More...
 
void surf_action_resume (surf_action_t action)
 Resume an action. More...
 
void surf_action_cancel (surf_action_t action)
 Cancel an action. More...
 
void surf_action_set_priority (surf_action_t action, double priority)
 Set the priority of an action. More...
 
void surf_action_set_category (surf_action_t action, const char *category)
 Set the category of an action. More...
 
e_surf_action_state_t surf_action_get_state (surf_action_t action)
 Get the state of an action. More...
 
double surf_action_get_cost (surf_action_t action)
 Get the cost of an action. More...
 
void surf_cpu_action_set_affinity (surf_action_t action, surf_resource_t cpu, unsigned long mask)
 [brief desrciption] More...
 
void surf_cpu_action_set_bound (surf_action_t action, double bound)
 [brief description] More...
 
double surf_network_action_get_latency_limited (surf_action_t action)
 [brief description] More...
 
surf_file_t surf_storage_action_get_file (surf_action_t action)
 Get the file associated to a storage action. More...
 
xbt_dict_t surf_storage_action_get_ls_dict (surf_action_t action)
 Get the result dictionary of an ls action. More...
 
const char * surf_storage_get_host (surf_resource_t resource)
 Get the host the storage is attached to. More...
 

Detailed Description

Describes the c bindings of SURF.

Typedef Documentation

typedef Model* surf_model_t

Model datatype.

Generic data structure for a model. The hosts, the CPUs and the network links are examples of models.

Action structure.

Never create s_surf_action_t by yourself ! The actions are created on the fly when you call execute or communicate on a model.

See also
e_surf_action_state_t

Function Documentation

const char* surf_model_name ( surf_model_t  model)

Get the name of a surf model (dont rely on exact value)

This is implemented using typeid(), so it may change with the compiler

surf_action_t surf_model_extract_done_action_set ( surf_model_t  model)

Pop an action from the done actions set.

Parameters
modelThe model from which the action is extracted
Returns
An action in done state
surf_action_t surf_model_extract_failed_action_set ( surf_model_t  model)

Pop an action from the failed actions set.

Parameters
modelThe model from which the action is extracted
Returns
An action in failed state
surf_action_t surf_model_extract_ready_action_set ( surf_model_t  model)

Pop an action from the ready actions set.

Parameters
modelThe model from which the action is extracted
Returns
An action in ready state
surf_action_t surf_model_extract_running_action_set ( surf_model_t  model)

Pop an action from the running actions set.

Parameters
modelThe model from which the action is extracted
Returns
An action in running state
int surf_model_running_action_set_size ( surf_model_t  model)

Get the size of the running action set of a model.

Parameters
modelThe model
Returns
The size of the running action set
surf_action_t surf_host_model_execute_parallel_task ( surf_host_model_t  model,
int  host_nb,
sg_host_t *  host_list,
double *  flops_amount,
double *  bytes_amount,
double  rate 
)

Execute a parallel task.

[long description]

Parameters
modelThe model which handle the parallelisation
host_nbThe number of hosts
host_listThe list of hosts on which the task is executed
flops_amountThe processing amount (in flop) needed to process
bytes_amountThe amount of data (in bytes) needed to transfer
rate[description]
Returns
The action corresponding to the parallele execution task
surf_action_t surf_network_model_communicate ( surf_network_model_t  model,
sg_host_t  src,
sg_host_t  dst,
double  size,
double  rate 
)

Create a communication between two hosts.

Parameters
modelThe model which handle the communication
srcThe source host
dstThe destination host
sizeThe amount of data (in bytes) needed to transfer
rate[description]
Returns
The action corresponding to the communication
const char* surf_resource_name ( surf_cpp_resource_t  resource)

Get the name of a surf resource (cpu, host, network, …)

Parameters
resourceThe surf resource
Returns
The name of the surf resource
xbt_dynar_t surf_host_get_info ( surf_resource_t  host,
surf_file_t  fd 
)

Get the informations of a file descriptor.

The returned xbt_dynar_t contains:

  • the size of the file,
  • the mount point,
  • the storage name,
  • the storage typeId,
  • the storage content type
Parameters
hostThe surf host
fdThe file descriptor
Returns
An xbt_dynar_t with the file informations
sg_size_t surf_host_get_free_size ( surf_resource_t  resource,
const char *  name 
)

Get the available space of the storage at the mount point.

Parameters
resourceThe surf host
nameThe mount point
Returns
The amount of available space in bytes
sg_size_t surf_host_get_used_size ( surf_resource_t  resource,
const char *  name 
)

Get the used space of the storage at the mount point.

Parameters
resourceThe surf host
nameThe mount point
Returns
The amount of used space in bytes
void surf_host_get_params ( surf_resource_t  resource,
vm_params_t  params 
)

Retrieve the params of that VM.

You can use fields ramsize and overcommit on a PM, too.

void surf_host_set_params ( surf_resource_t  resource,
vm_params_t  params 
)

Sets the params of that VM/PM.

You can use fields ramsize and overcommit on a PM, too.

void surf_vm_destroy ( surf_resource_t  resource)

Destroy a VM.

Parameters
resourceThe surf vm
void surf_vm_save ( surf_resource_t  resource)

Save the VM (Not yet implemented)

Parameters
resourceThe surf vm
void surf_vm_restore ( surf_resource_t  resource)

Restore the VM (Not yet implemented)

Parameters
resourceThe surf vm
void surf_vm_migrate ( surf_resource_t  resource,
surf_resource_t  ind_vm_ws_dest 
)

Migrate the VM to the destination host.

Parameters
resourceThe surf vm
ind_vm_ws_destThe destination host
surf_resource_t surf_vm_get_pm ( surf_resource_t  resource)

Get the physical machine hosting the VM.

Parameters
resourceThe surf vm
Returns
The physical machine hosting the VM
void surf_vm_set_bound ( surf_resource_t  resource,
double  bound 
)

[brief description]

[long description]

Parameters
resource[description]
bound[description]
void surf_vm_set_affinity ( surf_resource_t  resource,
surf_resource_t  cpu,
unsigned long  mask 
)

[brief description]

[long description]

Parameters
resource[description]
cpu[description]
mask[description]
surf_action_t surf_cpu_execute ( surf_resource_t  cpu,
double  size 
)

Execute some quantity of computation.

Parameters
cpuThe surf cpu
sizeThe value of the processing amount (in flop) needed to process
Returns
The surf action corresponding to the processing
surf_action_t surf_cpu_sleep ( surf_resource_t  cpu,
double  duration 
)

Make the cpu sleep for duration (in seconds)

[long description]

Parameters
cpuThe surf cpu
durationThe number of seconds to sleep
Returns
The surf action corresponding to the sleeping
double surf_host_get_current_power_peak ( surf_resource_t  host)

Get the host power peak.

[long description]

Parameters
hostThe surf host
Returns
The power peak
double surf_host_get_power_peak_at ( surf_resource_t  host,
int  pstate_index 
)

[brief description]

[long description]

Parameters
host[description]
pstate_index[description]
Returns
[description]
int surf_host_get_nb_pstates ( surf_resource_t  host)

[brief description]

[long description]

Parameters
host[description]
Returns
[description]
double surf_host_get_consumed_energy ( surf_resource_t  host)

Get the consumed energy (in joules) of an host.

Parameters
hostThe surf host
Returns
The consumed energy
xbt_dict_t surf_host_get_mounted_storage_list ( surf_resource_t  host)

Get the list of storages mounted on an host.

Parameters
hostThe surf host
Returns
Dictionary of mount point, Storage
xbt_dynar_t surf_host_get_attached_storage_list ( surf_resource_t  host)

Get the list of storages attached to an host.

Parameters
hostThe surf host
Returns
Dictionary of storage
int surf_host_unlink ( surf_resource_t  host,
surf_file_t  fd 
)

Unlink a file descriptor.

Parameters
hostThe surf host
fdThe file descriptor
Returns
0 if failed to unlink, 1 otherwise
size_t surf_host_get_size ( surf_resource_t  host,
surf_file_t  fd 
)

Get the size of a file on a host.

Parameters
hostThe surf host
fdThe file descriptor
Returns
The size in bytes of the file
size_t surf_host_file_tell ( surf_resource_t  host,
surf_file_t  fd 
)

Get the current position of the file descriptor.

Parameters
hostThe surf host
fdThe file descriptor
Returns
The current position of the file descriptor
int surf_host_file_move ( surf_resource_t  host,
surf_file_t  fd,
const char *  fullpath 
)

Move a file to another location on the same mount point.

[long description]

Parameters
hostThe surf host
fdThe file descriptor
fullpathThe new full path
Returns
MSG_OK if successful, otherwise MSG_TASK_CANCELED
int surf_host_file_seek ( surf_resource_t  host,
surf_file_t  fd,
sg_offset_t  offset,
int  origin 
)

Set the position indictator assiociated with the file descriptor to a new position.

[long description]

Parameters
hostThe surf host
fdThe file descriptor
offsetThe offset from the origin
originPosition used as a reference for the offset
  • SEEK_SET: beginning of the file
  • SEEK_CUR: current position indicator
  • SEEK_END: end of the file
Returns
MSG_OK if successful, otherwise MSG_TASK_CANCELED
xbt_dict_t surf_storage_get_content ( surf_resource_t  resource)

Get the content of a storage.

Parameters
resourceThe surf storage
Returns
A xbt_dict_t with path as keys and size in bytes as values
sg_size_t surf_storage_get_size ( surf_resource_t  resource)

Get the size in bytes of a storage.

Parameters
resourceThe surf storage
Returns
The size in bytes of the storage
sg_size_t surf_storage_get_free_size ( surf_resource_t  resource)

Get the available size in bytes of a storage.

Parameters
resourceThe surf storage
Returns
The available size in bytes of the storage
sg_size_t surf_storage_get_used_size ( surf_resource_t  resource)

Get the size in bytes of a storage.

Parameters
resourceThe surf storage
Returns
The used size in bytes of the storage
void* surf_action_get_data ( surf_action_t  action)

Get the data associated to the action.

Parameters
actionThe surf action
Returns
The data associated to the action
void surf_action_set_data ( surf_action_t  action,
void *  data 
)

Set the data associated to the action.

[long description]

Parameters
actionThe surf action
dataThe new data associated to the action
void surf_action_unref ( surf_action_t  action)

Unreference an action.

Parameters
actionThe surf action
double surf_action_get_start_time ( surf_action_t  action)

Get the start time of an action.

Parameters
actionThe surf action
Returns
The start time in seconds from the beginning of the simulation
double surf_action_get_finish_time ( surf_action_t  action)

Get the finish time of an action.

Parameters
actionThe surf action
Returns
The finish time in seconds from the beginning of the simulation
double surf_action_get_remains ( surf_action_t  action)

Get the remains amount of work to do of an action.

Parameters
actionThe surf action
Returns
The remains amount of work to do
void surf_action_suspend ( surf_action_t  action)

Suspend an action.

Parameters
actionThe surf action
void surf_action_resume ( surf_action_t  action)

Resume an action.

Parameters
actionThe surf action
void surf_action_cancel ( surf_action_t  action)

Cancel an action.

Parameters
actionThe surf action
void surf_action_set_priority ( surf_action_t  action,
double  priority 
)

Set the priority of an action.

[long description]

Parameters
actionThe surf action
priorityThe new priority [TODO]
void surf_action_set_category ( surf_action_t  action,
const char *  category 
)

Set the category of an action.

[long description]

Parameters
actionThe surf action
categoryThe new category of the action
e_surf_action_state_t surf_action_get_state ( surf_action_t  action)

Get the state of an action.

Parameters
actionThe surf action
Returns
The state of the action
double surf_action_get_cost ( surf_action_t  action)

Get the cost of an action.

Parameters
actionThe surf action
Returns
The cost of the action
void surf_cpu_action_set_affinity ( surf_action_t  action,
surf_resource_t  cpu,
unsigned long  mask 
)

[brief desrciption]

[long description]

Parameters
actionThe surf cpu action
cpu[description]
mask[description]
void surf_cpu_action_set_bound ( surf_action_t  action,
double  bound 
)

[brief description]

[long description]

Parameters
actionThe surf cpu action
bound[description]
double surf_network_action_get_latency_limited ( surf_action_t  action)

[brief description]

[long description]

Parameters
actionThe surf network action
surf_file_t surf_storage_action_get_file ( surf_action_t  action)

Get the file associated to a storage action.

Parameters
actionThe surf storage action
Returns
The file associated to a storage action
xbt_dict_t surf_storage_action_get_ls_dict ( surf_action_t  action)

Get the result dictionary of an ls action.

Parameters
actionThe surf storage action
Returns
The dictionry listing a path
const char* surf_storage_get_host ( surf_resource_t  resource)

Get the host the storage is attached to.

Parameters
resourceThe surf storage
Returns
The host name