1 /*
2  * Copyright (C) by Argonne National Laboratory
3  *     See COPYRIGHT in top-level directory
4  */
5 
6 #ifndef MPID_RMA_TYPES_H_INCLUDED
7 #define MPID_RMA_TYPES_H_INCLUDED
8 
9 #include "mpidi_ch3_impl.h"
10 
11 /* Special case RMA operations */
12 
13 enum MPIDI_RMA_Datatype {
14     MPIDI_RMA_DATATYPE_BASIC = 50,
15     MPIDI_RMA_DATATYPE_DERIVED = 51
16 };
17 
18 #define MPID_LOCK_NONE 60
19 
20 /*
21  * RMA Declarations.  We should move these into something separate from
22  * a Request.
23  */
24 
25 typedef enum MPIDI_RMA_Pool_type {
26     MPIDI_RMA_POOL_WIN = 6,
27     MPIDI_RMA_POOL_GLOBAL = 7
28 } MPIDI_RMA_Pool_type_t;
29 
30 typedef enum MPIDI_RMA_Acc_srcbuf_kind {
31     MPIDI_RMA_ACC_SRCBUF_DEFAULT,
32     MPIDI_RMA_ACC_SRCBUF_PACKED
33 } MPIDI_RMA_Acc_srcbuf_kind_t;
34 
35 /* for keeping track of RMA ops, which will be executed at the next sync call */
36 typedef struct MPIDI_RMA_Op {
37     struct MPIDI_RMA_Op *next;  /* pointer to next element in list */
38     struct MPIDI_RMA_Op *prev;  /* pointer to prev element in list */
39 
40     void *origin_addr;
41     int origin_count;
42     MPI_Datatype origin_datatype;
43 
44     void *compare_addr;
45     MPI_Datatype compare_datatype;
46 
47     void *result_addr;
48     int result_count;
49     MPI_Datatype result_datatype;
50 
51     struct MPIR_Request *single_req;    /* used for unstreamed RMA ops */
52     struct MPIR_Request **multi_reqs;   /* used for streamed RMA ops */
53     MPI_Aint reqs_size;         /* when reqs_size == 0, neither single_req nor multi_reqs is used;
54                                  * when reqs_size == 1, single_req is used;
55                                  * when reqs_size > 1, multi_reqs is used. */
56 
57     int target_rank;
58 
59     MPIDI_CH3_Pkt_t pkt;
60     MPIDI_RMA_Pool_type_t pool_type;
61     int piggyback_lock_candidate;
62 
63     int issued_stream_count;    /* when >= 0, it specifies number of stream units that have been issued;
64                                  * when < 0, it means all stream units of this operation haven been issued. */
65 
66     MPIR_Request *ureq;
67 
68 } MPIDI_RMA_Op_t;
69 
70 typedef struct MPIDI_RMA_Target {
71     struct MPIDI_RMA_Op *pending_net_ops_list_head;     /* pending operations that are waiting for network events */
72     struct MPIDI_RMA_Op *pending_user_ops_list_head;    /* pending operations that are waiting for user events */
73     struct MPIDI_RMA_Op *next_op_to_issue;
74     struct MPIDI_RMA_Target *next;
75     struct MPIDI_RMA_Target *prev;
76     int target_rank;
77     enum MPIDI_RMA_states access_state;
78     int lock_type;              /* NONE, SHARED, EXCLUSIVE */
79     int lock_mode;              /* e.g., MODE_NO_CHECK */
80     int win_complete_flag;
81 
82     /* The target structure is free to be cleaned up when all of the
83      * following conditions hold true:
84      *   - No operations are queued up (op_list == NULL)
85      *   - There are no outstanding acks (outstanding_acks == 0)
86      *   - There are no sync messages to be sent (sync_flag == NONE)
87      */
88     struct {
89         /* next synchronization flag to be sent to the target (either
90          * piggybacked or as a separate packet */
91         enum MPIDI_RMA_sync_types sync_flag;    /* UNLOCK, FLUSH or FLUSH_LOCAL */
92 
93         /* packets sent out that we are expecting an ack for */
94         int outstanding_acks;
95 
96     } sync;
97 
98     /* number of packets that are waiting for local completion */
99     int num_pkts_wait_for_local_completion;
100 
101     /* number of operations that does not have a FLUSH issued afterwards */
102     int num_ops_flush_not_issued;
103 
104     MPIDI_RMA_Pool_type_t pool_type;
105 } MPIDI_RMA_Target_t;
106 
107 typedef struct MPIDI_RMA_Slot {
108     struct MPIDI_RMA_Target *target_list_head;
109 } MPIDI_RMA_Slot_t;
110 
111 typedef struct MPIDI_RMA_Target_lock_entry {
112     struct MPIDI_RMA_Target_lock_entry *next;
113     struct MPIDI_RMA_Target_lock_entry *prev;
114     MPIDI_CH3_Pkt_t pkt;        /* all information for this request packet */
115     MPIDI_VC_t *vc;
116     void *data;                 /* for queued PUTs / ACCs / GACCs, data is copied here */
117     int buf_size;
118     int all_data_recved;        /* indicate if all data has been received */
119 } MPIDI_RMA_Target_lock_entry_t;
120 
121 typedef MPIDI_RMA_Op_t *MPIDI_RMA_Ops_list_t;
122 
123 #endif /* MPID_RMA_TYPES_H_INCLUDED */
124