Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
[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 "simix/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 typedef struct simdata_host {
24   smx_host_t smx_host;          /* SURF modeling                                                                */
25   msg_mailbox_t *mailboxes;     /* mailboxes to store msg tasks of of the host  */
26 } s_simdata_host_t;
27
28 /********************************* Task **************************************/
29
30 typedef struct simdata_task {
31   smx_action_t compute;         /* SIMIX modeling of computation */
32   smx_action_t comm;            /* SIMIX modeling of communication */
33   double message_size;          /* Data size */
34   double computation_amount;    /* Computation size */
35   m_process_t sender;
36   m_process_t receiver;
37   m_host_t source;
38   double priority;
39   double rate;
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;
44   double *comp_amount;
45   double *comm_amount;
46 } s_simdata_task_t;
47
48 /********************************* File **************************************/
49 typedef struct simdata_file {
50   smx_file_t smx_file;
51 } s_simdata_file_t;
52
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 ***************/
61
62 /******************************* Process *************************************/
63
64 typedef struct simdata_process {
65   m_host_t m_host;              /* the host on which the process is running */
66   int PID;                      /* used for debugging purposes */
67   int PPID;                     /* The parent PID */
68   m_host_t put_host;            /* used for debugging purposes */
69 #ifdef MSG_USE_DEPRECATED
70   m_channel_t put_channel;      /* used for debugging purposes */
71 #endif
72   smx_action_t waiting_action;
73   m_task_t waiting_task;
74   char **argv;                  /* arguments table if any */
75   int argc;                     /* arguments number if any */
76   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
77   void* data;                   /* user data */
78 } s_simdata_process_t, *simdata_process_t;
79
80 typedef struct process_arg {
81   const char *name;
82   xbt_main_func_t code;
83   void *data;
84   m_host_t m_host;
85   int argc;
86   char **argv;
87   double kill_time;
88 } s_process_arg_t, *process_arg_t;
89
90 typedef struct msg_comm {
91   smx_action_t s_comm;          /* SIMIX communication object encapsulated (the same for both processes) */
92   m_task_t task_sent;           /* task sent (NULL for the receiver) */
93   m_task_t *task_received;      /* where the task will be received (NULL for the sender) */
94   MSG_error_t status;           /* status of the communication once finished */
95 } s_msg_comm_t;
96
97 /************************** Global variables ********************************/
98 typedef struct MSG_Global {
99   xbt_fifo_t host;
100 #ifdef MSG_USE_DEPRECATED
101   int max_channel;
102 #endif
103   int PID;
104   int session;
105   unsigned long int sent_msg;   /* Total amount of messages sent during the simulation */
106   void (*task_copy_callback) (m_task_t task, m_process_t src, m_process_t dst);
107   void_f_pvoid_t process_data_cleanup;
108 } s_MSG_Global_t, *MSG_Global_t;
109
110 /*extern MSG_Global_t msg_global;*/
111 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
112
113
114 /*************************************************************/
115
116 #ifdef MSG_USE_DEPRECATED
117 #  define PROCESS_SET_ERRNO(val) \
118   (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno=val)
119 #  define PROCESS_GET_ERRNO() \
120   (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno)
121 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
122 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
123
124 #else
125 #  define MSG_RETURN(val) return(val)
126 #endif
127
128 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
129 void __MSG_host_destroy(m_host_t host);
130
131 void __MSG_display_process_status(void);
132
133 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
134 void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
135                                    xbt_main_func_t code, void *data,
136                                    const char *hostname, int argc,
137                                    char **argv, xbt_dict_t properties);
138 void MSG_process_kill_from_SIMIX(smx_process_t p);
139 void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size);
140
141 void _MSG_action_init(void);
142 void _MSG_action_exit(void);
143
144 SG_END_DECL()
145 #endif