mpidpkt.h 31.7 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
    MPIDI_CH3_PKT_LOCK,
89
    MPIDI_CH3_PKT_UNLOCK,
90
    MPIDI_CH3_PKT_FLUSH,
91
    MPIDI_CH3_PKT_DECR_AT_COUNTER,
92
    MPIDI_CH3_PKT_LOCK_ACK,
93
    MPIDI_CH3_PKT_FLUSH_ACK,
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
    MPIDI_CH3_PKT_FLAG_RMA_FLUSH_ACK = 256,
120 121 122 123 124 125
    MPIDI_CH3_PKT_FLAG_RMA_LOCK_GRANTED = 512,
    MPIDI_CH3_PKT_FLAG_RMA_LOCK_QUEUED_DATA_QUEUED = 1024,
    MPIDI_CH3_PKT_FLAG_RMA_LOCK_QUEUED_DATA_DISCARDED = 2048,
    MPIDI_CH3_PKT_FLAG_RMA_LOCK_DISCARDED = 4096,
    MPIDI_CH3_PKT_FLAG_RMA_UNLOCK_NO_ACK = 8192,
    MPIDI_CH3_PKT_FLAG_RMA_IMMED_RESP = 16384
126
} MPIDI_CH3_Pkt_flags_t;
127

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

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

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

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

typedef MPIDI_CH3_Pkt_send_t MPIDI_CH3_Pkt_rndv_req_to_send_t;

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

169
typedef struct MPIDI_CH3_Pkt_rndv_send {
170 171
    MPIDI_CH3_Pkt_type_t type;
    MPI_Request receiver_req_id;
172
} MPIDI_CH3_Pkt_rndv_send_t;
173

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

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

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

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

#define MPIDI_CH3_PKT_RMA_GET_IMMED_LEN(pkt_, immed_len_, err_)         \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
        switch((pkt_).type) {                                           \
        case (MPIDI_CH3_PKT_PUT):                                       \
            immed_len_ = (pkt_).put.immed_len;                          \
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
            immed_len_ = (pkt_).accum.immed_len;                        \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
            immed_len_ = (pkt_).get_accum.immed_len;                    \
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
            immed_len_ = (pkt_).fop.immed_len;                          \
            break;                                                      \
        case (MPIDI_CH3_PKT_CAS):                                       \
            /* FIXME: we should deal with CAS here */                   \
            break;                                                      \
        default:                                                        \
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
        }                                                               \
    }

#define MPIDI_CH3_PKT_RMA_GET_IMMED_DATA_PTR(pkt_, immed_data_, err_)   \
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
        switch((pkt_).type) {                                           \
        case (MPIDI_CH3_PKT_PUT):                                       \
            immed_data_ = (pkt_).put.data;                              \
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
            immed_data_ = (pkt_).accum.data;                            \
            break;                                                      \
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
            immed_data_ = (pkt_).get_accum.data;                        \
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
            immed_data_ = (pkt_).fop.data;                              \
            break;                                                      \
        case (MPIDI_CH3_PKT_CAS):                                       \
            /* FIXME: we should deal with CAS here */                   \
            break;                                                      \
        default:                                                        \
            MPIU_ERR_SETANDJUMP1(err_, MPI_ERR_OTHER, "**invalidpkt", "**invalidpkt %d", (pkt_).type); \
        }                                                               \
    }

Xin Zhao's avatar
Xin Zhao committed
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
#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); \
        }                                                               \
    }

381
#define MPIDI_CH3_PKT_RMA_GET_TARGET_WIN_HANDLE(pkt_, win_hdl_, err_)   \
Xin Zhao's avatar
Xin Zhao committed
382 383 384 385
    {                                                                   \
        err_ = MPI_SUCCESS;                                             \
        switch((pkt_).type) {                                           \
        case (MPIDI_CH3_PKT_PUT):                                       \
386
            win_hdl_ = (pkt_).put.target_win_handle;                    \
Xin Zhao's avatar
Xin Zhao committed
387 388
            break;                                                      \
        case (MPIDI_CH3_PKT_GET):                                       \
389
            win_hdl_ = (pkt_).get.target_win_handle;                    \
Xin Zhao's avatar
Xin Zhao committed
390 391
            break;                                                      \
        case (MPIDI_CH3_PKT_ACCUMULATE):                                \
392
            win_hdl_ = (pkt_).accum.target_win_handle;                  \
Xin Zhao's avatar
Xin Zhao committed
393 394
            break;                                                      \
        case (MPIDI_CH3_PKT_GET_ACCUM):                                 \
395
            win_hdl_ = (pkt_).get_accum.target_win_handle;              \
Xin Zhao's avatar
Xin Zhao committed
396 397
            break;                                                      \
        case (MPIDI_CH3_PKT_CAS):                                       \
398
            win_hdl_ = (pkt_).cas.target_win_handle;                    \
Xin Zhao's avatar
Xin Zhao committed
399 400
            break;                                                      \
        case (MPIDI_CH3_PKT_FOP):                                       \
401
            win_hdl_ = (pkt_).fop.target_win_handle;                    \
Xin Zhao's avatar
Xin Zhao committed
402
            break;                                                      \
403 404 405
        case (MPIDI_CH3_PKT_LOCK):                                      \
            win_hdl_ = (pkt_).lock.target_win_handle;                   \
            break;                                                      \
Xin Zhao's avatar
Xin Zhao committed
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
        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); \
        }                                                               \
    }

432 433 434 435 436
/* RMA packets start here */

/********************************************************************************/
/* RMA packet (from origin to target, including PUT, GET, ACC, GACC, CAS, FOP)  */
/********************************************************************************/
Xin Zhao's avatar
Xin Zhao committed
437

438
typedef struct MPIDI_CH3_Pkt_put {
439
    MPIDI_CH3_Pkt_type_t type;
440
    MPIDI_CH3_Pkt_flags_t flags;
441 442 443
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
    /* Followings are to describe target data */
444 445 446
    void *addr;
    int count;
    MPI_Datatype datatype;
447 448 449 450 451
    int dataloop_size;
    /* Followings are to piggyback LOCK */
    int lock_type;
    int origin_rank;
    /* Followings are to piggyback IMMED data */
452
    int immed_len;
453
    char data[MPIDI_RMA_IMMED_BYTES];
454 455 456
} MPIDI_CH3_Pkt_put_t;

typedef struct MPIDI_CH3_Pkt_get {
457
    MPIDI_CH3_Pkt_type_t type;
458
    MPIDI_CH3_Pkt_flags_t flags;
459 460 461
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
    /* Followings are to describe target data */
462 463 464
    void *addr;
    int count;
    MPI_Datatype datatype;
465 466
    int dataloop_size;
    /* Following is to complete request at origin */
467
    MPI_Request request_handle;
468 469 470
    /* Followings are to piggyback LOCK */
    int lock_type;
    int origin_rank;
471 472 473
} MPIDI_CH3_Pkt_get_t;

typedef struct MPIDI_CH3_Pkt_accum {
474
    MPIDI_CH3_Pkt_type_t type;
475
    MPIDI_CH3_Pkt_flags_t flags;
476 477 478
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
    /* Followings are to describe target data */
479 480 481
    void *addr;
    int count;
    MPI_Datatype datatype;
482 483
    int dataloop_size;
    /* Following is to specify ACC op */
484
    MPI_Op op;
485 486 487 488
    /* Followings are to piggyback LOCK */
    int lock_type;
    int origin_rank;
    /* Followings are to piggyback IMMED data */
489
    int immed_len;
490
    char data[MPIDI_RMA_IMMED_BYTES];
491 492
} MPIDI_CH3_Pkt_accum_t;

Xin Zhao's avatar
Xin Zhao committed
493 494 495
typedef struct MPIDI_CH3_Pkt_get_accum {
    MPIDI_CH3_Pkt_type_t type;
    MPIDI_CH3_Pkt_flags_t flags;
496 497 498
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
    /* Followings are to describe target data */
Xin Zhao's avatar
Xin Zhao committed
499 500 501
    void *addr;
    int count;
    MPI_Datatype datatype;
502 503
    int dataloop_size;
    /* Following is to describe ACC op */
Xin Zhao's avatar
Xin Zhao committed
504
    MPI_Op op;
505 506 507 508 509 510
    /* Following is to complete request on origin */
    MPI_Request request_handle;
    /* Followings are to piggyback LOCK */
    int lock_type;
    int origin_rank;
    /* Followings are to piggback IMMED data */
511
    int immed_len;
512
    char data[MPIDI_RMA_IMMED_BYTES];
Xin Zhao's avatar
Xin Zhao committed
513 514
} MPIDI_CH3_Pkt_get_accum_t;

515
typedef struct MPIDI_CH3_Pkt_fop {
516
    MPIDI_CH3_Pkt_type_t type;
517
    MPIDI_CH3_Pkt_flags_t flags;
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
    MPI_Win source_win_handle;
    MPI_Win target_win_handle;
    /* Followings are to describe target data */
    void *addr;
    MPI_Datatype datatype;
    /* Following is to speicfy ACC op */
    MPI_Op op;
    /* Following is to complete request at origin */
    MPI_Request request_handle;
    /* Followings are to piggyback IMMED data */
    int lock_type;
    int origin_rank;
    /* Followings are to piggyback IMMED data */
    int immed_len;
    char data[MPIDI_RMA_IMMED_BYTES];
} MPIDI_CH3_Pkt_fop_t;
534

535
typedef struct MPIDI_CH3_Pkt_cas {
536
    MPIDI_CH3_Pkt_type_t type;
537
    MPIDI_CH3_Pkt_flags_t flags;
538 539 540
    MPI_Win source_win_handle;
    MPI_Win target_win_handle;
    /* Followings are to describe target data */
541
    void *addr;
542 543
    MPI_Datatype datatype;
    /* Following is to complete request on origin */
544
    MPI_Request request_handle;
545 546 547 548
    /* Followings are to piggyback LOCK */
    int lock_type;
    int origin_rank;
    /* Followings are to piggyback IMMED data */
549 550
    MPIDI_CH3_CAS_Immed_u origin_data;
    MPIDI_CH3_CAS_Immed_u compare_data;
551
} MPIDI_CH3_Pkt_cas_t;
552

553 554 555 556 557 558 559

/*********************************************************************************/
/* RMA response packet (from target to origin, including GET_RESP, GET_ACC_RESP, */
/* CAS_RESP, FOP_RESP)                                                           */
/*********************************************************************************/

typedef struct MPIDI_CH3_Pkt_get_resp {
560
    MPIDI_CH3_Pkt_type_t type;
561 562
    MPIDI_CH3_Pkt_flags_t flags;
    /* Following is to complete request at origin */
563
    MPI_Request request_handle;
564 565
    /* TODO: we should add IMMED data here */
    /* Followings are used to decrement ack_counter at origin */
566
    MPI_Win source_win_handle;
567
    int target_rank;
568
    /* Followings are to piggyback IMMED data */
569
    int immed_len;
570
    char data[MPIDI_RMA_IMMED_BYTES];
571
} MPIDI_CH3_Pkt_get_resp_t;
572

573
typedef struct MPIDI_CH3_Pkt_get_accum_resp {
574
    MPIDI_CH3_Pkt_type_t type;
575
    MPIDI_CH3_Pkt_flags_t flags;
576
    /* Following is to complete request at origin */
577
    MPI_Request request_handle;
578 579
    /* TODO: we should add IMMED data here */
    /* Followings are used to decrement ack_counter at origin */
580
    MPI_Win source_win_handle;
581
    int target_rank;
582
    /* Followings are to piggyback IMMED data */
583
    int immed_len;
584
    char data[MPIDI_RMA_IMMED_BYTES];
585
} MPIDI_CH3_Pkt_get_accum_resp_t;
586

587
typedef struct MPIDI_CH3_Pkt_fop_resp {
588
    MPIDI_CH3_Pkt_type_t type;
589 590
    MPIDI_CH3_Pkt_flags_t flags;
    /* Following is to complete request at origin */
591
    MPI_Request request_handle;
592
    /* Followings are used to decrement ack_counter at orign */
593
    MPI_Win source_win_handle;
594 595 596 597
    int target_rank;
    /* Followings are to piggyback IMMED data */
    int immed_len;
    char data[MPIDI_RMA_IMMED_BYTES];
598
} MPIDI_CH3_Pkt_fop_resp_t;
599

600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
typedef struct MPIDI_CH3_Pkt_cas_resp {
    MPIDI_CH3_Pkt_type_t type;
    MPIDI_CH3_Pkt_flags_t flags;
    /* Following is to complete request at origin */
    MPI_Request request_handle;
    /* Followings are used to decrement ack_counter at orign */
    MPI_Win source_win_handle;
    int target_rank;
    /* Following is to piggyback IMMED data */
    MPIDI_CH3_CAS_Immed_u data;
} MPIDI_CH3_Pkt_cas_resp_t;

/*********************************************************************************/
/* RMA control packet (from origin to target, including LOCK, UNLOCK, FLUSH)     */
/*********************************************************************************/

616
typedef struct MPIDI_CH3_Pkt_lock {
617 618 619
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
620
    int lock_type;
621
    int origin_rank;
622
} MPIDI_CH3_Pkt_lock_t;
623

Xin Zhao's avatar
Xin Zhao committed
624 625
typedef struct MPIDI_CH3_Pkt_unlock {
    MPIDI_CH3_Pkt_type_t type;
626
    MPIDI_CH3_Pkt_flags_t flags;
Xin Zhao's avatar
Xin Zhao committed
627 628 629 630 631 632 633 634 635 636
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
} MPIDI_CH3_Pkt_unlock_t;

typedef struct MPIDI_CH3_Pkt_flush {
    MPIDI_CH3_Pkt_type_t type;
    MPI_Win target_win_handle;
    MPI_Win source_win_handle;
} MPIDI_CH3_Pkt_flush_t;

637 638 639 640 641 642
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;

/*********************************************************************************/
643
/* RMA control response packet (from target to origin, including LOCK_ACK,       */
644 645 646
/* FLUSH_ACK)                                                                    */
/*********************************************************************************/

647
typedef struct MPIDI_CH3_Pkt_lock_ack {
648
    MPIDI_CH3_Pkt_type_t type;
649
    MPIDI_CH3_Pkt_flags_t flags;
650
    MPI_Win source_win_handle;
651
    int target_rank;
652
} MPIDI_CH3_Pkt_lock_ack_t;
653

Xin Zhao's avatar
Xin Zhao committed
654 655
typedef struct MPIDI_CH3_Pkt_flush_ack {
    MPIDI_CH3_Pkt_type_t type;
656 657
    MPI_Win source_win_handle;
    int target_rank;
Xin Zhao's avatar
Xin Zhao committed
658
} MPIDI_CH3_Pkt_flush_ack_t;
659

660
/* RMA packets end here */
661

662
typedef struct MPIDI_CH3_Pkt_close {
663 664
    MPIDI_CH3_Pkt_type_t type;
    int ack;
665
} MPIDI_CH3_Pkt_close_t;
666

667
typedef struct MPIDI_CH3_Pkt_revoke {
Wesley Bland's avatar
Wesley Bland committed
668 669
    MPIDI_CH3_Pkt_type_t type;
    MPIR_Context_id_t revoked_comm;
670
} MPIDI_CH3_Pkt_revoke_t;
Wesley Bland's avatar
Wesley Bland committed
671

672
typedef union MPIDI_CH3_Pkt {
673 674
    MPIDI_CH3_Pkt_type_t type;
    MPIDI_CH3_Pkt_eager_send_t eager_send;
675
#if defined(USE_EAGER_SHORT)
676
    MPIDI_CH3_Pkt_eagershort_send_t eagershort_send;
677
#endif                          /* defined(USE_EAGER_SHORT) */
678 679 680 681 682 683 684 685
    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;
686
    /* RMA packets start here */
687 688 689
    MPIDI_CH3_Pkt_put_t put;
    MPIDI_CH3_Pkt_get_t get;
    MPIDI_CH3_Pkt_accum_t accum;
Xin Zhao's avatar
Xin Zhao committed
690
    MPIDI_CH3_Pkt_get_accum_t get_accum;
691 692 693 694 695 696
    MPIDI_CH3_Pkt_fop_t fop;
    MPIDI_CH3_Pkt_cas_t cas;
    MPIDI_CH3_Pkt_get_resp_t get_resp;
    MPIDI_CH3_Pkt_get_accum_resp_t get_accum_resp;
    MPIDI_CH3_Pkt_fop_resp_t fop_resp;
    MPIDI_CH3_Pkt_cas_resp_t cas_resp;
697
    MPIDI_CH3_Pkt_lock_t lock;
698
    MPIDI_CH3_Pkt_unlock_t unlock;
699
    MPIDI_CH3_Pkt_flush_t flush;
700
    MPIDI_CH3_Pkt_decr_at_counter_t decr_at_cnt;
701
    MPIDI_CH3_Pkt_lock_ack_t lock_ack;
702 703
    MPIDI_CH3_Pkt_flush_ack_t flush_ack;
    /* RMA packets end here */
704
    MPIDI_CH3_Pkt_close_t close;
Wesley Bland's avatar
Wesley Bland committed
705
    MPIDI_CH3_Pkt_revoke_t revoke;
706
# if defined(MPIDI_CH3_PKT_DECL)
707
     MPIDI_CH3_PKT_DECL
708
# endif
709
} MPIDI_CH3_Pkt_t;
710 711

#if defined(MPID_USE_SEQUENCE_NUMBERS)
712
typedef struct MPIDI_CH3_Pkt_send_container {
713
    MPIDI_CH3_Pkt_send_t pkt;
714 715
    struct MPIDI_CH3_Pkt_send_container_s *next;
} MPIDI_CH3_Pkt_send_container_t;
716 717 718
#endif

#endif