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 "simix/simix.h"
12 #include "surf/surf.h"
14 #include "xbt/dynar.h"
17 #include "xbt/config.h"
18 #include "instr/instr_private.h"
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 */
28 /********************************* Task **************************************/
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 */
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;
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 ***************/
58 /******************************* Process *************************************/
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 */
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 void* data; /* user data */
74 } s_simdata_process_t, *simdata_process_t;
76 typedef struct process_arg {
84 } s_process_arg_t, *process_arg_t;
86 typedef struct msg_comm {
87 smx_action_t s_comm; /* SIMIX communication object encapsulated (the same for both processes) */
88 m_task_t task_sent; /* task sent (NULL for the receiver) */
89 m_task_t *task_received; /* where the task will be received (NULL for the sender) */
90 MSG_error_t status; /* status of the communication once finished */
93 /************************** Global variables ********************************/
94 typedef struct MSG_Global {
96 #ifdef MSG_USE_DEPRECATED
101 unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
102 void (*task_copy_callback) (m_task_t task, m_process_t src, m_process_t dst);
103 void_f_pvoid_t process_data_cleanup;
104 } s_MSG_Global_t, *MSG_Global_t;
106 /*extern MSG_Global_t msg_global;*/
107 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
110 /*************************************************************/
112 #ifdef MSG_USE_DEPRECATED
113 # define PROCESS_SET_ERRNO(val) \
114 (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno=val)
115 # define PROCESS_GET_ERRNO() \
116 (((simdata_process_t) SIMIX_process_self_get_data(SIMIX_process_self()))->last_errno)
117 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
118 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
120 /*#define CHECK_HOST() xbt_assert(simcall_host_get_state(SIMIX_host_self())==1,\
121 "Host failed, you cannot call this function. (state=%d)",simcall_host_get_state(SIMIX_host_self()))*/
123 # define MSG_RETURN(val) return(val)
127 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
128 void __MSG_host_destroy(m_host_t host);
130 void __MSG_display_process_status(void);
132 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
133 void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
134 xbt_main_func_t code, void *data,
135 const char *hostname, int argc,
136 char **argv, xbt_dict_t properties);
137 void MSG_process_kill_from_SIMIX(smx_process_t p);
138 void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size);
140 void _MSG_action_init(void);
141 void _MSG_action_exit(void);