Debian Codegraph @

src/mpid/ch3/channels/nemesis/include/mpidi_ch3_pre.h

raw
1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #ifndef MPIDI_CH3_PRE_H_INCLUDED
7 #define MPIDI_CH3_PRE_H_INCLUDED
8 #include "mpid_nem_pre.h"
9 #include "mpidu_generic_queue.h"
10
11 #if defined(HAVE_NETINET_IN_H)
12 #include <netinet/in.h>
13 #elif defined(HAVE_WINSOCK2_H)
14 #include <winsock2.h>
15 #include <windows.h>
16 #endif
17
18 /*#define MPID_USE_SEQUENCE_NUMBERS*/
19 /*#define HAVE_CH3_PRE_INIT*/
20 /* #define MPIDI_CH3_HAS_NO_DYNAMIC_PROCESS */
21 #define MPIDI_DEV_IMPLEMENTS_KVS
22
23 /* Nemesis packets */
24 #define MPIDI_CH3_PKT_ENUM \
25 MPIDI_NEM_PKT_LMT_RTS, \
26 MPIDI_NEM_PKT_LMT_CTS, \
27 MPIDI_NEM_PKT_LMT_DONE, \
28 MPIDI_NEM_PKT_LMT_COOKIE, \
29 MPIDI_NEM_PKT_CKPT_MARKER, \
30 MPIDI_NEM_PKT_NETMOD
31
32 typedef struct {
33 void *netmod_priv; /* netmod communicator private data */
34 } MPIDI_CH3I_CH_comm_t;
35
36 typedef enum MPIDI_CH3I_VC_state
37 {
38 MPIDI_CH3I_VC_STATE_UNCONNECTED,
39 MPIDI_CH3I_VC_STATE_CONNECTING,
40 MPIDI_CH3I_VC_STATE_CONNECTED,
41 MPIDI_CH3I_VC_STATE_FAILED
42 }
43 MPIDI_CH3I_VC_state_t;
44
45 /* size of private data area in vc and req for network modules */
46 #define MPIDI_NEM_VC_NETMOD_AREA_LEN 128
47 #define MPIDI_NEM_REQ_NETMOD_AREA_LEN 192
48
49 /* define functions for access MPID_nem_lmt_rts_queue_t */
50 typedef GENERIC_Q_DECL(struct MPIR_Request) MPID_nem_lmt_rts_queue_t;
51 #define MPID_nem_lmt_rtsq_empty(q) GENERIC_Q_EMPTY (q)
52 #define MPID_nem_lmt_rtsq_head(q) GENERIC_Q_HEAD (q)
53 #define MPID_nem_lmt_rtsq_enqueue(qp, ep) do { \
54 MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CHANNEL, VERBOSE, (MPL_DBG_FDEST, \
55 "MPID_nem_lmt_rtsq_enqueue req=%p (handle=%#x), queue=%p", \
56 ep, (ep)->handle, qp)); \
57 GENERIC_Q_ENQUEUE (qp, ep, next); \
58 } while (0)
59 #define MPID_nem_lmt_rtsq_dequeue(qp, epp) do { \
60 GENERIC_Q_DEQUEUE (qp, epp, next); \
61 MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CHANNEL, VERBOSE, (MPL_DBG_FDEST, \
62 "MPID_nem_lmt_rtsq_dequeue req=%p (handle=%#x), queue=%p", \
63 *(epp), *(epp) ? (*(epp))->handle : -1, qp)); \
64 } while (0)
65 #define MPID_nem_lmt_rtsq_search_remove(qp, req_id, epp) do { \
66 GENERIC_Q_SEARCH_REMOVE(qp, _e->handle == (req_id), epp, \
67 struct MPIR_Request, next); \
68 MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CHANNEL, VERBOSE, (MPL_DBG_FDEST, \
69 "MPID_nem_lmt_rtsq_search_remove req=%p (handle=%#x), queue=%p", \
70 *(epp), req_id, qp)); \
71 } while (0)
72
73 typedef struct MPIDI_CH3I_VC
74 {
75 int pg_rank;
76 struct MPIR_Request *recv_active;
77
78 int is_local;
79 unsigned short send_seqno;
80 MPID_nem_fastbox_t *fbox_out;
81 MPID_nem_fastbox_t *fbox_in;
82 MPID_nem_queue_ptr_t recv_queue;
83 MPID_nem_queue_ptr_t free_queue;
84
85 #ifdef ENABLE_CHECKPOINTING
86 intptr_t ckpt_msg_len;
87 void *ckpt_msg_buf;
88 #endif
89
90 /* temp buffer to store partially received header */
91 intptr_t pending_pkt_len;
92 union MPIDI_CH3_Pkt *pending_pkt;
93
94 /* can be used by netmods to put this vc on a send queue or list */
95 struct MPIDI_VC *next;
96 struct MPIDI_VC *prev;
97
98 /* contig function pointers. Netmods should set these. */
99 /* iStartContigMsg -- sends a message consisting of a header (hdr) and contiguous data (data), possibly of 0 size. If the
100 message cannot be sent immediately, the function should create a request and return a pointer in sreq_ptr. The network
101 module should complete the request once the message has been completely sent. */
102 int (* iStartContigMsg)(struct MPIDI_VC *vc, void *hdr, intptr_t hdr_sz, void *data, intptr_t data_sz,
103 struct MPIR_Request **sreq_ptr);
104 /* iSentContig -- sends a message consisting of a header (hdr) and contiguous data (data), possibly of 0 size. The
105 network module should complete the request once the message has been completely sent. */
106 int (* iSendContig)(struct MPIDI_VC *vc, struct MPIR_Request *sreq, void *hdr, intptr_t hdr_sz,
107 void *data, intptr_t data_sz);
108 /* iSendIov -- sends a message consisting of multiple iovs, possibly of 0 n_iov.
109 n_iov should not exceed MPL_IOV_LIMIT - 1. network module should complete the request once the
110 message has been completely sent. */
111 int (* iSendIov)(struct MPIDI_VC *vc, struct MPIR_Request *sreq, void *hdr, intptr_t hdr_sz,
112 struct iovec *iov, int n_iov);
113
114 #ifdef ENABLE_CHECKPOINTING
115 /* ckpt_pause_send -- netmod should stop sending on this vc and queue messages to be sent after ckpt_continue()*/
116 int (* ckpt_pause_send_vc)(struct MPIDI_VC *vc);
117 /* ckpt_continue -- Notify remote side to start sending again. */
118 int (* ckpt_continue_vc)(struct MPIDI_VC *vc);
119 /* ckpt_restart -- similar to ckpt_continue, except that the process has been restarted */
120 int (* ckpt_restart_vc)(struct MPIDI_VC *vc);
121 #endif
122
123 /* LMT function pointers */
124 int (* lmt_initiate_lmt)(struct MPIDI_VC *vc, union MPIDI_CH3_Pkt *rts_pkt, struct MPIR_Request *req);
125 int (* lmt_start_recv)(struct MPIDI_VC *vc, struct MPIR_Request *req, struct iovec s_cookie);
126 int (* lmt_start_send)(struct MPIDI_VC *vc, struct MPIR_Request *sreq, struct iovec r_cookie);
127 int (* lmt_handle_cookie)(struct MPIDI_VC *vc, struct MPIR_Request *req, struct iovec cookie);
128 int (* lmt_done_send)(struct MPIDI_VC *vc, struct MPIR_Request *req);
129 int (* lmt_done_recv)(struct MPIDI_VC *vc, struct MPIR_Request *req);
130 int (* lmt_vc_terminated)(struct MPIDI_VC *vc);
131
132 /* LMT shared memory copy-buffer ptr */
133 struct MPID_nem_copy_buf *lmt_copy_buf;
134 MPL_shm_hnd_t lmt_copy_buf_handle;
135 MPL_shm_hnd_t lmt_recv_copy_buf_handle;
136 int lmt_buf_num;
137 intptr_t lmt_surfeit;
138 struct {struct MPID_nem_lmt_shm_wait_element *head, *tail;} lmt_queue;
139 struct MPID_nem_lmt_shm_wait_element *lmt_active_lmt;
140 int lmt_enqueued; /* FIXME: used for debugging */
141 MPID_nem_lmt_rts_queue_t lmt_rts_queue;
142
143 /* Pointer to per-vc packet handlers */
144 MPIDI_CH3_PktHandler_Fcn **pkt_handler;
145 int num_pkt_handlers;
146
147 union
148 {
149 char padding[MPIDI_NEM_VC_NETMOD_AREA_LEN];
150
151 /* Temporary helper field for ticket #1679. Should force proper pointer
152 * alignment on finnicky platforms like SPARC. Proper fix is to stop
153 * this questionable type aliasing altogether. */
154 void *align_helper;
155 } netmod_area;
156
157
158 /* FIXME: ch3 assumes there is a field called sendq_head in the ch
159 portion of the vc. This is unused in nemesis and should be set
160 to NULL */
161 void *sendq_head;
162 } MPIDI_CH3I_VC;
163
164 #define MPIDI_CH3_VC_DECL struct MPIDI_CH3I_VC ch;
165
166 struct MPIDI_CH3I_Request
167 {
168 struct MPIDI_VC *vc;
169 int noncontig;
170 intptr_t header_sz;
171
172 MPI_Request lmt_req_id; /* request id of remote side */
173 struct MPIR_Request *lmt_req; /* pointer to original send/recv request */
174 intptr_t lmt_data_sz; /* data size to be transferred, after checking for truncation */
175 struct iovec lmt_tmp_cookie; /* temporary storage for received cookie */
176 void *s_cookie; /* temporary storage for the cookie data in case the packet can't be sent immediately */
177
178 union
179 {
180 char padding[MPIDI_NEM_REQ_NETMOD_AREA_LEN];
181
182 /* Temporary helper field for ticket #1679. Should force proper pointer
183 * alignment on finnicky platforms like SPARC. Proper fix is to stop
184 * this questionable type aliasing altogether. */
185 void *align_helper;
186 } netmod_area;
187 };
188
189 /*
190 * MPIDI_CH3_REQUEST_DECL (additions to MPIR_Request)
191 */
192 #define MPIDI_CH3_REQUEST_DECL struct MPIDI_CH3I_Request ch;
193
194
195 #if 0
196 #define DUMP_REQUEST(req) do { \
197 int i; \
198 MPL_DBG_MSG_P(MPIDI_CH3_DBG_OTHER, TERSE, "request %p\n", (req)); \
199 MPL_DBG_MSG_D(MPIDI_CH3_DBG_OTHER, TERSE, " handle = %d\n", (req)->handle); \
200 MPL_DBG_MSG_D(MPIDI_CH3_DBG_OTHER, TERSE, " ref_count = %d\n", (req)->ref_count); \
201 MPL_DBG_MSG_D(MPIDI_CH3_DBG_OTHER, TERSE, " cc = %d\n", (req)->cc); \
202 for (i = 0; i < (req)->iov_count; ++i) \
203 MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_OTHER, TERSE, (MPL_DBG_FDEST, " dev.iov[%d] = (%p, %d)\n", i, \
204 (req)->dev.iov[i+(req)->dev.iov_offset].iov_base, \
205 (req)->dev.iov[i+(req)->dev.iov_offset].iov_len)); \
206 MPL_DBG_MSG_D(MPIDI_CH3_DBG_OTHER, TERSE, " dev.iov_count = %d\n", \
207 (req)->dev.iov_count); \
208 MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_OTHER, TERSE, (MPL_DBG_FDEST, " dev.state = 0x%x\n", (req)->dev.state)); \
209 MPL_DBG_MSG_D(MPIDI_CH3_DBG_OTHER, TERSE, " type = %d\n", \
210 MPIDI_Request_get_type(req)); \
211 } while (0)
212 #else
213 #define DUMP_REQUEST(req) do { } while (0)
214 #endif
215
216
217 #define MPIDI_POSTED_RECV_ENQUEUE_HOOK(req) MPIDI_CH3I_Posted_recv_enqueued(req)
218 #define MPIDI_POSTED_RECV_DEQUEUE_HOOK(req) MPIDI_CH3I_Posted_recv_dequeued(req)
219
220 /*
221 * MPID_Progress_state - device/channel dependent state to be passed between
222 * MPID_Progress_{start,wait,end}
223 *
224 */
225 typedef struct MPIDI_CH3I_Progress_state
226 {
227 int completion_count;
228 }
229 MPIDI_CH3I_Progress_state;
230
231 #define MPIDI_CH3_PROGRESS_STATE_DECL MPIDI_CH3I_Progress_state ch;
232
233 extern MPL_atomic_int_t MPIDI_CH3I_progress_completion_count;
234
235 #define MPIDI_CH3I_INCR_PROGRESS_COMPLETION_COUNT do { \
236 MPL_atomic_write_barrier(); \
237 MPL_atomic_fetch_add_int(&MPIDI_CH3I_progress_completion_count, 1); \
238 MPL_DBG_MSG_D(MPIDI_CH3_DBG_PROGRESS,VERBOSE, \
239 "just incremented MPIDI_CH3I_progress_completion_count=%d", \
240 MPL_atomic_relaxed_load_int(&MPIDI_CH3I_progress_completion_count)); \
241 } while(0)
242
243 #endif /* MPIDI_CH3_PRE_H_INCLUDED */
244