SimGrid  3.16
Versatile Simulation of Distributed Systems
Task Management Functions

Detailed Description

Task structure of MSG (msg_task_t) and associated functions.

Since most scheduling algorithms rely on a concept of task that can be either computed locally or transferred on another processor, it seems to be the right level of abstraction for our purposes.

See Task Actions to see how to put the tasks in action.

A task may then be defined by a computing amount, a message size and some private data.

Macros

#define MSG_TASK_UNINITIALIZED   NULL
 Default value for an uninitialized msg_task_t. More...
 
#define MSG_TASK_UNINITIALIZED   NULL
 Default value for an uninitialized msg_task_t. More...
 

Typedefs

typedef struct msg_taskmsg_task_t
 Task datatype. More...
 
typedef struct msg_taskmsg_task_t
 Task datatype. More...
 

Functions

msg_task_t MSG_task_create (const char *name, double flop_amount, double message_size, void *data)
 Creates a new msg_task_t. More...
 
msg_task_t MSG_parallel_task_create (const char *name, int host_nb, const msg_host_t *host_list, double *flops_amount, double *bytes_amount, void *data)
 Creates a new msg_task_t (a parallel one....). More...
 
voidMSG_task_get_data (msg_task_t task)
 Return the user data of a msg_task_t. More...
 
void MSG_task_set_data (msg_task_t task, void *data)
 Sets the user data of a msg_task_t. More...
 
void MSG_task_set_copy_callback (void(*callback)(msg_task_t task, msg_process_t sender, msg_process_t receiver))
 Sets a function to be called when a task has just been copied. More...
 
msg_process_t MSG_task_get_sender (msg_task_t task)
 Return the sender of a msg_task_t. More...
 
msg_host_t MSG_task_get_source (msg_task_t task)
 Return the source of a msg_task_t. More...
 
const char * MSG_task_get_name (msg_task_t task)
 Return the name of a msg_task_t. More...
 
void MSG_task_set_name (msg_task_t task, const char *name)
 Sets the name of a msg_task_t. More...
 
msg_error_t MSG_task_destroy (msg_task_t task)
 Destroy a msg_task_t. More...
 
double MSG_task_get_flops_amount (msg_task_t task)
 Returns the remaining amount of flops needed to execute a task msg_task_t. More...
 
void MSG_task_set_flops_amount (msg_task_t task, double flops_amount)
 set the computation amount needed to process a task msg_task_t. More...
 
void MSG_task_set_bytes_amount (msg_task_t task, double data_size)
 set the amount data attached with a task msg_task_t. More...
 
double MSG_task_get_remaining_communication (msg_task_t task)
 Returns the total amount received by a task msg_task_t. More...
 
double MSG_task_get_bytes_amount (msg_task_t task)
 Returns the size of the data attached to a task msg_task_t. More...
 
void MSG_task_set_priority (msg_task_t task, double priority)
 Changes the priority of a computation task. More...
 
void MSG_task_set_bound (msg_task_t task, double bound)
 Changes the maximum CPU utilization of a computation task. More...
 

Macro Definition Documentation

◆ MSG_TASK_UNINITIALIZED [1/2]

#define MSG_TASK_UNINITIALIZED   NULL

Default value for an uninitialized msg_task_t.

◆ MSG_TASK_UNINITIALIZED [2/2]

#define MSG_TASK_UNINITIALIZED   NULL

Default value for an uninitialized msg_task_t.

Typedef Documentation

◆ msg_task_t [1/2]

typedef struct msg_task* msg_task_t

Task datatype.

A task may then be defined by a computing amount, a message size and some private data.

◆ msg_task_t [2/2]

typedef struct msg_task* msg_task_t

Task datatype.

A task may then be defined by a computing amount, a message size and some private data.

Function Documentation

◆ MSG_task_create()

msg_task_t MSG_task_create ( const char *  name,
double  flop_amount,
double  message_size,
void data 
)

Creates a new msg_task_t.

A constructor for msg_task_t taking four arguments and returning the corresponding object.

Parameters
namea name for the object. It is for user-level information and can be nullptr.
flop_amounta value of the processing amount (in flop) needed to process this new task. If 0, then it cannot be executed with MSG_task_execute(). This value has to be >=0.
message_sizea value of the amount of data (in bytes) needed to transfer this new task. If 0, then it cannot be transfered with MSG_task_send() and MSG_task_recv(). This value has to be >=0.
dataa pointer to any data may want to attach to the new object. It is for user-level information and can be nullptr. It can be retrieved with the function MSG_task_get_data.
See also
msg_task_t
Returns
The new corresponding object.

◆ MSG_parallel_task_create()

msg_task_t MSG_parallel_task_create ( const char *  name,
int  host_nb,
const msg_host_t host_list,
double *  flops_amount,
double *  bytes_amount,
void data 
)

Creates a new msg_task_t (a parallel one....).

A constructor for msg_task_t taking six arguments and returning the corresponding object.

Parameters
namea name for the object. It is for user-level information and can be nullptr.
host_nbthe number of hosts implied in the parallel task.
host_listan array of host_nb msg_host_t.
flops_amountan array of host_nb doubles. flops_amount[i] is the total number of operations that have to be performed on host_list[i].
bytes_amountan array of host_nb* host_nb doubles.
dataa pointer to any data may want to attach to the new object. It is for user-level information and can be nullptr. It can be retrieved with the function MSG_task_get_data.
See also
msg_task_t
Returns
The new corresponding object.

◆ MSG_task_get_data()

void* MSG_task_get_data ( msg_task_t  task)

Return the user data of a msg_task_t.

This function checks whether task is a valid pointer and return the user data associated to task if possible.

◆ MSG_task_set_data()

void MSG_task_set_data ( msg_task_t  task,
void data 
)

Sets the user data of a msg_task_t.

This function allows to associate a new pointer to the user data associated of task.

◆ MSG_task_set_copy_callback()

void MSG_task_set_copy_callback ( void(*)(msg_task_t task, msg_process_t sender, msg_process_t receiver)  callback)

Sets a function to be called when a task has just been copied.

Parameters
callbacka callback function

◆ MSG_task_get_sender()

msg_process_t MSG_task_get_sender ( msg_task_t  task)

Return the sender of a msg_task_t.

This functions returns the msg_process_t which sent this task

◆ MSG_task_get_source()

msg_host_t MSG_task_get_source ( msg_task_t  task)

Return the source of a msg_task_t.

This functions returns the msg_host_t from which this task was sent

◆ MSG_task_get_name()

const char* MSG_task_get_name ( msg_task_t  task)

Return the name of a msg_task_t.

This functions returns the name of a msg_task_t as specified on creation

◆ MSG_task_set_name()

void MSG_task_set_name ( msg_task_t  task,
const char *  name 
)

Sets the name of a msg_task_t.

This functions allows to associate a name to a task

◆ MSG_task_destroy()

msg_error_t MSG_task_destroy ( msg_task_t  task)

Destroy a msg_task_t.

Destructor for msg_task_t. Note that you should free user data, if any, before calling this function.

Only the process that owns the task can destroy it. The owner changes after a successful send. If a task is successfully sent, the receiver becomes the owner and is supposed to destroy it. The sender should not use it anymore. If the task failed to be sent, the sender remains the owner of the task.

◆ MSG_task_get_flops_amount()

double MSG_task_get_flops_amount ( msg_task_t  task)

Returns the remaining amount of flops needed to execute a task msg_task_t.

Once a task has been processed, this amount is set to 0. If you want, you can reset this value with MSG_task_set_flops_amount before restarting the task.

◆ MSG_task_set_flops_amount()

void MSG_task_set_flops_amount ( msg_task_t  task,
double  flops_amount 
)

set the computation amount needed to process a task msg_task_t.

Warning
If the computation is ongoing (already started and not finished), it is not modified by this call. Moreover, after its completion, the ongoing execution with set the flops_amount to zero, overriding any value set during the execution.

◆ MSG_task_set_bytes_amount()

void MSG_task_set_bytes_amount ( msg_task_t  task,
double  data_size 
)

set the amount data attached with a task msg_task_t.

Warning
If the transfer is ongoing (already started and not finished), it is not modified by this call.

◆ MSG_task_get_remaining_communication()

double MSG_task_get_remaining_communication ( msg_task_t  task)

Returns the total amount received by a task msg_task_t.

If the communication does not exist it will return 0. So, if the communication has FINISHED or FAILED it returns zero.

◆ MSG_task_get_bytes_amount()

double MSG_task_get_bytes_amount ( msg_task_t  task)

Returns the size of the data attached to a task msg_task_t.

◆ MSG_task_set_priority()

void MSG_task_set_priority ( msg_task_t  task,
double  priority 
)

Changes the priority of a computation task.

This priority doesn't affect the transfer rate. A priority of 2 will make a task receive two times more cpu power than the other ones.

◆ MSG_task_set_bound()

void MSG_task_set_bound ( msg_task_t  task,
double  bound 
)

Changes the maximum CPU utilization of a computation task.

Unit is flops/s.

For VMs, there is a pitfall. Please see MSG_vm_set_bound().