Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ef8b829767d756a1ee60b7b341da64a124a3764f
[simgrid.git] / src / 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 /******************************* Process *************************************/
49
50 typedef struct simdata_process {
51   m_host_t m_host;              /* the host on which the process is running */
52   int PID;                      /* used for debugging purposes */
53   int PPID;                     /* The parent PID */
54   m_host_t put_host;            /* used for debugging purposes */
55   m_channel_t put_channel;      /* used for debugging purposes */
56   smx_action_t waiting_action;
57   m_task_t waiting_task;
58   int argc;                     /* arguments number if any */
59   char **argv;                  /* arguments table if any */
60   MSG_error_t last_errno;       /* the last value returned by a MSG_function */
61   void* data;                   /* user data */
62 } s_simdata_process_t, *simdata_process_t;
63
64 typedef struct process_arg {
65   const char *name;
66   xbt_main_func_t code;
67   void *data;
68   m_host_t m_host;
69   int argc;
70   char **argv;
71   double kill_time;
72 } s_process_arg_t, *process_arg_t;
73
74 typedef struct msg_comm {
75   smx_action_t s_comm;          /* SIMIX communication object encapsulated (the same for both processes) */
76   m_task_t task_sent;           /* task sent (NULL for the receiver) */
77   m_task_t *task_received;      /* where the task will be received (NULL for the sender) */
78   MSG_error_t status;           /* status of the communication once finished */
79 } s_msg_comm_t;
80
81 /************************** Global variables ********************************/
82 typedef struct MSG_Global {
83   xbt_fifo_t host;
84   int max_channel;
85   int PID;
86   int session;
87   unsigned long int sent_msg;   /* Total amount of messages sent during the simulation */
88 } s_MSG_Global_t, *MSG_Global_t;
89
90 /*extern MSG_Global_t msg_global;*/
91 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
92
93
94 /*************************************************************/
95
96 #define PROCESS_SET_ERRNO(val) \
97   (((simdata_process_t) SIMIX_process_self_get_data())->last_errno=val)
98 #define PROCESS_GET_ERRNO() \
99   (((simdata_process_t) SIMIX_process_self_get_data())->last_errno)
100 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
101 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
102
103 /*#define CHECK_HOST()  xbt_assert(SIMIX_req_host_get_state(SIMIX_host_self())==1,\
104                                   "Host failed, you cannot call this function. (state=%d)",SIMIX_req_host_get_state(SIMIX_host_self()))*/
105 #define CHECK_HOST()
106
107 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
108 void __MSG_host_destroy(m_host_t host);
109
110 void __MSG_display_process_status(void);
111
112 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
113 void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
114                                    xbt_main_func_t code, void *data,
115                                    const char *hostname, int argc,
116                                    char **argv, xbt_dict_t properties);
117 void MSG_process_kill_from_SIMIX(smx_process_t p);
118
119 void _MSG_action_init(void);
120 void _MSG_action_exit(void);
121
122 SG_END_DECL()
123 #endif