mpidpkt.h 31.4 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 {
Pavan Balaji's avatar
Pavan Balaji committed
65
    MPIDI_CH3_PKT_EAGER_SEND = 42,
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 88
    MPIDI_CH3_PKT_GET_ACCUM,
    MPIDI_CH3_PKT_ACCUM_IMMED,  /* optimization for short accumulate */
    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,
89 90
    MPIDI_CH3_PKT_LOCK,
    MPIDI_CH3_PKT_LOCK_GRANTED,
91
    MPIDI_CH3_PKT_UNLOCK,
92
    MPIDI_CH3_PKT_FLUSH,
Xin Zhao's avatar
Xin Zhao committed
93
    MPIDI_CH3_PKT_FLUSH_ACK,
94
    MPIDI_CH3_PKT_DECR_AT_COUNTER,
95 96 97 98 99
    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 */
    /* RMA Packets end here */
    MPIDI_CH3_PKT_FLOW_CNTL_UPDATE,     /* FIXME: Unused */
100
    MPIDI_CH3_PKT_CLOSE,
Wesley Bland's avatar
Wesley Bland committed
101
    MPIDI_CH3_PKT_REVOKE,
Pavan Balaji's avatar
Pavan Balaji committed
102
    MPIDI_CH3_PKT_END_CH3,
103
    /* The channel can define additional types by defining the value
104
     * MPIDI_CH3_PKT_ENUM */
105
# if defined(MPIDI_CH3_PKT_ENUM)
Pavan Balaji's avatar
Pavan Balaji committed
106
    MPIDI_CH3_PKT_ENUM,
107
# endif
Pavan Balaji's avatar
Pavan Balaji committed
108
    MPIDI_CH3_PKT_END_ALL,
109
    MPIDI_CH3_PKT_INVALID = -1  /* forces a signed enum to quash warnings */
Pavan Balaji's avatar
Pavan Balaji committed
110
} MPIDI_CH3_Pkt_type_t;
111

112
/* These flags can be "OR'ed" together */
113 114 115 116 117 118
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,
119
    MPIDI_CH3_PKT_FLAG_RMA_DECR_AT_COUNTER = 16,
120 121
    MPIDI_CH3_PKT_FLAG_RMA_NOCHECK = 32,
    MPIDI_CH3_PKT_FLAG_RMA_SHARED = 64,
122 123
    MPIDI_CH3_PKT_FLAG_RMA_EXCLUSIVE = 128,
    MPIDI_CH3_PKT_FLAG_RMA_FLUSH_ACK = 256
124
} MPIDI_CH3_Pkt_flags_t;
125

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

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

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

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

typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_rndv_req_to_send_t;

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

167
typedef struct MPIDI_CH3_Pkt_rndv_send {
168 169
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request receiver_req_id;
170
} MPIDI_CH3_Pkt_rndv_send_t;
171

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

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

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

192 193 194
#define MPIDI_CH3_PKT_RMA_GET_TARGET_DATATYPE(pkt_, datatype_, err_)    \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
Xin Zhao's avatar
Xin Zhao committed
195
        switch((pkt_).type) {                                           \
196
        case (MPIDI_CH3_PKT_PUT):                                       \
Xin Zhao's avatar
Xin Zhao committed
197
            datatype_ = (pkt_).put.datatype;                            \
198 199
            break;                                                      \
        case (MPIDI_CH3_PKT_GET):                                       \
Xin Zhao's avatar
Xin Zhao committed
200
            datatype_ = (pkt_).get.datatype;                            \
201 202
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
Xin Zhao's avatar
Xin Zhao committed
203
            datatype_ = (pkt_).accum.datatype;                          \
204
            break;                                                      \
Xin Zhao's avatar
Xin Zhao committed
205
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
Xin Zhao's avatar
Xin Zhao committed
206
            datatype_ = (pkt_).get_accum.datatype;                      \
Xin Zhao's avatar
Xin Zhao committed
207
            break;                                                      \
208
        case (MPIDI_CH3_PKT_CAS):                                       \
Xin Zhao's avatar
Xin Zhao committed
209
            datatype_ = (pkt_).cas.datatype;                            \
210 211
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
Xin Zhao's avatar
Xin Zhao committed
212
            datatype_ = (pkt_).fop.datatype;                            \
213 214 215 216 217 218 219 220 221 222 223 224 225 226
            break;                                                      \
        case (MPIDI_CH3_PKT_LOCK_PUT_UNLOCK):                           \
            datatype_ = pkt_.lock_put_unlock.datatype;                  \
            break;                                                      \
        case (MPIDI_CH3_PKT_LOCK_GET_UNLOCK):                           \
            datatype_ = pkt_.lock_get_unlock.datatype;                  \
            break;                                                      \
        case (MPIDI_CH3_PKT_LOCK_ACCUM_UNLOCK):                         \
            datatype_ = pkt_.lock_accum_unlock.datatype;                \
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUM_IMMED):                               \
            datatype_ = pkt_.accum_immed.datatype;                      \
            break;                                                      \
        default:                                                        \
Xin Zhao's avatar
Xin Zhao committed
227
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
228 229 230
        }                                                               \
    }

Xin Zhao's avatar
Xin Zhao committed
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 380 381 382 383 384 385 386 387 388 389 390 391 392 393
#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); \
        }                                                               \
    }


394
typedef struct MPIDI_CH3_Pkt_put {
395
    MPIDI_CH3_Pkt_type_t type;
396
    MPIDI_CH3_Pkt_flags_t flags;
397 398 399
    void *addr;
    int count;
    MPI_Datatype datatype;
400 401 402 403 404 405 406 407
    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
408 409
    char data[MPIDI_RMA_IMMED_BYTES];
    size_t immed_len;
410 411 412
} MPIDI_CH3_Pkt_put_t;

typedef struct MPIDI_CH3_Pkt_get {
413
    MPIDI_CH3_Pkt_type_t type;
414
    MPIDI_CH3_Pkt_flags_t flags;
415 416 417
    void *addr;
    int count;
    MPI_Datatype datatype;
418
    int dataloop_size;          /* for derived datatypes */
419
    MPI_Request request_handle;
420 421 422 423 424 425 426 427 428 429
    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 {
430 431
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
432 433 434 435
    /* followings are used to decrement ack_counter at origin */
    int target_rank;
    MPI_Win source_win_handle;
    MPIDI_CH3_Pkt_flags_t flags;
436
} MPIDI_CH3_Pkt_get_resp_t;
437

438
typedef struct MPIDI_CH3_Pkt_accum {
439
    MPIDI_CH3_Pkt_type_t type;
440
    MPIDI_CH3_Pkt_flags_t flags;
441 442 443
    void *addr;
    int count;
    MPI_Datatype datatype;
444
    int dataloop_size;          /* for derived datatypes */
445
    MPI_Op op;
446 447 448 449 450 451 452
    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
453 454
    char data[MPIDI_RMA_IMMED_BYTES];
    size_t immed_len;
455 456
} MPIDI_CH3_Pkt_accum_t;

Xin Zhao's avatar
Xin Zhao committed
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
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
473 474
    char data[MPIDI_RMA_IMMED_BYTES];
    size_t immed_len;
Xin Zhao's avatar
Xin Zhao committed
475 476
} MPIDI_CH3_Pkt_get_accum_t;

477
typedef struct MPIDI_CH3_Pkt_get_accum_resp {
478 479
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
480 481 482 483
    /* followings are used to decrement ack_counter at origin */
    int target_rank;
    MPI_Win source_win_handle;
    MPIDI_CH3_Pkt_flags_t flags;
484
} MPIDI_CH3_Pkt_get_accum_resp_t;
485

486
typedef struct MPIDI_CH3_Pkt_accum_immed {
487
    MPIDI_CH3_Pkt_type_t type;
488
    MPIDI_CH3_Pkt_flags_t flags;
489 490 491 492 493 494
    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?) */
495 496 497 498 499 500 501
    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*/
502
    int data[MPIDI_RMA_IMMED_INTS];
503
} MPIDI_CH3_Pkt_accum_immed_t;
504

505
typedef struct MPIDI_CH3_Pkt_cas {
506
    MPIDI_CH3_Pkt_type_t type;
507
    MPIDI_CH3_Pkt_flags_t flags;
508
    MPI_Datatype datatype;
509
    void *addr;
510
    MPI_Request request_handle;
511
    MPI_Win source_win_handle;
512 513 514 515
    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*/
516 517
    MPIDI_CH3_CAS_Immed_u origin_data;
    MPIDI_CH3_CAS_Immed_u compare_data;
518
} MPIDI_CH3_Pkt_cas_t;
519

520
typedef struct MPIDI_CH3_Pkt_cas_resp {
521 522 523
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
    MPIDI_CH3_CAS_Immed_u data;
524 525 526 527
    /* followings are used to decrement ack_counter at orign */
    int target_rank;
    MPI_Win source_win_handle;
    MPIDI_CH3_Pkt_flags_t flags;
528
} MPIDI_CH3_Pkt_cas_resp_t;
529

530
typedef struct MPIDI_CH3_Pkt_fop {
531
    MPIDI_CH3_Pkt_type_t type;
532
    MPIDI_CH3_Pkt_flags_t flags;
533 534 535 536
    MPI_Datatype datatype;
    void *addr;
    MPI_Op op;
    MPI_Request request_handle;
537
    MPI_Win source_win_handle;
538 539 540 541
    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
542 543
    char data[MPIDI_RMA_IMMED_BYTES];
    int immed_len;
544
} MPIDI_CH3_Pkt_fop_t;
545

546
typedef struct MPIDI_CH3_Pkt_fop_resp {
547 548
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request request_handle;
Xin Zhao's avatar
Xin Zhao committed
549 550
    char data[MPIDI_RMA_IMMED_BYTES];
    int immed_len;
551 552 553 554
    /* followings are used to decrement ack_counter at orign */
    int target_rank;
    MPI_Win source_win_handle;
    MPIDI_CH3_Pkt_flags_t flags;
555
} MPIDI_CH3_Pkt_fop_resp_t;
556

557
typedef struct MPIDI_CH3_Pkt_lock {
558 559 560 561
    MPIDI_CH3_Pkt_type_t type;
    int lock_type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
562
    int target_rank;            /* Used in unluck/flush response to look up the
563
                                 * target state at the origin. */
564
    int origin_rank;
565
} MPIDI_CH3_Pkt_lock_t;
566

Xin Zhao's avatar
Xin Zhao committed
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
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;

587
typedef struct MPIDI_CH3_Pkt_lock_granted {
588 589
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win source_win_handle;
Xin Zhao's avatar
Xin Zhao committed
590
    int target_rank;            /* Used in flush_ack response to look up the
591 592
                                 * target state at the origin. */
} MPIDI_CH3_Pkt_lock_granted_t;
593

Xin Zhao's avatar
Xin Zhao committed
594 595 596 597 598 599
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. */
} MPIDI_CH3_Pkt_flush_ack_t;
600

601 602 603 604 605
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;

606
typedef struct MPIDI_CH3_Pkt_lock_put_unlock {
607
    MPIDI_CH3_Pkt_type_t type;
608
    MPIDI_CH3_Pkt_flags_t flags;
609 610
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
611
    int origin_rank;
612 613 614 615
    int lock_type;
    void *addr;
    int count;
    MPI_Datatype datatype;
616
} MPIDI_CH3_Pkt_lock_put_unlock_t;
617

618
typedef struct MPIDI_CH3_Pkt_lock_get_unlock {
619
    MPIDI_CH3_Pkt_type_t type;
620
    MPIDI_CH3_Pkt_flags_t flags;
621 622
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
623
    int origin_rank;
624 625 626 627 628
    int lock_type;
    void *addr;
    int count;
    MPI_Datatype datatype;
    MPI_Request request_handle;
629
} MPIDI_CH3_Pkt_lock_get_unlock_t;
630

631
typedef struct MPIDI_CH3_Pkt_lock_accum_unlock {
632
    MPIDI_CH3_Pkt_type_t type;
633
    MPIDI_CH3_Pkt_flags_t flags;
634 635
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
636
    int origin_rank;
637 638 639 640 641
    int lock_type;
    void *addr;
    int count;
    MPI_Datatype datatype;
    MPI_Op op;
642
} MPIDI_CH3_Pkt_lock_accum_unlock_t;
643 644


645
typedef struct MPIDI_CH3_Pkt_close {
646 647
    MPIDI_CH3_Pkt_type_t type;
    int ack;
648
} MPIDI_CH3_Pkt_close_t;
649

650
typedef struct MPIDI_CH3_Pkt_revoke {
Wesley Bland's avatar
Wesley Bland committed
651 652
    MPIDI_CH3_Pkt_type_t type;
    MPIR_Context_id_t revoked_comm;
653
} MPIDI_CH3_Pkt_revoke_t;
Wesley Bland's avatar
Wesley Bland committed
654

655
typedef union MPIDI_CH3_Pkt {
656 657
    MPIDI_CH3_Pkt_type_t type;
    MPIDI_CH3_Pkt_eager_send_t eager_send;
658
#if defined(USE_EAGER_SHORT)
659
    MPIDI_CH3_Pkt_eagershort_send_t eagershort_send;
660
#endif                          /* defined(USE_EAGER_SHORT) */
661 662 663 664 665 666 667 668 669 670 671 672
    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;
673
    MPIDI_CH3_Pkt_accum_immed_t accum_immed;
Xin Zhao's avatar
Xin Zhao committed
674
    MPIDI_CH3_Pkt_get_accum_t get_accum;
675 676
    MPIDI_CH3_Pkt_lock_t lock;
    MPIDI_CH3_Pkt_lock_granted_t lock_granted;
677
    MPIDI_CH3_Pkt_unlock_t unlock;
678
    MPIDI_CH3_Pkt_flush_t flush;
Xin Zhao's avatar
Xin Zhao committed
679
    MPIDI_CH3_Pkt_flush_ack_t flush_ack;
680
    MPIDI_CH3_Pkt_decr_at_counter_t decr_at_cnt;
681 682 683 684
    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;
685 686
    MPIDI_CH3_Pkt_cas_t cas;
    MPIDI_CH3_Pkt_cas_resp_t cas_resp;
687 688
    MPIDI_CH3_Pkt_fop_t fop;
    MPIDI_CH3_Pkt_fop_resp_t fop_resp;
689
    MPIDI_CH3_Pkt_get_accum_resp_t get_accum_resp;
Wesley Bland's avatar
Wesley Bland committed
690
    MPIDI_CH3_Pkt_revoke_t revoke;
691
# if defined(MPIDI_CH3_PKT_DECL)
692
     MPIDI_CH3_PKT_DECL
693
# endif
694
} MPIDI_CH3_Pkt_t;
695 696

#if defined(MPID_USE_SEQUENCE_NUMBERS)
697
typedef struct MPIDI_CH3_Pkt_send_container {
698
    MPIDI_CH3_Pkt_send_t pkt;
699 700
    struct MPIDI_CH3_Pkt_send_container_s *next;
} MPIDI_CH3_Pkt_send_container_t;
701 702 703
#endif

#endif