Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use msg_process_t instead of m_process_t
[simgrid.git] / src / msg / msg_private.h
1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #ifndef METASIMGRID_PRIVATE_H
8 #define METASIMGRID_PRIVATE_H
9
10 #include "msg/msg.h"
11 #include "simgrid/simix.h"
12 #include "surf/surf.h"
13 #include "xbt/fifo.h"
14 #include "xbt/dynar.h"
15 #include "xbt/swag.h"
16 #include "xbt/dict.h"
17 #include "xbt/config.h"
18 #include "instr/instr_private.h"
19
20 SG_BEGIN_DECL()
21
22 /**************** datatypes **********************************/
23
24 /********************************* Task **************************************/
25
26 typedef struct simdata_task {
27   smx_action_t compute;         /* SIMIX modeling of computation */
28   smx_action_t comm;            /* SIMIX modeling of communication */
29   double message_size;          /* Data size */
30   double computation_amount;    /* Computation size */
31   msg_process_t sender;
32   msg_process_t receiver;
33   m_host_t source;
34   double priority;
35   double rate;
36   int isused;  /* Indicates whether the task is used in SIMIX currently */
37   int host_nb;                  /* ==0 if sequential task; parallel task if not */
38   /*******  Parallel Tasks Only !!!! *******/
39   smx_host_t *host_list;
40   double *comp_amount;
41   double *comm_amount;
42 } s_simdata_task_t;
43
44 /********************************* File **************************************/
45 typedef struct simdata_file {
46   smx_file_t smx_file;
47 } s_simdata_file_t;
48
49 /*************** Begin GPU ***************/
50 typedef struct simdata_gpu_task {
51   double computation_amount;    /* Computation size */
52   double dispatch_latency;
53   double collect_latency;
54   int isused;  /* Indicates whether the task is used in SIMIX currently */
55 } s_simdata_gpu_task_t;
56 /*************** End GPU ***************/
57
58 /******************************* Process *************************************/
59
60 typedef struct simdata_process {
61   m_host_t m_host;              /* the host on which the process is running */
62   int PID;                      /* used for debugging purposes */
63   int PPID;                     /* The parent PID */
64   m_host_t put_host;            /* used for debugging purposes */
65 #ifdef MSG_USE_DEPRECATED
66   m_channel_t put_channel;      /* used for debugging purposes */
67 #endif
68   smx_action_t waiting_action;
69   m_task_t waiting_task;
70   char **argv;                  /* arguments table if any */
71   int argc;                     /* arguments number if any */
72   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
73
74   msg_vm_t vm;                 /* virtual machine the process is in */
75
76   void* data;                   /* user data */
77 } s_simdata_process_t, *simdata_process_t;
78
79 typedef struct process_arg {
80   const char *name;
81   xbt_main_func_t code;
82   void *data;
83   m_host_t m_host;
84   int argc;
85   char **argv;
86   double kill_time;
87 } s_process_arg_t, *process_arg_t;
88
89 typedef struct msg_comm {
90   smx_action_t s_comm;          /* SIMIX communication object encapsulated (the same for both processes) */
91   m_task_t task_sent;           /* task sent (NULL for the receiver) */
92   m_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 */
94 } s_msg_comm_t;
95
96 typedef enum {
97   msg_vm_state_suspended, msg_vm_state_running, msg_vm_state_migrating
98 } e_msg_vm_state_t;
99
100 typedef struct msg_vm {
101   s_xbt_swag_hookup_t all_vms_hookup;
102   s_xbt_swag_hookup_t host_vms_hookup;
103   xbt_dynar_t processes;
104   e_msg_vm_state_t state;
105   m_host_t location;
106   int coreAmount;
107 } s_msg_vm_t;
108
109 /************************** Global variables ********************************/
110 typedef struct MSG_Global {
111   xbt_fifo_t host;
112 #ifdef MSG_USE_DEPRECATED
113   int max_channel;
114 #endif
115   int PID;
116   int session;
117   unsigned long int sent_msg;   /* Total amount of messages sent during the simulation */
118   void (*task_copy_callback) (m_task_t task, msg_process_t src, msg_process_t dst);
119   void_f_pvoid_t process_data_cleanup;
120   xbt_swag_t vms;
121 } s_MSG_Global_t, *MSG_Global_t;
122
123 /*extern MSG_Global_t msg_global;*/
124 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
125
126
127 /*************************************************************/
128
129 #ifdef MSG_USE_DEPRECATED
130 #  define PROCESS_SET_ERRNO(val) \
131   (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno=val)
132 #  define PROCESS_GET_ERRNO() \
133   (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno)
134 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
135 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
136
137 #else
138 #  define MSG_RETURN(val) return(val)
139 #endif
140
141 m_host_t __MSG_host_create(smx_host_t workstation);
142 void __MSG_host_destroy(m_host_t host);
143
144 void __MSG_display_process_status(void);
145
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,  int argc,
150                                    char **argv, xbt_dict_t properties, int auto_restart);
151 void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size);
152
153 void _MSG_action_init(void);
154 void _MSG_action_exit(void);
155
156 SG_END_DECL()
157 #endif