This source file includes following definitions.
- hcoll_map_derived_type
- find_derived_mapping
- ompi_predefined_derived_2_hcoll
- ompi_dtype_2_hcoll_dtype
- ompi_op_2_hcolrte_op
- hcoll_type_attr_del_fn
- hcoll_type_attr_del_fn
1 #ifndef COLL_HCOLL_DTYPES_H
2 #define COLL_HCOLL_DTYPES_H
3
4
5
6
7
8 #include "ompi/datatype/ompi_datatype.h"
9 #include "ompi/datatype/ompi_datatype_internal.h"
10 #include "ompi/mca/op/op.h"
11 #include "hcoll/api/hcoll_dte.h"
12 extern int hcoll_type_attr_keyval;
13 extern mca_coll_hcoll_dtype_t zero_dte_mapping;
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 static dte_data_representation_t* ompi_datatype_2_dte_data_rep[OMPI_DATATYPE_MAX_PREDEFINED] = {
38 &DTE_ZERO,
39 &DTE_ZERO,
40 #if defined(DTE_LB)
41 &DTE_LB,
42 #else
43 &DTE_ZERO,
44 #endif
45 #if defined(DTE_UB)
46 &DTE_UB,
47 #else
48 &DTE_ZERO,
49 #endif
50 &DTE_BYTE,
51 &DTE_INT16,
52 &DTE_INT32,
53 &DTE_INT64,
54 &DTE_INT128,
55 &DTE_UBYTE,
56 &DTE_UINT16,
57 &DTE_UINT32,
58 &DTE_UINT64,
59 &DTE_UINT128,
60 #if defined(DTE_FLOAT16)
61 &DTE_FLOAT16,
62 #else
63 &DTE_ZERO,
64 #endif
65 &DTE_FLOAT32,
66 &DTE_FLOAT64,
67 &DTE_FLOAT96,
68 &DTE_FLOAT128,
69 &DTE_ZERO,
70 #if defined(DTE_FLOAT32_COMPLEX)
71 &DTE_FLOAT32_COMPLEX,
72 #else
73 &DTE_ZERO,
74 #endif
75 #if defined(DTE_FLOAT64_COMPLEX)
76 &DTE_FLOAT64_COMPLEX,
77 #else
78 &DTE_ZERO,
79 #endif
80 #if defined(DTE_FLOAT128_COMPLEX)
81 &DTE_FLOAT128_COMPLEX,
82 #else
83 &DTE_ZERO,
84 #endif
85 #if defined(DTE_BOOL)
86 &DTE_BOOL,
87 #else
88 &DTE_ZERO,
89 #endif
90 #if defined(DTE_WCHAR)
91 &DTE_WCHAR,
92 #else
93 &DTE_ZERO,
94 #endif
95 &DTE_ZERO
96 };
97
98 enum {
99 TRY_FIND_DERIVED,
100 NO_DERIVED
101 };
102
103
104 #if HCOLL_API >= HCOLL_VERSION(3,6)
105 static inline
106 void hcoll_map_derived_type(ompi_datatype_t *dtype, dte_data_representation_t *new_dte)
107 {
108 int rc;
109 if (NULL == dtype->args) {
110
111 return;
112 }
113 rc = hcoll_create_mpi_type((void*)dtype, new_dte);
114 if (rc != HCOLL_SUCCESS) {
115
116
117
118 ompi_attr_set_c(TYPE_ATTR, (void*)dtype, &(dtype->d_keyhash),
119 hcoll_type_attr_keyval, &zero_dte_mapping, false);
120 }
121 }
122
123 static dte_data_representation_t find_derived_mapping(ompi_datatype_t *dtype){
124 dte_data_representation_t dte = DTE_ZERO;
125 mca_coll_hcoll_dtype_t *hcoll_dtype;
126 if (mca_coll_hcoll_component.derived_types_support_enabled) {
127 int map_found = 0;
128 ompi_attr_get_c(dtype->d_keyhash, hcoll_type_attr_keyval,
129 (void**)&hcoll_dtype, &map_found);
130 if (!map_found)
131 hcoll_map_derived_type(dtype, &dte);
132 else
133 dte = hcoll_dtype->type;
134 }
135
136 return dte;
137 }
138
139
140
141 static inline dte_data_representation_t
142 ompi_predefined_derived_2_hcoll(int ompi_id) {
143 switch(ompi_id) {
144 case OMPI_DATATYPE_MPI_FLOAT_INT:
145 return DTE_FLOAT_INT;
146 case OMPI_DATATYPE_MPI_DOUBLE_INT:
147 return DTE_DOUBLE_INT;
148 case OMPI_DATATYPE_MPI_LONG_INT:
149 return DTE_LONG_INT;
150 case OMPI_DATATYPE_MPI_SHORT_INT:
151 return DTE_SHORT_INT;
152 case OMPI_DATATYPE_MPI_LONG_DOUBLE_INT:
153 return DTE_LONG_DOUBLE_INT;
154 case OMPI_DATATYPE_MPI_2INT:
155 return DTE_2INT;
156 #if HCOLL_API >= HCOLL_VERSION(3,7)
157 case OMPI_DATATYPE_MPI_2INTEGER:
158 #if OMPI_SIZEOF_FORTRAN_INTEGER == 4
159 return DTE_2INT;
160 #elif OMPI_SIZEOF_FORTRAN_INTEGER == 8
161 return DTE_2INT64;
162 #else
163 return DTE_ZERO;
164 #endif
165 case OMPI_DATATYPE_MPI_2REAL:
166 #if OMPI_SIZEOF_FORTRAN_REAL == 4
167 return DTE_2FLOAT32;
168 #elif OMPI_SIZEOF_FORTRAN_REAL == 8
169 return DTE_2FLOAT64;
170 #else
171 return DTE_ZERO;
172 #endif
173 case OMPI_DATATYPE_MPI_2DBLPREC:
174 #if OMPI_SIZEOF_FORTRAN_DOUBLE_PRECISION == 4
175 return DTE_2FLOAT32;
176 #elif OMPI_SIZEOF_FORTRAN_DOUBLE_PRECISION == 8
177 return DTE_2FLOAT64;
178 #else
179 return DTE_ZERO;
180 #endif
181 #endif
182 default:
183 break;
184 }
185 return DTE_ZERO;
186 }
187 #endif
188
189 static dte_data_representation_t
190 ompi_dtype_2_hcoll_dtype( ompi_datatype_t *dtype,
191 const int mode)
192 {
193 int ompi_type_id = dtype->id;
194 int opal_type_id = dtype->super.id;
195 dte_data_representation_t dte_data_rep = DTE_ZERO;
196
197 if (ompi_type_id < OMPI_DATATYPE_MPI_MAX_PREDEFINED &&
198 dtype->super.flags & OMPI_DATATYPE_FLAG_PREDEFINED) {
199 if (opal_type_id > 0 && opal_type_id < OPAL_DATATYPE_MAX_PREDEFINED) {
200 dte_data_rep = *ompi_datatype_2_dte_data_rep[opal_type_id];
201 }
202 #if HCOLL_API >= HCOLL_VERSION(3,6)
203 else if (TRY_FIND_DERIVED == mode){
204 dte_data_rep = ompi_predefined_derived_2_hcoll(ompi_type_id);
205 }
206 } else {
207 if (TRY_FIND_DERIVED == mode)
208 dte_data_rep = find_derived_mapping(dtype);
209 #endif
210 }
211 if (HCOL_DTE_IS_ZERO(dte_data_rep) && TRY_FIND_DERIVED == mode &&
212 !mca_coll_hcoll_component.hcoll_datatype_fallback) {
213 dte_data_rep = DTE_ZERO;
214 dte_data_rep.rep.in_line_rep.data_handle.in_line.in_line = 0;
215 dte_data_rep.rep.in_line_rep.data_handle.pointer_to_handle = (uint64_t ) &dtype->super;
216 }
217 return dte_data_rep;
218 }
219
220 static hcoll_dte_op_t* ompi_op_2_hcoll_op[OMPI_OP_BASE_FORTRAN_OP_MAX + 1] = {
221 &hcoll_dte_op_null,
222 &hcoll_dte_op_max,
223 &hcoll_dte_op_min,
224 &hcoll_dte_op_sum,
225 &hcoll_dte_op_prod,
226 &hcoll_dte_op_land,
227 &hcoll_dte_op_band,
228 &hcoll_dte_op_lor,
229 &hcoll_dte_op_bor,
230 &hcoll_dte_op_lxor,
231 &hcoll_dte_op_bxor,
232 &hcoll_dte_op_null,
233 &hcoll_dte_op_null,
234 &hcoll_dte_op_null,
235 &hcoll_dte_op_null,
236 &hcoll_dte_op_null
237 };
238 static hcoll_dte_op_t* ompi_op_2_hcolrte_op(ompi_op_t *op) {
239 if (op->o_f_to_c_index > OMPI_OP_BASE_FORTRAN_OP_MAX) {
240 return ompi_op_2_hcoll_op[0];
241 }
242 return ompi_op_2_hcoll_op[op->o_f_to_c_index];
243 }
244
245
246 #if HCOLL_API >= HCOLL_VERSION(3,6)
247 static int hcoll_type_attr_del_fn(MPI_Datatype type, int keyval, void *attr_val, void *extra) {
248 int ret = OMPI_SUCCESS;
249 mca_coll_hcoll_dtype_t *dtype =
250 (mca_coll_hcoll_dtype_t*) attr_val;
251
252 assert(dtype);
253 if (&zero_dte_mapping == dtype) {
254 return OMPI_SUCCESS;
255 }
256 if (HCOLL_SUCCESS != (ret = hcoll_dt_destroy(dtype->type))) {
257 HCOL_ERROR("failed to delete type attr: hcoll_dte_destroy returned %d",ret);
258 return OMPI_ERROR;
259 }
260 opal_free_list_return(&mca_coll_hcoll_component.dtypes,
261 &dtype->super);
262
263 return OMPI_SUCCESS;
264 }
265 #else
266 static int hcoll_type_attr_del_fn(MPI_Datatype type, int keyval, void *attr_val, void *extra) {
267
268 return OMPI_SUCCESS;
269 }
270 #endif
271 #endif