1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #ifndef CH4I_WORKQ_TYPES_H_INCLUDED
7 #define CH4I_WORKQ_TYPES_H_INCLUDED
8
9 /*
10 Multi-threading models
11 */
12 enum {
13 MPIDI_CH4_MT_DIRECT,
14 MPIDI_CH4_MT_HANDOFF,
15
16 MPIDI_CH4_NUM_MT_MODELS,
17 };
18
19 /* For now any thread safety model that is not "direct" requires
20 * work queues. These queues might be used for different reasons,
21 * thus a new macro to capture that. */
22 #if !defined(MPIDI_CH4_USE_MT_DIRECT)
23 #define MPIDI_CH4_USE_WORK_QUEUES
24 #endif
25
26 /* Define the work queue implementation type */
27 #if defined(ENABLE_IZEM_QUEUE)
28 #include <queue/zm_queue.h>
29 #define MPIDI_workq_t zm_queue_t
30 #define MPIDI_workq_init zm_queue_init
31 #define MPIDI_workq_enqueue zm_queue_enqueue
32 #define MPIDI_workq_dequeue zm_queue_dequeue
33 #else
34 /* Stub implementation to make it compile */
35 typedef void *MPIDI_workq_t;
MPIDI_workq_init(MPIDI_workq_t * q)36 MPL_STATIC_INLINE_PREFIX void MPIDI_workq_init(MPIDI_workq_t * q)
37 {
38 #ifdef MPIDI_CH4_USE_WORK_QUEUES
39 MPIR_Assert(0);
40 #endif
41 }
42
MPIDI_workq_enqueue(MPIDI_workq_t * q,void * p)43 MPL_STATIC_INLINE_PREFIX void MPIDI_workq_enqueue(MPIDI_workq_t * q, void *p)
44 {
45 #ifdef MPIDI_CH4_USE_WORK_QUEUES
46 MPIR_Assert(0);
47 #endif
48 }
49
MPIDI_workq_dequeue(MPIDI_workq_t * q,void ** pp)50 MPL_STATIC_INLINE_PREFIX void MPIDI_workq_dequeue(MPIDI_workq_t * q, void **pp)
51 {
52 #ifdef MPIDI_CH4_USE_WORK_QUEUES
53 MPIR_Assert(0);
54 #endif
55 }
56 #endif
57
58 #define MPIDI_WORKQ_ELEMT_PREALLOC 64 /* Number of elements to preallocate in the "direct" block */
59
60 typedef enum MPIDI_workq_op MPIDI_workq_op_t;
61
62 /* Indentifies the delegated operation */
63 enum MPIDI_workq_op { SEND, ISEND, SSEND, ISSEND, RSEND, IRSEND, RECV, IRECV, IMRECV, IPROBE,
64 IMPROBE, CSEND, ICSEND, PUT, GET, ACC, CAS, FAO, GACC
65 };
66
67 struct MPIDI_av_entry;
68
69 /* Structure to encapsulate MPI operations that are delegated to another thread
70 * Can be allocated from an MPI object pool or embedded in another object (e.g. request) */
71 typedef struct MPIDI_workq_elemt {
72 MPIR_OBJECT_HEADER; /* adds handle and ref_count fields */
73 MPIDI_workq_op_t op;
74 MPL_atomic_int_t *processed; /* set to true by the progress thread when
75 * this work item is done */
76 union {
77 union {
78 struct MPIDI_workq_send {
79 const void *send_buf;
80 MPI_Aint count;
81 MPI_Datatype datatype;
82 int rank;
83 int tag;
84 MPIR_Comm *comm_ptr;
85 int context_offset;
86 struct MPIDI_av_entry *addr;
87 MPIR_Request *request;
88 } send; /* also for ISEND SSEND ISSEND RSEND IRSEND */
89 struct MPIDI_workq_csend {
90 const void *send_buf;
91 MPI_Aint count;
92 MPI_Datatype datatype;
93 int rank;
94 int tag;
95 MPIR_Comm *comm_ptr;
96 int context_offset;
97 struct MPIDI_av_entry *addr;
98 MPIR_Request *request;
99 MPIR_Errflag_t errflag;
100 } csend; /* also for ICSEND */
101 struct MPIDI_workq_recv {
102 void *recv_buf;
103 MPI_Aint count;
104 MPI_Datatype datatype;
105 int rank;
106 int tag;
107 MPIR_Comm *comm_ptr;
108 int context_offset;
109 struct MPIDI_av_entry *addr;
110 MPI_Status *status;
111 MPIR_Request *request;
112 } recv;
113 struct MPIDI_workq_irecv {
114 void *recv_buf;
115 MPI_Aint count;
116 MPI_Datatype datatype;
117 int rank;
118 int tag;
119 MPIR_Comm *comm_ptr;
120 int context_offset;
121 struct MPIDI_av_entry *addr;
122 MPIR_Request *request;
123 } irecv;
124 struct MPIDI_workq_iprobe {
125 int rank;
126 int tag;
127 MPIR_Comm *comm_ptr;
128 int context_offset;
129 struct MPIDI_av_entry *addr;
130 MPI_Status *status;
131 MPIR_Request *request;
132 int *flag;
133 } iprobe;
134 struct MPIDI_workq_improbe {
135 int rank;
136 int tag;
137 MPIR_Comm *comm_ptr;
138 int context_offset;
139 struct MPIDI_av_entry *addr;
140 MPI_Status *status;
141 MPIR_Request *request;
142 int *flag;
143 MPIR_Request **message;
144 } improbe;
145 struct MPIDI_workq_imrecv {
146 void *buf;
147 MPI_Aint count;
148 MPI_Datatype datatype;
149 MPIR_Request **message;
150 MPIR_Request *request;
151 } imrecv;
152 } pt2pt;
153 union {
154 struct MPIDI_workq_put {
155 const void *origin_addr;
156 int origin_count;
157 MPI_Datatype origin_datatype;
158 int target_rank;
159 MPI_Aint target_disp;
160 int target_count;
161 MPI_Datatype target_datatype;
162 MPIR_Win *win_ptr;
163 } put;
164 struct MPIDI_workq_get {
165 void *origin_addr;
166 int origin_count;
167 MPI_Datatype origin_datatype;
168 int target_rank;
169 MPI_Aint target_disp;
170 int target_count;
171 MPI_Datatype target_datatype;
172 MPIR_Win *win_ptr;
173 } get;
174 } rma;
175 } params;
176 } MPIDI_workq_elemt_t;
177
178 #endif /* CH4I_WORKQ_TYPES_H_INCLUDED */
179