1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef METASIMGRID_PRIVATE_H
8 #define METASIMGRID_PRIVATE_H
11 #include "simgrid/simix.h"
12 #include "surf/surf.h"
14 #include "xbt/dynar.h"
17 #include "xbt/config.h"
18 #include "instr/instr_private.h"
21 /**************** datatypes **********************************/
23 /********************************* Task **************************************/
25 typedef struct simdata_task {
26 smx_action_t compute; /* SIMIX modeling of computation */
27 smx_action_t comm; /* SIMIX modeling of communication */
28 double message_size; /* Data size */
29 double computation_amount; /* Computation size */
31 msg_process_t receiver;
35 int isused; /* Indicates whether the task is used in SIMIX currently */
36 int host_nb; /* ==0 if sequential task; parallel task if not */
37 /******* Parallel Tasks Only !!!! *******/
38 smx_host_t *host_list;
43 /********************************* File **************************************/
44 typedef struct simdata_file {
48 /*************** Begin GPU ***************/
49 typedef struct simdata_gpu_task {
50 double computation_amount; /* Computation size */
51 double dispatch_latency;
52 double collect_latency;
53 int isused; /* Indicates whether the task is used in SIMIX currently */
54 } s_simdata_gpu_task_t;
55 /*************** End GPU ***************/
57 /******************************* Process *************************************/
59 typedef struct simdata_process {
60 msg_host_t m_host; /* the host on which the process is running */
61 msg_host_t put_host; /* used for debugging purposes */
62 #ifdef MSG_USE_DEPRECATED
63 m_channel_t put_channel; /* used for debugging purposes */
65 smx_action_t waiting_action;
66 msg_task_t waiting_task;
67 char **argv; /* arguments table if any */
68 int argc; /* arguments number if any */
69 msg_error_t last_errno; /* the last value returned by a MSG_function */
71 void* data; /* user data */
72 } s_simdata_process_t, *simdata_process_t;
74 typedef struct process_arg {
82 } s_process_arg_t, *process_arg_t;
84 typedef struct msg_comm {
85 smx_action_t s_comm; /* SIMIX communication object encapsulated (the same for both processes) */
86 msg_task_t task_sent; /* task sent (NULL for the receiver) */
87 msg_task_t *task_received; /* where the task will be received (NULL for the sender) */
88 msg_error_t status; /* status of the communication once finished */
92 /************************** Global variables ********************************/
93 typedef struct MSG_Global {
95 #ifdef MSG_USE_DEPRECATED
99 unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
100 void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst);
101 void_f_pvoid_t process_data_cleanup;
102 } s_MSG_Global_t, *MSG_Global_t;
104 /*extern MSG_Global_t msg_global;*/
105 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
108 /*************************************************************/
110 #ifdef MSG_USE_DEPRECATED
111 # define PROCESS_SET_ERRNO(val) \
112 (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno=val)
113 # define PROCESS_GET_ERRNO() \
114 (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno)
115 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
116 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
119 # define MSG_RETURN(val) return(val)
122 msg_host_t __MSG_host_create(smx_host_t workstation);
123 void __MSG_host_destroy(msg_host_priv_t host);
125 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
126 void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
127 xbt_main_func_t code, void *data,
128 const char *hostname, double kill_time, int argc,
129 char **argv, xbt_dict_t properties, int auto_restart);
130 void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size);
132 void _MSG_action_init(void);
133 void _MSG_action_exit(void);
135 void MSG_post_create_environment(void);
137 /********** Tracing **********/
138 /* declaration of instrumentation functions from msg_task_instr.c */
139 void TRACE_msg_set_task_category(msg_task_t task, const char *category);
140 void TRACE_msg_task_create(msg_task_t task);
141 void TRACE_msg_task_execute_start(msg_task_t task);
142 void TRACE_msg_task_execute_end(msg_task_t task);
143 void TRACE_msg_task_destroy(msg_task_t task);
144 void TRACE_msg_task_get_start(void);
145 void TRACE_msg_task_get_end(double start_time, msg_task_t task);
146 int TRACE_msg_task_put_start(msg_task_t task); //returns TRUE if the task_put_end must be called
147 void TRACE_msg_task_put_end(void);
149 /* declaration of instrumentation functions from msg_process_instr.c */
150 char *instr_process_id (msg_process_t proc, char *str, int len);
151 char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len);
152 void TRACE_msg_process_change_host(msg_process_t process, msg_host_t old_host,
153 msg_host_t new_host);
154 void TRACE_msg_process_create (const char *process_name, int process_pid, msg_host_t host);
155 void TRACE_msg_process_destroy (const char *process_name, int process_pid, msg_host_t host);
156 void TRACE_msg_process_kill(msg_process_t process);
157 void TRACE_msg_process_suspend(msg_process_t process);
158 void TRACE_msg_process_resume(msg_process_t process);
159 void TRACE_msg_process_sleep_in(msg_process_t process); //called from msg/gos.c
160 void TRACE_msg_process_sleep_out(msg_process_t process);
161 void TRACE_msg_process_end(msg_process_t process);
163 /* declaration of instrumentation functions from instr_msg_vm.c */
164 char *instr_vm_id(msg_vm_t vm, char *str, int len);
165 char *instr_vm_id_2(const char *vm_name, char *str, int len);
166 void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host,
167 msg_host_t new_host);
168 void TRACE_msg_vm_start(msg_vm_t vm);
169 void TRACE_msg_vm_create(const char *vm_name, msg_host_t host);
170 void TRACE_msg_vm_kill(msg_vm_t process);
171 void TRACE_msg_vm_suspend(msg_vm_t vm);
172 void TRACE_msg_vm_resume(msg_vm_t vm);
173 void TRACE_msg_vm_save(msg_vm_t vm);
174 void TRACE_msg_vm_restore(msg_vm_t vm);
175 void TRACE_msg_vm_end(msg_vm_t vm);