1 /* -*- Mode: C; c-basic-offset:4 ; -*- */ 2 /* 3 * (C) 2001 by Argonne National Laboratory. 4 * See COPYRIGHT in top-level directory. 5 */ 6 7 #ifndef HAVE_MPIDPKT_H 8 #define HAVE_MPIDPKT_H 9 10 #include "oputil.h" 11 12 /* Enable the use of data within the message packet for small messages */ 13 #define USE_EAGER_SHORT 14 #define MPIDI_EAGER_SHORT_INTS 4 15 /* FIXME: This appears to assume that sizeof(int) == 4 (or at least >= 4) */ 16 #define MPIDI_EAGER_SHORT_SIZE 16 17 18 /* This is the number of ints that can be carried within an RMA packet */ 19 #define MPIDI_RMA_IMMED_INTS 1 20 21 /* Union over all types (integer, logical, and multi-language types) that are 22 allowed in a CAS operation. This is used to allocate enough space in the 23 packet header for immediate data. */ 24 typedef union { 25 #define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) c_type_ cas_##type_name_; 26 MPIR_OP_TYPE_GROUP(C_INTEGER) 27 MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER) 28 MPIR_OP_TYPE_GROUP(LOGICAL) 29 MPIR_OP_TYPE_GROUP(BYTE) 30 MPIR_OP_TYPE_GROUP(C_INTEGER_EXTRA) 31 MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER_EXTRA) 32 MPIR_OP_TYPE_GROUP(LOGICAL_EXTRA) 33 MPIR_OP_TYPE_GROUP(BYTE_EXTRA) 34 #undef MPIR_OP_TYPE_MACRO 35 } MPIDI_CH3_CAS_Immed_u; 36 37 /* Union over all types (all predefined types) that are allowed in a 38 Fetch-and-op operation. This can be too large for the packet header, so we 39 limit the immediate space in the header to FOP_IMMED_INTS. */ 40 41 #define MPIDI_RMA_FOP_IMMED_INTS 2 42 #define MPIDI_RMA_FOP_RESP_IMMED_INTS 8 43 44 typedef union { 45 #define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) c_type_ fop##type_name_; 46 MPIR_OP_TYPE_GROUP_ALL_BASIC 47 MPIR_OP_TYPE_GROUP_ALL_EXTRA 48 #undef MPIR_OP_TYPE_MACRO 49 } MPIDI_CH3_FOP_Immed_u; 50 51 /* 52 * MPIDI_CH3_Pkt_type_t 53 * 54 * Predefined packet types. This simplifies some of the code. 55 */ 56 /* FIXME: Having predefined names makes it harder to add new message types, 57 such as different RMA types. */ 58 typedef enum MPIDI_CH3_Pkt_type 59 { 60 MPIDI_CH3_PKT_EAGER_SEND = 0, 61 #if defined(USE_EAGER_SHORT) 62 MPIDI_CH3_PKT_EAGERSHORT_SEND, 63 #endif /* defined(USE_EAGER_SHORT) */ 64 MPIDI_CH3_PKT_EAGER_SYNC_SEND, /* FIXME: no sync eager */ 65 MPIDI_CH3_PKT_EAGER_SYNC_ACK, 66 MPIDI_CH3_PKT_READY_SEND, 67 MPIDI_CH3_PKT_RNDV_REQ_TO_SEND, 68 MPIDI_CH3_PKT_RNDV_CLR_TO_SEND, 69 MPIDI_CH3_PKT_RNDV_SEND, /* FIXME: should be stream put */ 70 MPIDI_CH3_PKT_CANCEL_SEND_REQ, 71 MPIDI_CH3_PKT_CANCEL_SEND_RESP, 72 MPIDI_CH3_PKT_PUT, /* RMA Packets begin here */ 73 MPIDI_CH3_PKT_GET, 74 MPIDI_CH3_PKT_GET_RESP, 75 MPIDI_CH3_PKT_ACCUMULATE, 76 MPIDI_CH3_PKT_LOCK, 77 MPIDI_CH3_PKT_LOCK_GRANTED, 78 MPIDI_CH3_PKT_PT_RMA_DONE, 79 MPIDI_CH3_PKT_LOCK_PUT_UNLOCK, /* optimization for single puts */ 80 MPIDI_CH3_PKT_LOCK_GET_UNLOCK, /* optimization for single gets */ 81 MPIDI_CH3_PKT_LOCK_ACCUM_UNLOCK, /* optimization for single accumulates */ 82 /* RMA Packets end here */ 83 MPIDI_CH3_PKT_ACCUM_IMMED, /* optimization for short accumulate */ 84 /* FIXME: Add PUT, GET_IMMED packet types */ 85 MPIDI_CH3_PKT_CAS, 86 MPIDI_CH3_PKT_CAS_UNLOCK, 87 MPIDI_CH3_PKT_CAS_RESP, 88 MPIDI_CH3_PKT_FOP, 89 MPIDI_CH3_PKT_FOP_RESP, 90 MPIDI_CH3_PKT_FLOW_CNTL_UPDATE, /* FIXME: Unused */ 91 MPIDI_CH3_PKT_CLOSE, 92 MPIDI_CH3_PKT_END_CH3 93 /* The channel can define additional types by defining the value 94 MPIDI_CH3_PKT_ENUM */ 95 # if defined(MPIDI_CH3_PKT_ENUM) 96 , MPIDI_CH3_PKT_ENUM 97 # endif 98 , MPIDI_CH3_PKT_END_ALL, 99 MPIDI_CH3_PKT_INVALID = -1 /* forces a signed enum to quash warnings */ 100 } 101 MPIDI_CH3_Pkt_type_t; 102 103 typedef struct MPIDI_CH3_Pkt_send 104 { 105 MPIDI_CH3_Pkt_type_t type; /* XXX - uint8_t to conserve space ??? */ 106 MPIDI_Message_match match; 107 MPI_Request sender_req_id; /* needed for ssend and send cancel */ 108 MPIDI_msg_sz_t data_sz; 109 #if defined(MPID_USE_SEQUENCE_NUMBERS) 110 MPID_Seqnum_t seqnum; 111 #endif 112 } 113 MPIDI_CH3_Pkt_send_t; 114 115 /* NOTE: Normal and synchronous eager sends, as well as all ready-mode sends, 116 use the same structure but have a different type value. */ 117 typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_eager_send_t; 118 typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_eager_sync_send_t; 119 typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_ready_send_t; 120 121 #if defined(USE_EAGER_SHORT) 122 typedef struct MPIDI_CH3_Pkt_eagershort_send 123 { 124 MPIDI_CH3_Pkt_type_t type; /* XXX - uint8_t to conserve space ??? */ 125 MPIDI_Message_match match; 126 MPIDI_msg_sz_t data_sz; 127 #if defined(MPID_USE_SEQUENCE_NUMBERS) 128 MPID_Seqnum_t seqnum; 129 #endif 130 int data[MPIDI_EAGER_SHORT_INTS]; /* FIXME: Experimental for now */ 131 } 132 MPIDI_CH3_Pkt_eagershort_send_t; 133 #endif /* defined(USE_EAGER_SHORT) */ 134 135 typedef struct MPIDI_CH3_Pkt_eager_sync_ack 136 { 137 MPIDI_CH3_Pkt_type_t type; 138 MPI_Request sender_req_id; 139 } 140 MPIDI_CH3_Pkt_eager_sync_ack_t; 141 142 typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_rndv_req_to_send_t; 143 144 typedef struct MPIDI_CH3_Pkt_rndv_clr_to_send 145 { 146 MPIDI_CH3_Pkt_type_t type; 147 MPI_Request sender_req_id; 148 MPI_Request receiver_req_id; 149 } 150 MPIDI_CH3_Pkt_rndv_clr_to_send_t; 151 152 typedef struct MPIDI_CH3_Pkt_rndv_send 153 { 154 MPIDI_CH3_Pkt_type_t type; 155 MPI_Request receiver_req_id; 156 } 157 MPIDI_CH3_Pkt_rndv_send_t; 158 159 typedef struct MPIDI_CH3_Pkt_cancel_send_req 160 { 161 MPIDI_CH3_Pkt_type_t type; 162 MPIDI_Message_match match; 163 MPI_Request sender_req_id; 164 } 165 MPIDI_CH3_Pkt_cancel_send_req_t; 166 167 typedef struct MPIDI_CH3_Pkt_cancel_send_resp 168 { 169 MPIDI_CH3_Pkt_type_t type; 170 MPI_Request sender_req_id; 171 int ack; 172 } 173 MPIDI_CH3_Pkt_cancel_send_resp_t; 174 175 #if defined(MPIDI_CH3_PKT_DEFS) 176 MPIDI_CH3_PKT_DEFS 177 #endif 178 179 typedef struct MPIDI_CH3_Pkt_put 180 { 181 MPIDI_CH3_Pkt_type_t type; 182 void *addr; 183 int count; 184 MPI_Datatype datatype; 185 int dataloop_size; /* for derived datatypes */ 186 MPI_Win target_win_handle; /* Used in the last RMA operation in each 187 * epoch for decrementing rma op counter in 188 * active target rma and for unlocking window 189 * in passive target rma. Otherwise set to NULL*/ 190 MPI_Win source_win_handle; /* Used in the last RMA operation in an 191 * epoch in the case of passive target rma 192 * with shared locks. Otherwise set to NULL*/ 193 } 194 MPIDI_CH3_Pkt_put_t; 195 196 typedef struct MPIDI_CH3_Pkt_get 197 { 198 MPIDI_CH3_Pkt_type_t type; 199 void *addr; 200 int count; 201 MPI_Datatype datatype; 202 int dataloop_size; /* for derived datatypes */ 203 MPI_Request request_handle; 204 MPI_Win target_win_handle; /* Used in the last RMA operation in each 205 * epoch for decrementing rma op counter in 206 * active target rma and for unlocking window 207 * in passive target rma. Otherwise set to NULL*/ 208 MPI_Win source_win_handle; /* Used in the last RMA operation in an 209 * epoch in the case of passive target rma 210 * with shared locks. Otherwise set to NULL*/ 211 } 212 MPIDI_CH3_Pkt_get_t; 213 214 typedef struct MPIDI_CH3_Pkt_get_resp 215 { 216 MPIDI_CH3_Pkt_type_t type; 217 MPI_Request request_handle; 218 } 219 MPIDI_CH3_Pkt_get_resp_t; 220 221 typedef struct MPIDI_CH3_Pkt_accum 222 { 223 MPIDI_CH3_Pkt_type_t type; 224 void *addr; 225 int count; 226 MPI_Datatype datatype; 227 int dataloop_size; /* for derived datatypes */ 228 MPI_Op op; 229 MPI_Win target_win_handle; /* Used in the last RMA operation in each 230 * epoch for decrementing rma op counter in 231 * active target rma and for unlocking window 232 * in passive target rma. Otherwise set to NULL*/ 233 MPI_Win source_win_handle; /* Used in the last RMA operation in an 234 * epoch in the case of passive target rma 235 * with shared locks. Otherwise set to NULL*/ 236 } 237 MPIDI_CH3_Pkt_accum_t; 238 239 typedef struct MPIDI_CH3_Pkt_accum_immed 240 { 241 MPIDI_CH3_Pkt_type_t type; 242 void *addr; 243 int count; 244 /* FIXME: Compress datatype/op into a single word (immedate mode) */ 245 MPI_Datatype datatype; 246 MPI_Op op; 247 /* FIXME: do we need these (use a regular accum packet if we do?) */ 248 MPI_Win target_win_handle; /* Used in the last RMA operation in each 249 * epoch for decrementing rma op counter in 250 * active target rma and for unlocking window 251 * in passive target rma. Otherwise set to NULL*/ 252 MPI_Win source_win_handle; /* Used in the last RMA operation in an 253 * epoch in the case of passive target rma 254 * with shared locks. Otherwise set to NULL*/ 255 int data[MPIDI_RMA_IMMED_INTS]; 256 } 257 MPIDI_CH3_Pkt_accum_immed_t; 258 259 typedef struct MPIDI_CH3_Pkt_cas 260 { 261 MPIDI_CH3_Pkt_type_t type; 262 MPI_Datatype datatype; 263 void *addr; 264 MPI_Request request_handle; 265 MPI_Win target_win_handle; /* Used in the last RMA operation in each 266 * epoch for decrementing rma op counter in 267 * active target rma and for unlocking window 268 * in passive target rma. Otherwise set to NULL*/ 269 270 /* source_win_handle is omitted here to reduce 271 * the packet size. If this is the last CAS 272 * packet, the type will be set to CAS_UNLOCK */ 273 MPIDI_CH3_CAS_Immed_u origin_data; 274 MPIDI_CH3_CAS_Immed_u compare_data; 275 } 276 MPIDI_CH3_Pkt_cas_t; 277 278 typedef struct MPIDI_CH3_Pkt_cas_resp 279 { 280 MPIDI_CH3_Pkt_type_t type; 281 MPI_Request request_handle; 282 MPIDI_CH3_CAS_Immed_u data; 283 } 284 MPIDI_CH3_Pkt_cas_resp_t; 285 286 typedef struct MPIDI_CH3_Pkt_fop 287 { 288 MPIDI_CH3_Pkt_type_t type; 289 MPI_Datatype datatype; 290 void *addr; 291 MPI_Op op; 292 MPI_Request request_handle; 293 MPI_Win target_win_handle; /* Used in the last RMA operation in each 294 * epoch for decrementing rma op counter in 295 * active target rma and for unlocking window 296 * in passive target rma. Otherwise set to NULL*/ 297 MPI_Win source_win_handle; /* Used in the last RMA operation in an 298 * epoch in the case of passive target rma 299 * with shared locks. Otherwise set to NULL*/ 300 int origin_data[MPIDI_RMA_FOP_IMMED_INTS]; 301 } 302 MPIDI_CH3_Pkt_fop_t; 303 304 typedef struct MPIDI_CH3_Pkt_fop_resp 305 { 306 MPIDI_CH3_Pkt_type_t type; 307 MPI_Request request_handle; 308 int data[MPIDI_RMA_FOP_RESP_IMMED_INTS]; 309 } 310 MPIDI_CH3_Pkt_fop_resp_t; 311 312 typedef struct MPIDI_CH3_Pkt_lock 313 { 314 MPIDI_CH3_Pkt_type_t type; 315 int lock_type; 316 MPI_Win target_win_handle; 317 MPI_Win source_win_handle; 318 } 319 MPIDI_CH3_Pkt_lock_t; 320 321 typedef struct MPIDI_CH3_Pkt_lock_granted 322 { 323 MPIDI_CH3_Pkt_type_t type; 324 MPI_Win source_win_handle; 325 } 326 MPIDI_CH3_Pkt_lock_granted_t; 327 328 typedef MPIDI_CH3_Pkt_lock_granted_t MPIDI_CH3_Pkt_pt_rma_done_t; 329 330 typedef struct MPIDI_CH3_Pkt_lock_put_unlock 331 { 332 MPIDI_CH3_Pkt_type_t type; 333 MPI_Win target_win_handle; 334 MPI_Win source_win_handle; 335 int lock_type; 336 void *addr; 337 int count; 338 MPI_Datatype datatype; 339 } 340 MPIDI_CH3_Pkt_lock_put_unlock_t; 341 342 typedef struct MPIDI_CH3_Pkt_lock_get_unlock 343 { 344 MPIDI_CH3_Pkt_type_t type; 345 MPI_Win target_win_handle; 346 MPI_Win source_win_handle; 347 int lock_type; 348 void *addr; 349 int count; 350 MPI_Datatype datatype; 351 MPI_Request request_handle; 352 } 353 MPIDI_CH3_Pkt_lock_get_unlock_t; 354 355 typedef struct MPIDI_CH3_Pkt_lock_accum_unlock 356 { 357 MPIDI_CH3_Pkt_type_t type; 358 MPI_Win target_win_handle; 359 MPI_Win source_win_handle; 360 int lock_type; 361 void *addr; 362 int count; 363 MPI_Datatype datatype; 364 MPI_Op op; 365 } 366 MPIDI_CH3_Pkt_lock_accum_unlock_t; 367 368 369 typedef struct MPIDI_CH3_Pkt_close 370 { 371 MPIDI_CH3_Pkt_type_t type; 372 int ack; 373 } 374 MPIDI_CH3_Pkt_close_t; 375 376 typedef union MPIDI_CH3_Pkt 377 { 378 MPIDI_CH3_Pkt_type_t type; 379 MPIDI_CH3_Pkt_eager_send_t eager_send; 380 #if defined(USE_EAGER_SHORT) 381 MPIDI_CH3_Pkt_eagershort_send_t eagershort_send; 382 #endif /* defined(USE_EAGER_SHORT) */ 383 MPIDI_CH3_Pkt_eager_sync_send_t eager_sync_send; 384 MPIDI_CH3_Pkt_eager_sync_ack_t eager_sync_ack; 385 MPIDI_CH3_Pkt_eager_send_t ready_send; 386 MPIDI_CH3_Pkt_rndv_req_to_send_t rndv_req_to_send; 387 MPIDI_CH3_Pkt_rndv_clr_to_send_t rndv_clr_to_send; 388 MPIDI_CH3_Pkt_rndv_send_t rndv_send; 389 MPIDI_CH3_Pkt_cancel_send_req_t cancel_send_req; 390 MPIDI_CH3_Pkt_cancel_send_resp_t cancel_send_resp; 391 MPIDI_CH3_Pkt_put_t put; 392 MPIDI_CH3_Pkt_get_t get; 393 MPIDI_CH3_Pkt_get_resp_t get_resp; 394 MPIDI_CH3_Pkt_accum_t accum; 395 MPIDI_CH3_Pkt_accum_immed_t accum_immed; 396 MPIDI_CH3_Pkt_lock_t lock; 397 MPIDI_CH3_Pkt_lock_granted_t lock_granted; 398 MPIDI_CH3_Pkt_pt_rma_done_t pt_rma_done; 399 MPIDI_CH3_Pkt_lock_put_unlock_t lock_put_unlock; 400 MPIDI_CH3_Pkt_lock_get_unlock_t lock_get_unlock; 401 MPIDI_CH3_Pkt_lock_accum_unlock_t lock_accum_unlock; 402 MPIDI_CH3_Pkt_close_t close; 403 MPIDI_CH3_Pkt_cas_t cas; 404 MPIDI_CH3_Pkt_cas_resp_t cas_resp; 405 MPIDI_CH3_Pkt_fop_t fop; 406 MPIDI_CH3_Pkt_fop_resp_t fop_resp; 407 # if defined(MPIDI_CH3_PKT_DECL) 408 MPIDI_CH3_PKT_DECL 409 # endif 410 } 411 MPIDI_CH3_Pkt_t; 412 413 #if defined(MPID_USE_SEQUENCE_NUMBERS) 414 typedef struct MPIDI_CH3_Pkt_send_container 415 { 416 MPIDI_CH3_Pkt_send_t pkt; 417 struct MPIDI_CH3_Pkt_send_container_s * next; 418 } 419 MPIDI_CH3_Pkt_send_container_t; 420 #endif 421 422 #endif 423