SimGrid  3.18
Versatile Simulation of Distributed Systems
simix.h File Reference
#include "simgrid/datatypes.h"
#include "simgrid/forward.h"
#include "simgrid/host.h"
#include "xbt/ex.h"
#include "xbt/parmap.h"

Typedefs

typedef struct s_smx_cond_tsmx_cond_t
 
typedef struct s_smx_sem_tsmx_sem_t
 
typedef void(* void_pfn_smxprocess_t) (smx_actor_t)
 
typedef struct s_smx_timer_tsmx_timer_t
 

Enumerations

enum  smx_process_exit_status_t { SMX_EXIT_SUCCESS = 0, SMX_EXIT_FAILURE = 1 }
 
enum  e_smx_state_t {
  SIMIX_WAITING, SIMIX_READY, SIMIX_RUNNING, SIMIX_DONE,
  SIMIX_CANCELED, SIMIX_FAILED, SIMIX_SRC_HOST_FAILURE, SIMIX_DST_HOST_FAILURE,
  SIMIX_TIMEOUT, SIMIX_SRC_TIMEOUT, SIMIX_DST_TIMEOUT, SIMIX_LINK_FAILURE
}
 Host datatypeA location (or host) is any possible place where a process may run. More...
 

Functions

smx_actor_t SIMIX_process_from_PID (aid_t PID)
 Returns the process from PID. More...
 
int SIMIX_context_is_parallel ()
 Returns whether some parallel threads are used for the user contexts. More...
 
int SIMIX_context_get_nthreads ()
 Returns the number of parallel threads used for the user contexts. More...
 
void SIMIX_context_set_nthreads (int nb_threads)
 Sets the number of parallel threads to use for the user contexts. More...
 
int SIMIX_context_get_parallel_threshold ()
 Returns the threshold above which user processes are run in parallel. More...
 
void SIMIX_context_set_parallel_threshold (int threshold)
 Sets the threshold above which user processes are run in parallel. More...
 
e_xbt_parmap_mode_t SIMIX_context_get_parallel_mode ()
 Returns the synchronization mode used when processes are run in parallel. More...
 
void SIMIX_context_set_parallel_mode (e_xbt_parmap_mode_t mode)
 Sets the synchronization mode to use when processes are run in parallel. More...
 
int SIMIX_is_maestro ()
 
void SIMIX_global_init (int *argc, char **argv)
 Initialize SIMIX internal data. More...
 
void SIMIX_set_maestro (void(*code)(void *), void *data)
 
void SIMIX_function_register_process_cleanup (void_pfn_smxprocess_t function)
 Registers a function to cleanup a process. More...
 
void SIMIX_function_register_process_kill (void_pfn_smxprocess_t function)
 Registers a function to kill a process. More...
 
void SIMIX_run ()
 Run the main simulation loop. More...
 
double SIMIX_get_clock ()
 A clock (in second). More...
 
smx_timer_t SIMIX_timer_set (double date, void(*function)(void *), void *arg)
 Set the date to execute a function. More...
 
void SIMIX_timer_remove (smx_timer_t timer)
 cancels a timer that was added earlier More...
 
double SIMIX_timer_next ()
 
double SIMIX_timer_get_date (smx_timer_t timer)
 Returns the date at which the timer will trigger (or 0 if nullptr timer) More...
 
void SIMIX_display_process_status ()
 
void SIMIX_create_environment (const char *file)
 A platform constructor. More...
 
void SIMIX_function_register (const char *name, xbt_main_func_t code)
 Registers a xbt_main_func_t code in a global table. More...
 
void SIMIX_function_register_default (xbt_main_func_t code)
 Registers a xbt_main_func_t code as default value. More...
 
void SIMIX_init_application ()
 
void SIMIX_launch_application (const char *file)
 An application deployer. More...
 
void SIMIX_process_set_function (const char *process_host, const char *process_function, xbt_dynar_t arguments, double process_start_time, double process_kill_time)
 Bypass the parser, get arguments, and set function to each process. More...
 
void SIMIX_maestro_create (void(*code)(void *), void *data)
 Creates and runs the maestro process. More...
 
void SIMIX_process_detach ()
 
void SIMIX_host_off (sg_host_t host, smx_actor_t issuer)
 Stop the host if it is on. More...
 
void SIMIX_host_self_set_data (void *data)
 
voidSIMIX_host_self_get_data ()
 
int SIMIX_process_count ()
 
smx_actor_t SIMIX_process_self ()
 Returns the current agent. More...
 
const char * SIMIX_process_self_get_name ()
 
void SIMIX_process_self_set_data (void *data)
 
voidSIMIX_process_self_get_data ()
 
int SIMIX_process_has_pending_comms (smx_actor_t process)
 Returns whether a process has pending asynchronous communications. More...
 
void SIMIX_process_on_exit_runall (smx_actor_t process)
 
void SIMIX_process_on_exit (smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data)
 
void SIMIX_comm_set_copy_data_callback (void(*callback)(smx_activity_t, void *, size_t))
 
void SIMIX_comm_copy_pointer_callback (smx_activity_t comm, void *buff, size_t buff_size)
 
void SIMIX_comm_copy_buffer_callback (smx_activity_t comm, void *buff, size_t buff_size)
 
smx_activity_t SIMIX_comm_get_send_match (smx_mailbox_t mbox, int(*match_fun)(void *, void *), void *data)
 
int SIMIX_comm_has_send_match (smx_mailbox_t mbox, int(*match_fun)(void *, void *), void *data)
 
int SIMIX_comm_has_recv_match (smx_mailbox_t mbox, int(*match_fun)(void *, void *), void *data)
 
void SIMIX_comm_finish (smx_activity_t synchro)
 Answers the SIMIX simcalls associated to a communication synchro. More...
 
void simcall_call (smx_actor_t process)
 
void simcall_host_set_data (sg_host_t host, void *data)
 
smx_activity_t simcall_execution_start (const char *name, double flops_amount, double priority, double bound, sg_host_t host)
 
smx_activity_t simcall_execution_parallel_start (const char *name, int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, double rate, double timeout)
 Creates a synchro that may involve parallel computation on several hosts and communication between them. More...
 
void simcall_execution_cancel (smx_activity_t execution)
 Cancels an execution synchro. More...
 
void simcall_execution_set_priority (smx_activity_t execution, double priority)
 Changes the priority of an execution synchro. More...
 
void simcall_execution_set_bound (smx_activity_t execution, double bound)
 Changes the capping (the maximum CPU utilization) of an execution synchro. More...
 
e_smx_state_t simcall_execution_wait (smx_activity_t execution)
 Waits for the completion of an execution synchro and destroy it. More...
 
e_smx_state_t simcall_execution_test (smx_activity_t execution)
 
void simcall_process_killall (int reset_pid)
 Kills all SIMIX processes. More...
 
void SIMIX_process_throw (smx_actor_t process, xbt_errcat_t cat, int value, const char *msg)
 Ask another process to raise the given exception. More...
 
void simcall_process_cleanup (smx_actor_t process)
 Cleans up a SIMIX process. More...
 
void simcall_process_suspend (smx_actor_t process)
 Suspends a process. More...
 
int simcall_process_count ()
 Returns the amount of SIMIX processes in the system. More...
 
void simcall_process_set_data (smx_actor_t process, void *data)
 Set the user data of a smx_actor_t. More...
 
void simcall_process_set_kill_time (smx_actor_t process, double kill_time)
 Set the kill time of a process. More...
 
void simcall_process_on_exit (smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data)
 Add an on_exit function Add an on_exit function which will be executed when the process exits/is killed. More...
 
void simcall_process_join (smx_actor_t process, double timeout)
 
e_smx_state_t simcall_process_sleep (double duration)
 Creates a new sleep SIMIX synchro. More...
 
void simcall_comm_cancel (smx_activity_t comm)
 
unsigned int simcall_comm_waitany (xbt_dynar_t comms, double timeout)
 
void simcall_comm_wait (smx_activity_t comm, double timeout)
 
int simcall_comm_test (smx_activity_t comm)
 
int simcall_comm_testany (smx_activity_t *comms, size_t count)
 
void simcall_set_category (smx_activity_t synchro, const char *category)
 Set the category of an synchro. More...
 
smx_mutex_t simcall_mutex_init ()
 
smx_mutex_t SIMIX_mutex_ref (smx_mutex_t mutex)
 Increase the refcount for this mutex. More...
 
void SIMIX_mutex_unref (smx_mutex_t mutex)
 Decrease the refcount for this mutex. More...
 
void simcall_mutex_lock (smx_mutex_t mutex)
 
int simcall_mutex_trylock (smx_mutex_t mutex)
 
void simcall_mutex_unlock (smx_mutex_t mutex)
 
smx_cond_t simcall_cond_init ()
 
void SIMIX_cond_unref (smx_cond_t cond)
 
smx_cond_t SIMIX_cond_ref (smx_cond_t cond)
 
void simcall_cond_signal (smx_cond_t cond)
 
void simcall_cond_wait (smx_cond_t cond, smx_mutex_t mutex)
 
void simcall_cond_wait_timeout (smx_cond_t cond, smx_mutex_t mutex, double max_duration)
 
void simcall_cond_broadcast (smx_cond_t cond)
 
void SIMIX_sem_destroy (smx_sem_t sem)
 Destroys a semaphore. More...
 
void simcall_sem_acquire (smx_sem_t sem)
 
void simcall_sem_acquire_timeout (smx_sem_t sem, double max_duration)
 
sg_size_t simcall_storage_read (surf_storage_t st, sg_size_t size)
 
sg_size_t simcall_storage_write (surf_storage_t fd, sg_size_t size)
 
int simcall_mc_random (int min, int max)
 

Variables

unsigned smx_context_stack_size
 
int smx_context_stack_size_was_set
 
unsigned smx_context_guard_size
 
int smx_context_guard_size_was_set
 

Typedef Documentation

◆ void_pfn_smxprocess_t

typedef void(* void_pfn_smxprocess_t) (smx_actor_t)

◆ smx_timer_t

typedef struct s_smx_timer_t* smx_timer_t

Enumeration Type Documentation

◆ smx_process_exit_status_t

Enumerator
SMX_EXIT_SUCCESS 
SMX_EXIT_FAILURE 

Function Documentation

◆ SIMIX_process_from_PID()

smx_actor_t SIMIX_process_from_PID ( aid_t  PID)

Returns the process from PID.

◆ SIMIX_context_is_parallel()

int SIMIX_context_is_parallel ( )

Returns whether some parallel threads are used for the user contexts.

◆ SIMIX_context_get_nthreads()

int SIMIX_context_get_nthreads ( )

Returns the number of parallel threads used for the user contexts.

Returns
the number of threads (1 means no parallelism)

◆ SIMIX_context_set_nthreads()

void SIMIX_context_set_nthreads ( int  nb_threads)

Sets the number of parallel threads to use for the user contexts.

This function should be called before initializing SIMIX. A value of 1 means no parallelism (1 thread only). If the value is greater than 1, the thread support must be enabled.

Parameters
nb_threadsthe number of threads to use

◆ SIMIX_context_get_parallel_threshold()

int SIMIX_context_get_parallel_threshold ( )

Returns the threshold above which user processes are run in parallel.

If the number of threads is set to 1, there is no parallelism and this threshold has no effect.

Returns
when the number of user processes ready to run is above this threshold, they are run in parallel

◆ SIMIX_context_set_parallel_threshold()

void SIMIX_context_set_parallel_threshold ( int  threshold)

Sets the threshold above which user processes are run in parallel.

If the number of threads is set to 1, there is no parallelism and this threshold has no effect.

Parameters
thresholdwhen the number of user processes ready to run is above this threshold, they are run in parallel

◆ SIMIX_context_get_parallel_mode()

e_xbt_parmap_mode_t SIMIX_context_get_parallel_mode ( )

Returns the synchronization mode used when processes are run in parallel.

Returns
how threads are synchronized if processes are run in parallel

◆ SIMIX_context_set_parallel_mode()

void SIMIX_context_set_parallel_mode ( e_xbt_parmap_mode_t  mode)

Sets the synchronization mode to use when processes are run in parallel.

Parameters
modehow to synchronize threads if processes are run in parallel

◆ SIMIX_is_maestro()

int SIMIX_is_maestro ( )

◆ SIMIX_set_maestro()

void SIMIX_set_maestro ( void(*)(void *)  code,
void data 
)

◆ SIMIX_function_register_process_cleanup()

void SIMIX_function_register_process_cleanup ( void_pfn_smxprocess_t  function)

Registers a function to cleanup a process.

This function registers a user function to be called when a process ends properly.

Parameters
functioncleanup process function

◆ SIMIX_function_register_process_kill()

void SIMIX_function_register_process_kill ( void_pfn_smxprocess_t  function)

Registers a function to kill a process.

This function registers a function to be called when a process is killed. The function has to call the SIMIX_process_kill().

Parameters
functionKill process function

◆ SIMIX_timer_set()

smx_timer_t SIMIX_timer_set ( double  date,
void(*)(void *)  callback,
void arg 
)

Set the date to execute a function.

Set the date to execute the function on the surf.

Parameters
dateDate to execute function
callbackFunction to be executed
argParameters of the function

◆ SIMIX_timer_remove()

void SIMIX_timer_remove ( smx_timer_t  timer)

cancels a timer that was added earlier

◆ SIMIX_timer_next()

double SIMIX_timer_next ( )

◆ SIMIX_timer_get_date()

double SIMIX_timer_get_date ( smx_timer_t  timer)

Returns the date at which the timer will trigger (or 0 if nullptr timer)

◆ SIMIX_display_process_status()

void SIMIX_display_process_status ( )

◆ SIMIX_create_environment()

void SIMIX_create_environment ( const char *  file)

A platform constructor.

Creates a new platform, including hosts, links and the routing_table.

Parameters
filea filename of a xml description of a platform. This file follows this DTD :
\include surfxml.dtd

Here is a small example of such a platform

\include small_platform.xml

◆ SIMIX_function_register()

void SIMIX_function_register ( const char *  name,
xbt_main_func_t  code 
)

Registers a xbt_main_func_t code in a global table.

Registers a code function in a global table. This table is then used by SIMIX_launch_application.

Parameters
namethe reference name of the function.
codethe function

◆ SIMIX_function_register_default()

void SIMIX_function_register_default ( xbt_main_func_t  code)

Registers a xbt_main_func_t code as default value.

Registers a code function as being the default value. This function will get used by SIMIX_launch_application() when there is no registered function of the requested name in.

Parameters
codethe function

◆ SIMIX_init_application()

void SIMIX_init_application ( )

◆ SIMIX_launch_application()

void SIMIX_launch_application ( const char *  file)

An application deployer.

Creates the process described in file.

Parameters
filea filename of a xml description of the application. This file follows this DTD :
\include surfxml.dtd

Here is a small example of such a platform

\include small_deployment.xml

◆ SIMIX_process_set_function()

void SIMIX_process_set_function ( const char *  process_host,
const char *  process_function,
xbt_dynar_t  arguments,
double  process_start_time,
double  process_kill_time 
)

Bypass the parser, get arguments, and set function to each process.

◆ SIMIX_maestro_create()

void SIMIX_maestro_create ( void(*)(void *)  code,
void data 
)

Creates and runs the maestro process.

◆ SIMIX_process_detach()

void SIMIX_process_detach ( )

◆ SIMIX_host_off()

void SIMIX_host_off ( sg_host_t  host,
smx_actor_t  issuer 
)

Stop the host if it is on.

◆ SIMIX_host_self_set_data()

void SIMIX_host_self_set_data ( void data)

◆ SIMIX_host_self_get_data()

void* SIMIX_host_self_get_data ( )

◆ SIMIX_process_count()

int SIMIX_process_count ( )

◆ SIMIX_process_self()

smx_actor_t SIMIX_process_self ( )

Returns the current agent.

This functions returns the currently running SIMIX process.

Returns
The SIMIX process

◆ SIMIX_process_self_get_name()

const char* SIMIX_process_self_get_name ( )

◆ SIMIX_process_self_set_data()

void SIMIX_process_self_set_data ( void data)

◆ SIMIX_process_self_get_data()

void* SIMIX_process_self_get_data ( )

◆ SIMIX_process_has_pending_comms()

int SIMIX_process_has_pending_comms ( smx_actor_t  process)

Returns whether a process has pending asynchronous communications.

Returns
true if there are asynchronous communications in this process

◆ SIMIX_process_on_exit_runall()

void SIMIX_process_on_exit_runall ( smx_actor_t  process)

◆ SIMIX_process_on_exit()

void SIMIX_process_on_exit ( smx_actor_t  process,
int_f_pvoid_pvoid_t  fun,
void data 
)

◆ SIMIX_comm_set_copy_data_callback()

void SIMIX_comm_set_copy_data_callback ( void(*)(smx_activity_t, void *, size_t)  callback)

◆ SIMIX_comm_copy_pointer_callback()

void SIMIX_comm_copy_pointer_callback ( smx_activity_t  comm,
void buff,
size_t  buff_size 
)

◆ SIMIX_comm_copy_buffer_callback()

void SIMIX_comm_copy_buffer_callback ( smx_activity_t  comm,
void buff,
size_t  buff_size 
)

◆ SIMIX_comm_get_send_match()

smx_activity_t SIMIX_comm_get_send_match ( smx_mailbox_t  mbox,
int(*)(void *, void *)  match_fun,
void data 
)

◆ SIMIX_comm_has_send_match()

int SIMIX_comm_has_send_match ( smx_mailbox_t  mbox,
int(*)(void *, void *)  match_fun,
void data 
)

◆ SIMIX_comm_has_recv_match()

int SIMIX_comm_has_recv_match ( smx_mailbox_t  mbox,
int(*)(void *, void *)  match_fun,
void data 
)

◆ SIMIX_comm_finish()

void SIMIX_comm_finish ( smx_activity_t  synchro)

Answers the SIMIX simcalls associated to a communication synchro.

Parameters
synchroa finished communication synchro

◆ simcall_call()

void simcall_call ( smx_actor_t  process)

◆ simcall_host_set_data()

void simcall_host_set_data ( sg_host_t  host,
void data 
)

◆ simcall_execution_start()

smx_activity_t simcall_execution_start ( const char *  name,
double  flops_amount,
double  priority,
double  bound,
sg_host_t  host 
)

◆ simcall_execution_test()

e_smx_state_t simcall_execution_test ( smx_activity_t  execution)

◆ SIMIX_process_throw()

void SIMIX_process_throw ( smx_actor_t  process,
xbt_errcat_t  cat,
int  value,
const char *  msg 
)

Ask another process to raise the given exception.

Parameters
processThe process that should raise that exception
catcategory of exception
valuevalue associated to the exception
msgstring information associated to the exception

◆ simcall_process_join()

void simcall_process_join ( smx_actor_t  process,
double  timeout 
)

◆ simcall_set_category()

void simcall_set_category ( smx_activity_t  synchro,
const char *  category 
)

Set the category of an synchro.

This functions changes the category only. It calls a surf function.

Parameters
synchroThe execution synchro
categoryThe tracing category

◆ SIMIX_mutex_ref()

smx_mutex_t SIMIX_mutex_ref ( smx_mutex_t  mutex)

Increase the refcount for this mutex.

◆ SIMIX_mutex_unref()

void SIMIX_mutex_unref ( smx_mutex_t  mutex)

Decrease the refcount for this mutex.

◆ SIMIX_cond_unref()

void SIMIX_cond_unref ( smx_cond_t  cond)

◆ SIMIX_cond_ref()

smx_cond_t SIMIX_cond_ref ( smx_cond_t  cond)

◆ SIMIX_sem_destroy()

void SIMIX_sem_destroy ( smx_sem_t  sem)

Destroys a semaphore.

◆ simcall_storage_read()

sg_size_t simcall_storage_read ( surf_storage_t  st,
sg_size_t  size 
)

◆ simcall_storage_write()

sg_size_t simcall_storage_write ( surf_storage_t  fd,
sg_size_t  size 
)

◆ simcall_mc_random()

int simcall_mc_random ( int  min,
int  max 
)

Variable Documentation

◆ smx_context_stack_size

unsigned smx_context_stack_size

◆ smx_context_stack_size_was_set

int smx_context_stack_size_was_set

◆ smx_context_guard_size

unsigned smx_context_guard_size

◆ smx_context_guard_size_was_set

int smx_context_guard_size_was_set