|
10 | 10 | #include "ompi/mca/op/op.h" |
11 | 11 | #include "hcoll/api/hcoll_dte.h" |
12 | 12 | extern int hcoll_type_attr_keyval; |
13 | | - |
| 13 | +extern mca_coll_hcoll_dtype_t zero_dte_mapping; |
14 | 14 | /*to keep this at hand: Ids of the basic opal_datatypes: |
15 | 15 | #define OPAL_DATATYPE_INT1 4 |
16 | 16 | #define OPAL_DATATYPE_INT2 5 |
@@ -97,15 +97,21 @@ enum { |
97 | 97 |
|
98 | 98 | #if HCOLL_API >= HCOLL_VERSION(3,6) |
99 | 99 | static inline |
100 | | -int hcoll_map_derived_type(ompi_datatype_t *dtype, dte_data_representation_t *new_dte) |
| 100 | +void hcoll_map_derived_type(ompi_datatype_t *dtype, dte_data_representation_t *new_dte) |
101 | 101 | { |
102 | 102 | int rc; |
103 | 103 | if (NULL == dtype->args) { |
104 | 104 | /* predefined type, shouldn't call this */ |
105 | | - return OMPI_SUCCESS; |
| 105 | + return; |
106 | 106 | } |
107 | 107 | rc = hcoll_create_mpi_type((void*)dtype, new_dte); |
108 | | - return rc == HCOLL_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR; |
| 108 | + if (rc != HCOLL_SUCCESS) { |
| 109 | + /* If hcoll fails to create mpi derived type let's set zero_dte on this dtype. |
| 110 | + This will save cycles on subsequent collective calls with the same derived |
| 111 | + type since we will not try to create hcoll type again. */ |
| 112 | + ompi_attr_set_c(TYPE_ATTR, (void*)dtype, &(dtype->d_keyhash), |
| 113 | + hcoll_type_attr_keyval, &zero_dte_mapping, false); |
| 114 | + } |
109 | 115 | } |
110 | 116 |
|
111 | 117 | static dte_data_representation_t find_derived_mapping(ompi_datatype_t *dtype){ |
@@ -238,6 +244,9 @@ static int hcoll_type_attr_del_fn(MPI_Datatype type, int keyval, void *attr_val, |
238 | 244 | (mca_coll_hcoll_dtype_t*) attr_val; |
239 | 245 |
|
240 | 246 | assert(dtype); |
| 247 | + if (&zero_dte_mapping == dtype) { |
| 248 | + return OMPI_SUCCESS; |
| 249 | + } |
241 | 250 | if (HCOLL_SUCCESS != (ret = hcoll_dt_destroy(dtype->type))) { |
242 | 251 | HCOL_ERROR("failed to delete type attr: hcoll_dte_destroy returned %d",ret); |
243 | 252 | return OMPI_ERROR; |
|
0 commit comments