1 /* Copyright (c) 2004-2014. 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;
34 double bound; /* Capping for CPU resource */
35 double rate; /* Capping for network resource */
37 /* CPU affinity database of this task */
38 xbt_dict_t affinity_mask_db; /* smx_host_t host => unsigned long mask */
40 int isused; /* Indicates whether the task is used in SIMIX currently */
41 int host_nb; /* ==0 if sequential task; parallel task if not */
42 /******* Parallel Tasks Only !!!! *******/
43 smx_host_t *host_list;
48 /********************************* File **************************************/
49 typedef struct simdata_file {
53 /*************** Begin GPU ***************/
54 typedef struct simdata_gpu_task {
55 double computation_amount; /* Computation size */
56 double dispatch_latency;
57 double collect_latency;
58 int isused; /* Indicates whether the task is used in SIMIX currently */
59 } s_simdata_gpu_task_t;
60 /*************** End GPU ***************/
62 /******************************* Process *************************************/
64 typedef struct simdata_process {
65 msg_host_t m_host; /* the host on which the process is running */
66 msg_host_t put_host; /* used for debugging purposes */
67 #ifdef MSG_USE_DEPRECATED
68 m_channel_t put_channel; /* used for debugging purposes */
70 smx_action_t waiting_action;
71 msg_task_t waiting_task;
72 char **argv; /* arguments table if any */
73 int argc; /* arguments number if any */
74 msg_error_t last_errno; /* the last value returned by a MSG_function */
76 void* data; /* user data */
77 } s_simdata_process_t, *simdata_process_t;
79 typedef struct process_arg {
87 } s_process_arg_t, *process_arg_t;
89 typedef struct msg_comm {
90 smx_action_t s_comm; /* SIMIX communication object encapsulated (the same for both processes) */
91 msg_task_t task_sent; /* task sent (NULL for the receiver) */
92 msg_task_t *task_received; /* where the task will be received (NULL for the sender) */
93 msg_error_t status; /* status of the communication once finished */
97 /******************************* VM *************************************/
98 typedef struct dirty_page {
100 double prev_remaining;
102 } s_dirty_page, *dirty_page_t;
104 XBT_PUBLIC_DATA(const char*) MSG_vm_get_property_value(msg_vm_t vm, const char *name);
105 XBT_PUBLIC_DATA(xbt_dict_t) MSG_vm_get_properties(msg_vm_t vm);
106 XBT_PUBLIC_DATA(void) MSG_vm_set_property_value(msg_vm_t vm, const char *name, void *value, void_f_pvoid_t free_ctn);
107 XBT_PUBLIC_DATA(msg_vm_t) MSG_vm_get_by_name(const char *name);
108 XBT_PUBLIC_DATA(const char*) MSG_vm_get_name(msg_vm_t vm);
110 /************************** Global variables ********************************/
111 typedef struct MSG_Global {
113 #ifdef MSG_USE_DEPRECATED
117 unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
118 void (*task_copy_callback) (msg_task_t task, msg_process_t src, msg_process_t dst);
119 void_f_pvoid_t process_data_cleanup;
120 } s_MSG_Global_t, *MSG_Global_t;
122 /*extern MSG_Global_t msg_global;*/
123 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
126 /*************************************************************/
128 #ifdef MSG_USE_DEPRECATED
129 # define PROCESS_SET_ERRNO(val) \
130 (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno=val)
131 # define PROCESS_GET_ERRNO() \
132 (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno)
133 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
134 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
137 # define MSG_RETURN(val) return(val)
140 msg_host_t __MSG_host_create(smx_host_t workstation);
141 msg_storage_t __MSG_storage_create(smx_storage_t storage);
142 void __MSG_host_destroy(msg_host_t host);
143 void __MSG_storage_destroy(msg_storage_priv_t host);
144 void __MSG_file_destroy(msg_file_priv_t host);
146 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
147 void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
148 xbt_main_func_t code, void *data,
149 const char *hostname, double kill_time,
150 int argc, char **argv,
151 xbt_dict_t properties, int auto_restart,
152 smx_process_t parent_process);
153 void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size);
155 void _MSG_action_init(void);
156 void _MSG_action_exit(void);
158 void MSG_post_create_environment(void);
160 static inline void *msg_host_resource_priv(const void *host) {
161 return xbt_lib_get_level((void *)host, MSG_HOST_LEVEL);
164 void MSG_host_add_task(msg_host_t host, msg_task_t task);
165 void MSG_host_del_task(msg_host_t host, msg_task_t task);
167 /********** Tracing **********/
168 /* declaration of instrumentation functions from msg_task_instr.c */
169 void TRACE_msg_set_task_category(msg_task_t task, const char *category);
170 void TRACE_msg_task_create(msg_task_t task);
171 void TRACE_msg_task_execute_start(msg_task_t task);
172 void TRACE_msg_task_execute_end(msg_task_t task);
173 void TRACE_msg_task_destroy(msg_task_t task);
174 void TRACE_msg_task_get_start(void);
175 void TRACE_msg_task_get_end(double start_time, msg_task_t task);
176 int TRACE_msg_task_put_start(msg_task_t task); //returns TRUE if the task_put_end must be called
177 void TRACE_msg_task_put_end(void);
179 /* declaration of instrumentation functions from msg_process_instr.c */
180 char *instr_process_id (msg_process_t proc, char *str, int len);
181 char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len);
182 void TRACE_msg_process_change_host(msg_process_t process, msg_host_t old_host,
183 msg_host_t new_host);
184 void TRACE_msg_process_create (const char *process_name, int process_pid, msg_host_t host);
185 void TRACE_msg_process_destroy (const char *process_name, int process_pid, msg_host_t host);
186 void TRACE_msg_process_kill(msg_process_t process);
187 void TRACE_msg_process_suspend(msg_process_t process);
188 void TRACE_msg_process_resume(msg_process_t process);
189 void TRACE_msg_process_sleep_in(msg_process_t process); //called from msg/gos.c
190 void TRACE_msg_process_sleep_out(msg_process_t process);
191 void TRACE_msg_process_end(msg_process_t process);
193 /* declaration of instrumentation functions from instr_msg_vm.c */
194 char *instr_vm_id(msg_vm_t vm, char *str, int len);
195 char *instr_vm_id_2(const char *vm_name, char *str, int len);
196 void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host,
197 msg_host_t new_host);
198 void TRACE_msg_vm_start(msg_vm_t vm);
199 void TRACE_msg_vm_create(const char *vm_name, msg_host_t host);
200 void TRACE_msg_vm_kill(msg_vm_t process);
201 void TRACE_msg_vm_suspend(msg_vm_t vm);
202 void TRACE_msg_vm_resume(msg_vm_t vm);
203 void TRACE_msg_vm_save(msg_vm_t vm);
204 void TRACE_msg_vm_restore(msg_vm_t vm);
205 void TRACE_msg_vm_end(msg_vm_t vm);