mpidpkt.h 16 KB
Newer Older
1 2 3 4 5 6 7 8
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
 *  (C) 2001 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

#ifndef HAVE_MPIDPKT_H
#define HAVE_MPIDPKT_H
9 10 11 12

/* Enable the use of data within the message packet for small messages */
#define USE_EAGER_SHORT
#define MPIDI_EAGER_SHORT_INTS 4
13
/* FIXME: This appears to assume that sizeof(int) == 4 (or at least >= 4) */
14 15
#define MPIDI_EAGER_SHORT_SIZE 16

16 17 18
/* This is the number of ints that can be carried within an RMA packet */
#define MPIDI_RMA_IMMED_INTS 1

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
/* Union over all types that are allowed in a CAS operation.  This
   is used to allocate enough space in the packet header for immediate
   data.  */
typedef union {
    char       cas_char;
    short      cas_short;
    int        cas_int;
    long       cas_long;
    MPI_Aint   cas_aint;
    MPI_Offset cas_offset;
#if defined(HAVE_INT8_T)
    int8_t     cas_int8_t;
#endif
#if defined(HAVE_INT16_T)
    int16_t    cas_int16_t;
#endif
#if defined(HAVE_INT32_T)
    int32_t    cas_int32_t;
#endif
#if defined(HAVE_INT64_T)
    int64_t    cas_int64_t;
#endif
#if defined(HAVE_UINT8_T)
    uint8_t    cas_uint8_t;
#endif
#if defined(HAVE_UINT16_T)
    uint16_t   cas_uint16_t;
#endif
#if defined(HAVE_UINT32_T)
    uint32_t   cas_uint32_t;
#endif
#if defined(HAVE_UINT64_T)
    uint64_t   cas_uint64_t;
#endif
#if defined(HAVE_LONG_LONG_INT)
    long long  cas_long_long;
#endif
#if defined(HAVE_FORTRAN_BINDING)
    MPI_Fint   cas_fint;
#endif
#if defined(HAVE__BOOL)
    _Bool      cas__bool;
#endif
#if defined(HAVE_CXX_BINDING)
    MPIR_CXX_BOOL_CTYPE cas_cxx_bool;
#endif
#if defined(MPIR_INTEGER1_CTYPE)
    MPIR_INTEGER1_CTYPE cas_integer1;
#endif
#if defined(MPIR_INTEGER2_CTYPE)
    MPIR_INTEGER2_CTYPE cas_integer2;
#endif
#if defined(MPIR_INTEGER4_CTYPE)
    MPIR_INTEGER4_CTYPE cas_integer4;
#endif
#if defined(MPIR_INTEGER8_CTYPE)
    MPIR_INTEGER8_CTYPE cas_integer8;
#endif
#if defined(MPIR_INTEGER16_CTYPE)
    MPIR_INTEGER16_CTYPE cas_integer16;
#endif
} MPIDI_CH3_CAS_Immed_u;

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
/* Union over all types that are allowed in a Fetch-and-op operation.  This
   is used to allocate enough space in the packet header for immediate
   data.  */
typedef union {
    char       fop_char;
    short      fop_short;
    int        fop_int;
    long       fop_long;
    MPI_Aint   fop_aint;
    MPI_Offset fop_offset;

#if defined(HAVE_INT8_T)
    int8_t     fop_int8_t;
#endif
#if defined(HAVE_INT16_T)
    int16_t    fop_int16_t;
#endif
#if defined(HAVE_INT32_T)
    int32_t    fop_int32_t;
#endif
#if defined(HAVE_INT64_T)
    int64_t    fop_int64_t;
#endif
#if defined(HAVE_UINT8_T)
    uint8_t    fop_uint8_t;
#endif
#if defined(HAVE_UINT16_T)
    uint16_t   fop_uint16_t;
#endif
#if defined(HAVE_UINT32_T)
    uint32_t   fop_uint32_t;
#endif
#if defined(HAVE_UINT64_T)
    uint64_t   fop_uint64_t;
#endif
#if defined(HAVE_LONG_LONG_INT)
    long long  fop_long_long;
#endif
#if defined(HAVE_FORTRAN_BINDING)
    MPI_Fint   fop_fint;
#endif
#if defined(HAVE__BOOL)
    _Bool      fop__bool;
#endif
#if defined(HAVE_CXX_BINDING)
    MPIR_CXX_BOOL_CTYPE fop_cxx_bool;
#endif
#if defined(MPIR_INTEGER1_CTYPE)
    MPIR_INTEGER1_CTYPE fop_integer1;
#endif
#if defined(MPIR_INTEGER2_CTYPE)
    MPIR_INTEGER2_CTYPE fop_integer2;
#endif
#if defined(MPIR_INTEGER4_CTYPE)
    MPIR_INTEGER4_CTYPE fop_integer4;
#endif
#if defined(MPIR_INTEGER8_CTYPE)
    MPIR_INTEGER8_CTYPE fop_integer8;
#endif
#if defined(MPIR_INTEGER16_CTYPE)
    MPIR_INTEGER16_CTYPE fop_integer16;
#endif

    float      fop_float;
    double     fop_double;

#if defined(HAVE_LONG_DOUBLE)
    long double fop_long_double;
#endif

#if defined(MPIR_REAL4_CTYPE)
    MPIR_REAL4_CTYPE fop_mpir_real4_ctype;
#endif
#if defined(MPIR_REAL8_CTYPE)
    MPIR_REAL8_CTYPE fop_mpir_real8_ctype;
#endif
#if defined(MPIR_REAL16_CTYPE)
    MPIR_REAL16_CTYPE fop_mpir_real16_ctype;
#endif

    struct {
        double re;
        double im;
    } fop_d_complex;

#if defined(HAVE_LONG_DOUBLE)
    struct {
        long double re;
        long double im;
    } fop_ld_complex;
#endif

    struct { 
        float re;
        float im;
    } fop_s_complex;

#if defined(HAVE_FORTRAN_BINDING)
    struct {
        MPIR_FC_REAL_CTYPE re;
        MPIR_FC_REAL_CTYPE im;
    } fop_s_fc_complex;

    struct {
        MPIR_FC_DOUBLE_CTYPE re;
        MPIR_FC_DOUBLE_CTYPE im;
    } fop_d_fc_complex;
#endif
} MPIDI_CH3_FOP_Immed_u;

192 193 194
/*
 * MPIDI_CH3_Pkt_type_t
 *
195
 * Predefined packet types.  This simplifies some of the code.
196
 */
197 198
/* FIXME: Having predefined names makes it harder to add new message types,
   such as different RMA types. */
199 200 201
typedef enum MPIDI_CH3_Pkt_type
{
    MPIDI_CH3_PKT_EAGER_SEND = 0,
202
#if defined(USE_EAGER_SHORT)
203
    MPIDI_CH3_PKT_EAGERSHORT_SEND,
204
#endif /* defined(USE_EAGER_SHORT) */
205 206 207 208 209 210 211 212
    MPIDI_CH3_PKT_EAGER_SYNC_SEND,    /* FIXME: no sync eager */
    MPIDI_CH3_PKT_EAGER_SYNC_ACK,
    MPIDI_CH3_PKT_READY_SEND,
    MPIDI_CH3_PKT_RNDV_REQ_TO_SEND,
    MPIDI_CH3_PKT_RNDV_CLR_TO_SEND,
    MPIDI_CH3_PKT_RNDV_SEND,          /* FIXME: should be stream put */
    MPIDI_CH3_PKT_CANCEL_SEND_REQ,
    MPIDI_CH3_PKT_CANCEL_SEND_RESP,
213
    MPIDI_CH3_PKT_PUT,                /* RMA Packets begin here */
214 215 216 217 218 219 220 221 222
    MPIDI_CH3_PKT_GET,
    MPIDI_CH3_PKT_GET_RESP,
    MPIDI_CH3_PKT_ACCUMULATE,
    MPIDI_CH3_PKT_LOCK,
    MPIDI_CH3_PKT_LOCK_GRANTED,
    MPIDI_CH3_PKT_PT_RMA_DONE,
    MPIDI_CH3_PKT_LOCK_PUT_UNLOCK, /* optimization for single puts */
    MPIDI_CH3_PKT_LOCK_GET_UNLOCK, /* optimization for single gets */
    MPIDI_CH3_PKT_LOCK_ACCUM_UNLOCK, /* optimization for single accumulates */
223
                                     /* RMA Packets end here */
224 225
    MPIDI_CH3_PKT_ACCUM_IMMED,     /* optimization for short accumulate */
    /* FIXME: Add PUT, GET_IMMED packet types */
226
    MPIDI_CH3_PKT_CAS,
227
    MPIDI_CH3_PKT_CAS_UNLOCK,
228
    MPIDI_CH3_PKT_CAS_RESP,
229 230 231
    MPIDI_CH3_PKT_FOP,
    MPIDI_CH3_PKT_FOP_UNLOCK,
    MPIDI_CH3_PKT_FOP_RESP,
232 233 234 235 236 237 238 239
    MPIDI_CH3_PKT_FLOW_CNTL_UPDATE,  /* FIXME: Unused */
    MPIDI_CH3_PKT_CLOSE,
    MPIDI_CH3_PKT_END_CH3
    /* The channel can define additional types by defining the value
       MPIDI_CH3_PKT_ENUM */
# if defined(MPIDI_CH3_PKT_ENUM)
    , MPIDI_CH3_PKT_ENUM
# endif    
240 241
    , MPIDI_CH3_PKT_END_ALL,
    MPIDI_CH3_PKT_INVALID = -1 /* forces a signed enum to quash warnings */
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
}
MPIDI_CH3_Pkt_type_t;

typedef struct MPIDI_CH3_Pkt_send
{
    MPIDI_CH3_Pkt_type_t type;  /* XXX - uint8_t to conserve space ??? */
    MPIDI_Message_match match;
    MPI_Request sender_req_id;	/* needed for ssend and send cancel */
    MPIDI_msg_sz_t data_sz;
#if defined(MPID_USE_SEQUENCE_NUMBERS)
    MPID_Seqnum_t seqnum;
#endif    
}
MPIDI_CH3_Pkt_send_t;

/* NOTE: Normal and synchronous eager sends, as well as all ready-mode sends, 
   use the same structure but have a different type value. */
typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_eager_send_t;
typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_eager_sync_send_t;
typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_ready_send_t;
262 263

#if defined(USE_EAGER_SHORT)
264 265 266 267 268 269 270 271 272 273 274
typedef struct MPIDI_CH3_Pkt_eagershort_send
{
    MPIDI_CH3_Pkt_type_t type;  /* XXX - uint8_t to conserve space ??? */
    MPIDI_Message_match match;
    MPIDI_msg_sz_t data_sz;
#if defined(MPID_USE_SEQUENCE_NUMBERS)
    MPID_Seqnum_t seqnum;
#endif
    int  data[MPIDI_EAGER_SHORT_INTS];    /* FIXME: Experimental for now */
}
MPIDI_CH3_Pkt_eagershort_send_t;
275
#endif /* defined(USE_EAGER_SHORT) */
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380

typedef struct MPIDI_CH3_Pkt_eager_sync_ack
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request sender_req_id;
}
MPIDI_CH3_Pkt_eager_sync_ack_t;

typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_rndv_req_to_send_t;

typedef struct MPIDI_CH3_Pkt_rndv_clr_to_send
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request sender_req_id;
    MPI_Request receiver_req_id;
}
MPIDI_CH3_Pkt_rndv_clr_to_send_t;

typedef struct MPIDI_CH3_Pkt_rndv_send
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request receiver_req_id;
}
MPIDI_CH3_Pkt_rndv_send_t;

typedef struct MPIDI_CH3_Pkt_cancel_send_req
{
    MPIDI_CH3_Pkt_type_t type;
    MPIDI_Message_match match;
    MPI_Request sender_req_id;
}
MPIDI_CH3_Pkt_cancel_send_req_t;

typedef struct MPIDI_CH3_Pkt_cancel_send_resp
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request sender_req_id;
    int ack;
}
MPIDI_CH3_Pkt_cancel_send_resp_t;

#if defined(MPIDI_CH3_PKT_DEFS)
MPIDI_CH3_PKT_DEFS
#endif

typedef struct MPIDI_CH3_Pkt_put
{
    MPIDI_CH3_Pkt_type_t type;
    void *addr;
    int count;
    MPI_Datatype datatype;
    int dataloop_size;   /* for derived datatypes */
    MPI_Win target_win_handle; /* Used in the last RMA operation in each
                               * epoch for decrementing rma op counter in
                               * active target rma and for unlocking window 
                               * in passive target rma. Otherwise set to NULL*/
    MPI_Win source_win_handle; /* Used in the last RMA operation in an
                               * epoch in the case of passive target rma
                               * with shared locks. Otherwise set to NULL*/
}
MPIDI_CH3_Pkt_put_t;

typedef struct MPIDI_CH3_Pkt_get
{
    MPIDI_CH3_Pkt_type_t type;
    void *addr;
    int count;
    MPI_Datatype datatype;
    int dataloop_size;   /* for derived datatypes */
    MPI_Request request_handle;
    MPI_Win target_win_handle; /* Used in the last RMA operation in each
                               * epoch for decrementing rma op counter in
                               * active target rma and for unlocking window 
                               * in passive target rma. Otherwise set to NULL*/
    MPI_Win source_win_handle; /* Used in the last RMA operation in an
                               * epoch in the case of passive target rma
                               * with shared locks. Otherwise set to NULL*/
}
MPIDI_CH3_Pkt_get_t;

typedef struct MPIDI_CH3_Pkt_get_resp
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
}
MPIDI_CH3_Pkt_get_resp_t;

typedef struct MPIDI_CH3_Pkt_accum
{
    MPIDI_CH3_Pkt_type_t type;
    void *addr;
    int count;
    MPI_Datatype datatype;
    int dataloop_size;   /* for derived datatypes */
    MPI_Op op;
    MPI_Win target_win_handle; /* Used in the last RMA operation in each
                               * epoch for decrementing rma op counter in
                               * active target rma and for unlocking window 
                               * in passive target rma. Otherwise set to NULL*/
    MPI_Win source_win_handle; /* Used in the last RMA operation in an
                               * epoch in the case of passive target rma
                               * with shared locks. Otherwise set to NULL*/
}
MPIDI_CH3_Pkt_accum_t;

381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
typedef struct MPIDI_CH3_Pkt_accum_immed
{
    MPIDI_CH3_Pkt_type_t type;
    void *addr;
    int count;
    /* FIXME: Compress datatype/op into a single word (immedate mode) */
    MPI_Datatype datatype;
    MPI_Op op;
    /* FIXME: do we need these (use a regular accum packet if we do?) */
    MPI_Win target_win_handle; /* Used in the last RMA operation in each
                               * epoch for decrementing rma op counter in
                               * active target rma and for unlocking window 
                               * in passive target rma. Otherwise set to NULL*/
    MPI_Win source_win_handle; /* Used in the last RMA operation in an
                               * epoch in the case of passive target rma
                               * with shared locks. Otherwise set to NULL*/
    int data[MPIDI_RMA_IMMED_INTS];
}
MPIDI_CH3_Pkt_accum_immed_t;

401 402 403 404
typedef struct MPIDI_CH3_Pkt_cas
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Datatype datatype;
405
    void *addr;
406 407
    MPI_Request request_handle;
    MPI_Win target_win_handle; /* Used in the last RMA operation in each
408 409 410 411 412 413 414
                                * epoch for decrementing rma op counter in
                                * active target rma and for unlocking window 
                                * in passive target rma. Otherwise set to NULL*/

                               /* source_win_handle is omitted here to reduce
                                * the packet size.  If this is the last CAS
                                * packet, the type will be set to CAS_UNLOCK */
415 416 417 418 419 420 421 422 423 424 425 426 427
    MPIDI_CH3_CAS_Immed_u origin_data;
    MPIDI_CH3_CAS_Immed_u compare_data;
}
MPIDI_CH3_Pkt_cas_t;

typedef struct MPIDI_CH3_Pkt_cas_resp
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
    MPIDI_CH3_CAS_Immed_u data;
}
MPIDI_CH3_Pkt_cas_resp_t;

428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
typedef struct MPIDI_CH3_Pkt_fop
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Datatype datatype;
    void *addr;
    MPI_Op op;
    MPI_Request request_handle;
    MPI_Win target_win_handle; /* Used in the last RMA operation in each
                                * epoch for decrementing rma op counter in
                                * active target rma and for unlocking window 
                                * in passive target rma. Otherwise set to NULL*/

                               /* source_win_handle is omitted here to reduce
                                * the packet size.  If this is the last FETCH_OP
                                * packet, the type will be set to FETCH_OP_UNLOCK */
    MPIDI_CH3_FOP_Immed_u origin_data;
}
MPIDI_CH3_Pkt_fop_t;

typedef struct MPIDI_CH3_Pkt_fop_resp
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
    MPIDI_CH3_FOP_Immed_u data;
}
MPIDI_CH3_Pkt_fop_resp_t;

455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
typedef struct MPIDI_CH3_Pkt_lock
{
    MPIDI_CH3_Pkt_type_t type;
    int lock_type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
}
MPIDI_CH3_Pkt_lock_t;

typedef struct MPIDI_CH3_Pkt_lock_granted
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win source_win_handle;
}
MPIDI_CH3_Pkt_lock_granted_t;

typedef MPIDI_CH3_Pkt_lock_granted_t MPIDI_CH3_Pkt_pt_rma_done_t;

typedef struct MPIDI_CH3_Pkt_lock_put_unlock
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
    int lock_type;
    void *addr;
    int count;
    MPI_Datatype datatype;
}
MPIDI_CH3_Pkt_lock_put_unlock_t;

typedef struct MPIDI_CH3_Pkt_lock_get_unlock
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
    int lock_type;
    void *addr;
    int count;
    MPI_Datatype datatype;
    MPI_Request request_handle;
}
MPIDI_CH3_Pkt_lock_get_unlock_t;

typedef struct MPIDI_CH3_Pkt_lock_accum_unlock
{
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
    int lock_type;
    void *addr;
    int count;
    MPI_Datatype datatype;
    MPI_Op op;
}
MPIDI_CH3_Pkt_lock_accum_unlock_t;


typedef struct MPIDI_CH3_Pkt_close
{
    MPIDI_CH3_Pkt_type_t type;
    int ack;
}
MPIDI_CH3_Pkt_close_t;

typedef union MPIDI_CH3_Pkt
{
    MPIDI_CH3_Pkt_type_t type;
    MPIDI_CH3_Pkt_eager_send_t eager_send;
523
#if defined(USE_EAGER_SHORT)
524
    MPIDI_CH3_Pkt_eagershort_send_t eagershort_send;
525
#endif /* defined(USE_EAGER_SHORT) */
526 527 528 529 530 531 532 533 534 535 536 537
    MPIDI_CH3_Pkt_eager_sync_send_t eager_sync_send;
    MPIDI_CH3_Pkt_eager_sync_ack_t eager_sync_ack;
    MPIDI_CH3_Pkt_eager_send_t ready_send;
    MPIDI_CH3_Pkt_rndv_req_to_send_t rndv_req_to_send;
    MPIDI_CH3_Pkt_rndv_clr_to_send_t rndv_clr_to_send;
    MPIDI_CH3_Pkt_rndv_send_t rndv_send;
    MPIDI_CH3_Pkt_cancel_send_req_t cancel_send_req;
    MPIDI_CH3_Pkt_cancel_send_resp_t cancel_send_resp;
    MPIDI_CH3_Pkt_put_t put;
    MPIDI_CH3_Pkt_get_t get;
    MPIDI_CH3_Pkt_get_resp_t get_resp;
    MPIDI_CH3_Pkt_accum_t accum;
538
    MPIDI_CH3_Pkt_accum_immed_t accum_immed;
539 540 541 542 543 544 545
    MPIDI_CH3_Pkt_lock_t lock;
    MPIDI_CH3_Pkt_lock_granted_t lock_granted;
    MPIDI_CH3_Pkt_pt_rma_done_t pt_rma_done;    
    MPIDI_CH3_Pkt_lock_put_unlock_t lock_put_unlock;
    MPIDI_CH3_Pkt_lock_get_unlock_t lock_get_unlock;
    MPIDI_CH3_Pkt_lock_accum_unlock_t lock_accum_unlock;
    MPIDI_CH3_Pkt_close_t close;
546 547
    MPIDI_CH3_Pkt_cas_t cas;
    MPIDI_CH3_Pkt_cas_resp_t cas_resp;
548 549
    MPIDI_CH3_Pkt_fop_t fop;
    MPIDI_CH3_Pkt_fop_resp_t fop_resp;
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
# if defined(MPIDI_CH3_PKT_DECL)
    MPIDI_CH3_PKT_DECL
# endif
}
MPIDI_CH3_Pkt_t;

#if defined(MPID_USE_SEQUENCE_NUMBERS)
typedef struct MPIDI_CH3_Pkt_send_container
{
    MPIDI_CH3_Pkt_send_t pkt;
    struct MPIDI_CH3_Pkt_send_container_s * next;
}
MPIDI_CH3_Pkt_send_container_t;
#endif

#endif