1010#include "ompi/mca/op/op.h"
1111#include "hcoll/api/hcoll_dte.h"
1212extern int hcoll_type_attr_keyval ;
13-
13+ extern mca_coll_hcoll_dtype_t zero_dte_mapping ;
1414/*to keep this at hand: Ids of the basic opal_datatypes:
1515#define OPAL_DATATYPE_INT1 4
1616#define OPAL_DATATYPE_INT2 5
@@ -36,8 +36,16 @@ total 15 types
3636static dte_data_representation_t * ompi_datatype_2_dte_data_rep [OMPI_DATATYPE_MAX_PREDEFINED ] = {
3737 & DTE_ZERO , /*OPAL_DATATYPE_LOOP 0 */
3838 & DTE_ZERO , /*OPAL_DATATYPE_END_LOOP 1 */
39- & DTE_ZERO , /*OPAL_DATATYPE_LB 2 */
40- & DTE_ZERO , /*OPAL_DATATYPE_UB 3 */
39+ #if defined(DTE_LB )
40+ & DTE_LB , /*OPAL_DATATYPE_LB 2 */
41+ #else
42+ & DTE_ZERO ,
43+ #endif
44+ #if defined(DTE_UB )
45+ & DTE_UB , /*OPAL_DATATYPE_UB 3 */
46+ #else
47+ & DTE_ZERO ,
48+ #endif
4149 & DTE_BYTE , /*OPAL_DATATYPE_INT1 4 */
4250 & DTE_INT16 , /*OPAL_DATATYPE_INT2 5 */
4351 & DTE_INT32 , /*OPAL_DATATYPE_INT4 6 */
@@ -68,8 +76,16 @@ static dte_data_representation_t* ompi_datatype_2_dte_data_rep[OMPI_DATATYPE_MAX
6876#else
6977 & DTE_ZERO ,
7078#endif
71- & DTE_ZERO , /*OPAL_DATATYPE_BOOL 22 */
72- & DTE_ZERO , /*OPAL_DATATYPE_WCHAR 23 */
79+ #if defined(DTE_BOOL )
80+ & DTE_BOOL , /*OPAL_DATATYPE_BOOL 22 */
81+ #else
82+ & DTE_ZERO ,
83+ #endif
84+ #if defined(DTE_WCHAR )
85+ & DTE_WCHAR , /*OPAL_DATATYPE_WCHAR 23 */
86+ #else
87+ & DTE_ZERO ,
88+ #endif
7389 & DTE_ZERO /*OPAL_DATATYPE_UNAVAILABLE 24 */
7490};
7591
@@ -81,15 +97,21 @@ enum {
8197
8298#if HCOLL_API >= HCOLL_VERSION (3 ,6 )
8399static inline
84- 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 )
85101{
86102 int rc ;
87103 if (NULL == dtype -> args ) {
88104 /* predefined type, shouldn't call this */
89- return OMPI_SUCCESS ;
105+ return ;
90106 }
91107 rc = hcoll_create_mpi_type ((void * )dtype , new_dte );
92- 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+ }
93115}
94116
95117static dte_data_representation_t find_derived_mapping (ompi_datatype_t * dtype ){
@@ -222,6 +244,9 @@ static int hcoll_type_attr_del_fn(MPI_Datatype type, int keyval, void *attr_val,
222244 (mca_coll_hcoll_dtype_t * ) attr_val ;
223245
224246 assert (dtype );
247+ if (& zero_dte_mapping == dtype ) {
248+ return OMPI_SUCCESS ;
249+ }
225250 if (HCOLL_SUCCESS != (ret = hcoll_dt_destroy (dtype -> type ))) {
226251 HCOL_ERROR ("failed to delete type attr: hcoll_dte_destroy returned %d" ,ret );
227252 return OMPI_ERROR ;
0 commit comments