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

#ifndef HAVE_MPIDPKT_H
#define HAVE_MPIDPKT_H
9

10 11
#include "oputil.h"

12 13 14 15 16 17 18
#ifdef HAVE_STDINT_H
#  include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
#  include <inttypes.h>
#endif

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

25
/* This is the number of ints that can be carried within an RMA packet */
Xin Zhao's avatar
Xin Zhao committed
26
#define MPIDI_RMA_IMMED_BYTES 16
27

28 29 30
/* Union over all types (integer, logical, and multi-language types) that are
   allowed in a CAS operation.  This is used to allocate enough space in the
   packet header for immediate data.  */
31
typedef union {
32
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) c_type_ cas_##type_name_;
33 34 35 36 37 38 39 40
    MPIR_OP_TYPE_GROUP(C_INTEGER)
    MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER)
    MPIR_OP_TYPE_GROUP(LOGICAL)
    MPIR_OP_TYPE_GROUP(BYTE)
    MPIR_OP_TYPE_GROUP(C_INTEGER_EXTRA)
    MPIR_OP_TYPE_GROUP(FORTRAN_INTEGER_EXTRA)
    MPIR_OP_TYPE_GROUP(LOGICAL_EXTRA)
    MPIR_OP_TYPE_GROUP(BYTE_EXTRA)
41
#undef MPIR_OP_TYPE_MACRO
42 43
} MPIDI_CH3_CAS_Immed_u;

44 45 46 47
/* Union over all types (all predefined types) that are allowed in a
   Fetch-and-op operation.  This can be too large for the packet header, so we
   limit the immediate space in the header to FOP_IMMED_INTS. */

48 49 50
/* *INDENT-OFF* */
/* Indentation turned off because "indent" is getting confused with
 * the lack of a semi-colon in the fields below */
51
typedef union {
52
#define MPIR_OP_TYPE_MACRO(mpi_type_, c_type_, type_name_) c_type_ fop##type_name_;
53 54
    MPIR_OP_TYPE_GROUP_ALL_BASIC
    MPIR_OP_TYPE_GROUP_ALL_EXTRA
55
#undef MPIR_OP_TYPE_MACRO
56
} MPIDI_CH3_FOP_Immed_u;
57
/* *INDENT-ON* */
58

59
/*
60
 * Predefined packet types.  This simplifies some of the code.
61
 */
62 63
/* FIXME: Having predefined names makes it harder to add new message types,
   such as different RMA types. */
64
typedef enum {
Xin Zhao's avatar
Xin Zhao committed
65
    MPIDI_CH3_PKT_EAGER_SEND = 0,
66
#if defined(USE_EAGER_SHORT)
67
    MPIDI_CH3_PKT_EAGERSHORT_SEND,
68
#endif /* defined(USE_EAGER_SHORT) */
69
    MPIDI_CH3_PKT_EAGER_SYNC_SEND,      /* FIXME: no sync eager */
70 71 72 73
    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,
74
    MPIDI_CH3_PKT_RNDV_SEND,    /* FIXME: should be stream put */
75 76
    MPIDI_CH3_PKT_CANCEL_SEND_REQ,
    MPIDI_CH3_PKT_CANCEL_SEND_RESP,
Xin Zhao's avatar
Xin Zhao committed
77 78
    /* RMA Packets begin here */
    MPIDI_CH3_PKT_PUT,
79 80
    MPIDI_CH3_PKT_GET,
    MPIDI_CH3_PKT_ACCUMULATE,
Xin Zhao's avatar
Xin Zhao committed
81 82 83 84 85 86 87
    MPIDI_CH3_PKT_GET_ACCUM,
    MPIDI_CH3_PKT_FOP,
    MPIDI_CH3_PKT_CAS,
    MPIDI_CH3_PKT_GET_RESP,
    MPIDI_CH3_PKT_GET_ACCUM_RESP,
    MPIDI_CH3_PKT_FOP_RESP,
    MPIDI_CH3_PKT_CAS_RESP,
88 89
    MPIDI_CH3_PKT_LOCK,
    MPIDI_CH3_PKT_LOCK_GRANTED,
90
    MPIDI_CH3_PKT_UNLOCK,
91
    MPIDI_CH3_PKT_FLUSH,
Xin Zhao's avatar
Xin Zhao committed
92
    MPIDI_CH3_PKT_FLUSH_ACK,
93
    MPIDI_CH3_PKT_DECR_AT_COUNTER,
94 95
    /* RMA Packets end here */
    MPIDI_CH3_PKT_FLOW_CNTL_UPDATE,     /* FIXME: Unused */
96
    MPIDI_CH3_PKT_CLOSE,
Wesley Bland's avatar
Wesley Bland committed
97
    MPIDI_CH3_PKT_REVOKE,
Pavan Balaji's avatar
Pavan Balaji committed
98
    MPIDI_CH3_PKT_END_CH3,
99
    /* The channel can define additional types by defining the value
100
     * MPIDI_CH3_PKT_ENUM */
101
# if defined(MPIDI_CH3_PKT_ENUM)
Pavan Balaji's avatar
Pavan Balaji committed
102
    MPIDI_CH3_PKT_ENUM,
103
# endif
Pavan Balaji's avatar
Pavan Balaji committed
104
    MPIDI_CH3_PKT_END_ALL,
105
    MPIDI_CH3_PKT_INVALID = -1  /* forces a signed enum to quash warnings */
Pavan Balaji's avatar
Pavan Balaji committed
106
} MPIDI_CH3_Pkt_type_t;
107

108
/* These flags can be "OR'ed" together */
109 110 111 112 113 114
typedef enum {
    MPIDI_CH3_PKT_FLAG_NONE = 0,
    MPIDI_CH3_PKT_FLAG_RMA_LOCK = 1,
    MPIDI_CH3_PKT_FLAG_RMA_UNLOCK = 2,
    MPIDI_CH3_PKT_FLAG_RMA_FLUSH = 4,
    MPIDI_CH3_PKT_FLAG_RMA_REQ_ACK = 8,
115
    MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER = 16,
116 117
    MPIDI_CH3_PKT_FLAG_RMA_NOCHECK = 32,
    MPIDI_CH3_PKT_FLAG_RMA_SHARED = 64,
118
    MPIDI_CH3_PKT_FLAG_RMA_EXCLUSIVE = 128,
119 120 121
    MPIDI_CH3_PKT_FLAG_RMA_FLUSH_ACK = 256,
    MPIDI_CH3_PKT_FLAG_RMA_UNLOCK_ACK = 512,
    MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED = 1024
122
} MPIDI_CH3_Pkt_flags_t;
123

124
typedef struct MPIDI_CH3_Pkt_send {
125 126
    MPIDI_CH3_Pkt_type_t type;  /* XXX - uint8_t to conserve space ??? */
    MPIDI_Message_match match;
127
    MPI_Request sender_req_id;  /* needed for ssend and send cancel */
128 129 130
    MPIDI_msg_sz_t data_sz;
#if defined(MPID_USE_SEQUENCE_NUMBERS)
    MPID_Seqnum_t seqnum;
131 132
#endif
} MPIDI_CH3_Pkt_send_t;
133

134
/* NOTE: Normal and synchronous eager sends, as well as all ready-mode sends,
135 136 137 138
   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;
139 140

#if defined(USE_EAGER_SHORT)
141
typedef struct MPIDI_CH3_Pkt_eagershort_send {
142 143 144 145 146 147
    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
148 149
    int data[MPIDI_EAGER_SHORT_INTS];   /* FIXME: Experimental for now */
} MPIDI_CH3_Pkt_eagershort_send_t;
150
#endif /* defined(USE_EAGER_SHORT) */
151

152
typedef struct MPIDI_CH3_Pkt_eager_sync_ack {
153 154
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request sender_req_id;
155
} MPIDI_CH3_Pkt_eager_sync_ack_t;
156 157 158

typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_rndv_req_to_send_t;

159
typedef struct MPIDI_CH3_Pkt_rndv_clr_to_send {
160 161 162
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request sender_req_id;
    MPI_Request receiver_req_id;
163
} MPIDI_CH3_Pkt_rndv_clr_to_send_t;
164

165
typedef struct MPIDI_CH3_Pkt_rndv_send {
166 167
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request receiver_req_id;
168
} MPIDI_CH3_Pkt_rndv_send_t;
169

170
typedef struct MPIDI_CH3_Pkt_cancel_send_req {
171 172 173
    MPIDI_CH3_Pkt_type_t type;
    MPIDI_Message_match match;
    MPI_Request sender_req_id;
174
} MPIDI_CH3_Pkt_cancel_send_req_t;
175

176
typedef struct MPIDI_CH3_Pkt_cancel_send_resp {
177 178 179
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request sender_req_id;
    int ack;
180
} MPIDI_CH3_Pkt_cancel_send_resp_t;
181

182 183 184
/* *INDENT-OFF* */
/* Indentation turned off because "indent" is getting confused with
 * the lack of a semi-colon in the field below */
185 186 187
#if defined(MPIDI_CH3_PKT_DEFS)
MPIDI_CH3_PKT_DEFS
#endif
188
/* *INDENT-ON* */
189

190 191 192
#define MPIDI_CH3_PKT_RMA_GET_TARGET_DATATYPE(pkt_, datatype_, err_)    \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
Xin Zhao's avatar
Xin Zhao committed
193
        switch((pkt_).type) {                                           \
194
        case (MPIDI_CH3_PKT_PUT):                                       \
Xin Zhao's avatar
Xin Zhao committed
195
            datatype_ = (pkt_).put.datatype;                            \
196 197
            break;                                                      \
        case (MPIDI_CH3_PKT_GET):                                       \
Xin Zhao's avatar
Xin Zhao committed
198
            datatype_ = (pkt_).get.datatype;                            \
199 200
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
Xin Zhao's avatar
Xin Zhao committed
201
            datatype_ = (pkt_).accum.datatype;                          \
202
            break;                                                      \
Xin Zhao's avatar
Xin Zhao committed
203
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
Xin Zhao's avatar
Xin Zhao committed
204
            datatype_ = (pkt_).get_accum.datatype;                      \
Xin Zhao's avatar
Xin Zhao committed
205
            break;                                                      \
206
        case (MPIDI_CH3_PKT_CAS):                                       \
Xin Zhao's avatar
Xin Zhao committed
207
            datatype_ = (pkt_).cas.datatype;                            \
208 209
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
Xin Zhao's avatar
Xin Zhao committed
210
            datatype_ = (pkt_).fop.datatype;                            \
211 212
            break;                                                      \
        default:                                                        \
Xin Zhao's avatar
Xin Zhao committed
213
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
214 215 216
        }                                                               \
    }

Xin Zhao's avatar
Xin Zhao committed
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 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
#define MPIDI_CH3_PKT_RMA_GET_LOCK_TYPE(pkt_, lock_type_, err_)         \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
        switch((pkt_).type) {                                           \
        case (MPIDI_CH3_PKT_PUT):                                       \
            lock_type_ = (pkt_).put.lock_type;                          \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET):                                       \
            lock_type_ = (pkt_).get.lock_type;                          \
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
            lock_type_ = (pkt_).accum.lock_type;                        \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
            lock_type_ = (pkt_).get_accum.lock_type;                    \
            break;                                                      \
        case (MPIDI_CH3_PKT_CAS):                                       \
            lock_type_ = (pkt_).cas.lock_type;                          \
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
            lock_type_ = (pkt_).fop.lock_type;                          \
            break;                                                      \
        case (MPIDI_CH3_PKT_LOCK):                                      \
            lock_type_ = (pkt_).lock.lock_type;                         \
            break;                                                      \
        default:                                                        \
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
        }                                                               \
    }

#define MPIDI_CH3_PKT_RMA_GET_ORIGIN_RANK(pkt_, origin_rank_, err_)     \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
        switch((pkt_).type) {                                           \
        case (MPIDI_CH3_PKT_PUT):                                       \
            origin_rank_ = (pkt_).put.origin_rank;                      \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET):                                       \
            origin_rank_ = (pkt_).get.origin_rank;                      \
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
            origin_rank_ = (pkt_).accum.origin_rank;                    \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
            origin_rank_ = (pkt_).get_accum.origin_rank;                \
            break;                                                      \
        case (MPIDI_CH3_PKT_CAS):                                       \
            origin_rank_ = (pkt_).cas.origin_rank;                      \
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
            origin_rank_ = (pkt_).fop.origin_rank;                      \
            break;                                                      \
        case (MPIDI_CH3_PKT_LOCK):                                      \
            origin_rank_ = (pkt_).lock.origin_rank;                     \
            break;                                                      \
        default:                                                        \
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
        }                                                               \
    }

#define MPIDI_CH3_PKT_RMA_GET_FLAGS(pkt_, flags_, err_)                 \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
        switch((pkt_).type) {                                           \
        case (MPIDI_CH3_PKT_PUT):                                       \
            flags_ = (pkt_).put.flags;                                  \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET):                                       \
            flags_ = (pkt_).get.flags;                                  \
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
            flags_ = (pkt_).accum.flags;                                \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
            flags_ = (pkt_).get_accum.flags;                            \
            break;                                                      \
        case (MPIDI_CH3_PKT_CAS):                                       \
            flags_ = (pkt_).cas.flags;                                  \
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
            flags_ = (pkt_).fop.flags;                                  \
            break;                                                      \
        default:                                                        \
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
        }                                                               \
    }

#define MPIDI_CH3_PKT_RMA_UNSET_FLAG(pkt_, flag_, err_)                 \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
        switch((pkt_).type) {                                           \
        case (MPIDI_CH3_PKT_PUT):                                       \
            (pkt_).put.flags &= ~(flag_);                               \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET):                                       \
            (pkt_).get.flags &= ~(flag_);                               \
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
            (pkt_).accum.flags &= ~(flag_);                             \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
            (pkt_).get_accum.flags &= ~(flag_);                         \
            break;                                                      \
        case (MPIDI_CH3_PKT_CAS):                                       \
            (pkt_).cas.flags &= ~(flag_);                               \
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
            (pkt_).fop.flags &= ~(flag_);                               \
            break;                                                      \
        default:                                                        \
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
        }                                                               \
    }

#define MPIDI_CH3_PKT_RMA_SET_FLAG(pkt_, flag_, err_)                   \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
        switch((pkt_).type) {                                           \
        case (MPIDI_CH3_PKT_PUT):                                       \
            (pkt_).put.flags |= (flag_);                                \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET):                                       \
            (pkt_).get.flags |= (flag_);                                \
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
            (pkt_).accum.flags |= (flag_);                              \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
            (pkt_).get_accum.flags |= (flag_);                          \
            break;                                                      \
        case (MPIDI_CH3_PKT_CAS):                                       \
            (pkt_).cas.flags |= (flag_);                                \
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
            (pkt_).fop.flags |= (flag_);                                \
            break;                                                      \
        default:                                                        \
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
        }                                                               \
    }

#define MPIDI_CH3_PKT_RMA_SET_DATALOOP_SIZE(pkt_, dataloop_size_, err_) \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
        switch((pkt_).type) {                                           \
        case (MPIDI_CH3_PKT_PUT):                                       \
            (pkt_).put.dataloop_size = (dataloop_size_);                \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET):                                       \
            (pkt_).get.dataloop_size = (dataloop_size_);                \
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
            (pkt_).accum.dataloop_size = (dataloop_size_);              \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
            (pkt_).get_accum.dataloop_size = (dataloop_size_);          \
            break;                                                      \
        default:                                                        \
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
        }                                                               \
    }


380
typedef struct MPIDI_CH3_Pkt_put {
381
    MPIDI_CH3_Pkt_type_t type;
382
    MPIDI_CH3_Pkt_flags_t flags;
383 384 385
    void *addr;
    int count;
    MPI_Datatype datatype;
386 387 388 389 390 391 392 393
    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*/
Xin Zhao's avatar
Xin Zhao committed
394 395
    char data[MPIDI_RMA_IMMED_BYTES];
    size_t immed_len;
396 397
    int lock_type;      /* used when piggybacking LOCK message. */
    int origin_rank;    /* used when piggybacking LOCK message. */
398 399 400
} MPIDI_CH3_Pkt_put_t;

typedef struct MPIDI_CH3_Pkt_get {
401
    MPIDI_CH3_Pkt_type_t type;
402
    MPIDI_CH3_Pkt_flags_t flags;
403 404 405
    void *addr;
    int count;
    MPI_Datatype datatype;
406
    int dataloop_size;          /* for derived datatypes */
407
    MPI_Request request_handle;
408 409 410 411 412 413 414
    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*/
415 416
    int lock_type;   /* used when piggybacking LOCK message. */
    int origin_rank; /* used when piggybacking LOCK message. */
417 418 419
} MPIDI_CH3_Pkt_get_t;

typedef struct MPIDI_CH3_Pkt_get_resp {
420 421
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
422 423 424 425
    /* followings are used to decrement ack_counter at origin */
    int target_rank;
    MPI_Win source_win_handle;
    MPIDI_CH3_Pkt_flags_t flags;
426
} MPIDI_CH3_Pkt_get_resp_t;
427

428
typedef struct MPIDI_CH3_Pkt_accum {
429
    MPIDI_CH3_Pkt_type_t type;
430
    MPIDI_CH3_Pkt_flags_t flags;
431 432 433
    void *addr;
    int count;
    MPI_Datatype datatype;
434
    int dataloop_size;          /* for derived datatypes */
435
    MPI_Op op;
436 437 438 439 440 441 442
    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*/
Xin Zhao's avatar
Xin Zhao committed
443 444
    char data[MPIDI_RMA_IMMED_BYTES];
    size_t immed_len;
445 446
    int lock_type;    /* used when piggybacking LOCK message. */
    int origin_rank;  /* used when piggybacking LOCK message. */
447 448
} MPIDI_CH3_Pkt_accum_t;

Xin Zhao's avatar
Xin Zhao committed
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
typedef struct MPIDI_CH3_Pkt_get_accum {
    MPIDI_CH3_Pkt_type_t type;
    MPIDI_CH3_Pkt_flags_t flags;
    MPI_Request request_handle; /* For get_accumulate response */
    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*/
Xin Zhao's avatar
Xin Zhao committed
465 466
    char data[MPIDI_RMA_IMMED_BYTES];
    size_t immed_len;
467 468
    int lock_type;     /* used when piggybacking LOCK message. */
    int origin_rank;   /* used when piggybacking LOCK message. */
Xin Zhao's avatar
Xin Zhao committed
469 470
} MPIDI_CH3_Pkt_get_accum_t;

471
typedef struct MPIDI_CH3_Pkt_get_accum_resp {
472 473
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
474 475 476 477
    /* followings are used to decrement ack_counter at origin */
    int target_rank;
    MPI_Win source_win_handle;
    MPIDI_CH3_Pkt_flags_t flags;
478
} MPIDI_CH3_Pkt_get_accum_resp_t;
479

480
typedef struct MPIDI_CH3_Pkt_cas {
481
    MPIDI_CH3_Pkt_type_t type;
482
    MPIDI_CH3_Pkt_flags_t flags;
483
    MPI_Datatype datatype;
484
    void *addr;
485
    MPI_Request request_handle;
486
    MPI_Win source_win_handle;
487 488 489 490
    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*/
491 492
    MPIDI_CH3_CAS_Immed_u origin_data;
    MPIDI_CH3_CAS_Immed_u compare_data;
493 494
    int lock_type;     /* used when piggybacking LOCK message. */
    int origin_rank;   /* used when piggybacking LOCK message. */
495
} MPIDI_CH3_Pkt_cas_t;
496

497
typedef struct MPIDI_CH3_Pkt_cas_resp {
498 499 500
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
    MPIDI_CH3_CAS_Immed_u data;
501 502 503 504
    /* followings are used to decrement ack_counter at orign */
    int target_rank;
    MPI_Win source_win_handle;
    MPIDI_CH3_Pkt_flags_t flags;
505
} MPIDI_CH3_Pkt_cas_resp_t;
506

507
typedef struct MPIDI_CH3_Pkt_fop {
508
    MPIDI_CH3_Pkt_type_t type;
509
    MPIDI_CH3_Pkt_flags_t flags;
510 511 512 513
    MPI_Datatype datatype;
    void *addr;
    MPI_Op op;
    MPI_Request request_handle;
514
    MPI_Win source_win_handle;
515 516 517 518
    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*/
Xin Zhao's avatar
Xin Zhao committed
519 520
    char data[MPIDI_RMA_IMMED_BYTES];
    int immed_len;
521 522
    int lock_type;     /* used when piggybacking LOCK message. */
    int origin_rank;   /* used when piggybacking LOCK message. */
523
} MPIDI_CH3_Pkt_fop_t;
524

525
typedef struct MPIDI_CH3_Pkt_fop_resp {
526 527
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
Xin Zhao's avatar
Xin Zhao committed
528 529
    char data[MPIDI_RMA_IMMED_BYTES];
    int immed_len;
530 531 532 533
    /* followings are used to decrement ack_counter at orign */
    int target_rank;
    MPI_Win source_win_handle;
    MPIDI_CH3_Pkt_flags_t flags;
534
} MPIDI_CH3_Pkt_fop_resp_t;
535

536
typedef struct MPIDI_CH3_Pkt_lock {
537 538 539 540
    MPIDI_CH3_Pkt_type_t type;
    int lock_type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
541
    int target_rank;            /* Used in unluck/flush response to look up the
542
                                 * target state at the origin. */
543
    int origin_rank;
544
} MPIDI_CH3_Pkt_lock_t;
545

Xin Zhao's avatar
Xin Zhao committed
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
typedef struct MPIDI_CH3_Pkt_unlock {
    MPIDI_CH3_Pkt_type_t type;
    int lock_type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
    int target_rank;            /* Used in unluck/flush response to look up the
                                 * target state at the origin. */
    int origin_rank;
} MPIDI_CH3_Pkt_unlock_t;

typedef struct MPIDI_CH3_Pkt_flush {
    MPIDI_CH3_Pkt_type_t type;
    int lock_type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
    int target_rank;            /* Used in unluck/flush response to look up the
                                 * target state at the origin. */
    int origin_rank;
} MPIDI_CH3_Pkt_flush_t;

566
typedef struct MPIDI_CH3_Pkt_lock_granted {
567 568
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win source_win_handle;
Xin Zhao's avatar
Xin Zhao committed
569
    int target_rank;            /* Used in flush_ack response to look up the
570 571
                                 * target state at the origin. */
} MPIDI_CH3_Pkt_lock_granted_t;
572

Xin Zhao's avatar
Xin Zhao committed
573 574 575 576 577
typedef struct MPIDI_CH3_Pkt_flush_ack {
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win source_win_handle;
    int target_rank;            /* Used in flush_ack response to look up the
                                 * target state at the origin. */
578
    MPIDI_CH3_Pkt_flags_t flags;
Xin Zhao's avatar
Xin Zhao committed
579
} MPIDI_CH3_Pkt_flush_ack_t;
580

581 582 583 584 585
typedef struct MPIDI_CH3_Pkt_decr_at_counter {
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win target_win_handle;
} MPIDI_CH3_Pkt_decr_at_counter_t;

586
typedef struct MPIDI_CH3_Pkt_close {
587 588
    MPIDI_CH3_Pkt_type_t type;
    int ack;
589
} MPIDI_CH3_Pkt_close_t;
590

591
typedef struct MPIDI_CH3_Pkt_revoke {
Wesley Bland's avatar
Wesley Bland committed
592 593
    MPIDI_CH3_Pkt_type_t type;
    MPIR_Context_id_t revoked_comm;
594
} MPIDI_CH3_Pkt_revoke_t;
Wesley Bland's avatar
Wesley Bland committed
595

596
typedef union MPIDI_CH3_Pkt {
597 598
    MPIDI_CH3_Pkt_type_t type;
    MPIDI_CH3_Pkt_eager_send_t eager_send;
599
#if defined(USE_EAGER_SHORT)
600
    MPIDI_CH3_Pkt_eagershort_send_t eagershort_send;
601
#endif                          /* defined(USE_EAGER_SHORT) */
602 603 604 605 606 607 608 609 610 611 612 613
    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;
Xin Zhao's avatar
Xin Zhao committed
614
    MPIDI_CH3_Pkt_get_accum_t get_accum;
615 616
    MPIDI_CH3_Pkt_lock_t lock;
    MPIDI_CH3_Pkt_lock_granted_t lock_granted;
617
    MPIDI_CH3_Pkt_unlock_t unlock;
618
    MPIDI_CH3_Pkt_flush_t flush;
Xin Zhao's avatar
Xin Zhao committed
619
    MPIDI_CH3_Pkt_flush_ack_t flush_ack;
620
    MPIDI_CH3_Pkt_decr_at_counter_t decr_at_cnt;
621
    MPIDI_CH3_Pkt_close_t close;
622 623
    MPIDI_CH3_Pkt_cas_t cas;
    MPIDI_CH3_Pkt_cas_resp_t cas_resp;
624 625
    MPIDI_CH3_Pkt_fop_t fop;
    MPIDI_CH3_Pkt_fop_resp_t fop_resp;
626
    MPIDI_CH3_Pkt_get_accum_resp_t get_accum_resp;
Wesley Bland's avatar
Wesley Bland committed
627
    MPIDI_CH3_Pkt_revoke_t revoke;
628
# if defined(MPIDI_CH3_PKT_DECL)
629
     MPIDI_CH3_PKT_DECL
630
# endif
631
} MPIDI_CH3_Pkt_t;
632 633

#if defined(MPID_USE_SEQUENCE_NUMBERS)
634
typedef struct MPIDI_CH3_Pkt_send_container {
635
    MPIDI_CH3_Pkt_send_t pkt;
636 637
    struct MPIDI_CH3_Pkt_send_container_s *next;
} MPIDI_CH3_Pkt_send_container_t;
638 639 640
#endif

#endif