2626#include "ompi/mca/coll/han/coll_han_algorithms.h"
2727#include "ompi/mca/coll/base/coll_base_util.h"
2828
29+ #define MCA_COLL_HAN_ANY_MESSAGE_SIZE 0
30+
2931/*
3032 * Tests if a dynamic collective is implemented
3133 * Useful for file reading warnings and MCA parameter generation
@@ -41,6 +43,7 @@ bool mca_coll_han_is_coll_dynamic_implemented(COLLTYPE_T coll_id)
4143 case BARRIER :
4244 case BCAST :
4345 case GATHER :
46+ case GATHERV :
4447 case REDUCE :
4548 case SCATTER :
4649 return true;
@@ -1045,6 +1048,103 @@ mca_coll_han_gather_intra_dynamic(const void *sbuf, int scount,
10451048 sub_module );
10461049}
10471050
1051+ /*
1052+ * Gatherv selector:
1053+ * On a sub-communicator, checks the stored rules to find the module to use
1054+ * On the global communicator, calls the han collective implementation, or
1055+ * calls the correct module if fallback mechanism is activated
1056+ */
1057+ int mca_coll_han_gatherv_intra_dynamic (const void * sbuf , int scount , struct ompi_datatype_t * sdtype ,
1058+ void * rbuf , const int * rcounts , const int * displs ,
1059+ struct ompi_datatype_t * rdtype , int root ,
1060+ struct ompi_communicator_t * comm ,
1061+ mca_coll_base_module_t * module )
1062+ {
1063+ mca_coll_han_module_t * han_module = (mca_coll_han_module_t * ) module ;
1064+ TOPO_LVL_T topo_lvl = han_module -> topologic_level ;
1065+ mca_coll_base_module_gatherv_fn_t gatherv ;
1066+ mca_coll_base_module_t * sub_module ;
1067+ int rank , verbosity = 0 ;
1068+
1069+ if (!han_module -> enabled ) {
1070+ return han_module -> previous_gatherv (sbuf , scount , sdtype , rbuf , rcounts , displs , rdtype ,
1071+ root , comm , han_module -> previous_gatherv_module );
1072+ }
1073+
1074+ /* v collectives do not support message-size based dynamic rules */
1075+ sub_module = get_module (GATHERV , MCA_COLL_HAN_ANY_MESSAGE_SIZE , comm , han_module );
1076+
1077+ /* First errors are always printed by rank 0 */
1078+ rank = ompi_comm_rank (comm );
1079+ if ( (0 == rank ) && (han_module -> dynamic_errors < mca_coll_han_component .max_dynamic_errors ) ) {
1080+ verbosity = 30 ;
1081+ }
1082+
1083+ if (NULL == sub_module ) {
1084+ /*
1085+ * No valid collective module from dynamic rules
1086+ * nor from mca parameter
1087+ */
1088+ han_module -> dynamic_errors ++ ;
1089+ opal_output_verbose (verbosity , mca_coll_han_component .han_output ,
1090+ "coll:han:mca_coll_han_gatherv_intra_dynamic "
1091+ "HAN did not find any valid module for collective %d (%s) "
1092+ "with topological level %d (%s) on communicator (%s/%s). "
1093+ "Please check dynamic file/mca parameters\n" ,
1094+ GATHERV , mca_coll_base_colltype_to_str (GATHERV ),
1095+ topo_lvl , mca_coll_han_topo_lvl_to_str (topo_lvl ),
1096+ ompi_comm_print_cid (comm ), comm -> c_name );
1097+ OPAL_OUTPUT_VERBOSE ((30 , mca_coll_han_component .han_output ,
1098+ "HAN/GATHERV: No module found for the sub-communicator. "
1099+ "Falling back to another component\n" ));
1100+ gatherv = han_module -> previous_gatherv ;
1101+ sub_module = han_module -> previous_gatherv_module ;
1102+ } else if (NULL == sub_module -> coll_gatherv ) {
1103+ /*
1104+ * No valid collective from dynamic rules
1105+ * nor from mca parameter
1106+ */
1107+ han_module -> dynamic_errors ++ ;
1108+ opal_output_verbose (verbosity , mca_coll_han_component .han_output ,
1109+ "coll:han:mca_coll_han_gatherv_intra_dynamic "
1110+ "HAN found valid module for collective %d (%s) "
1111+ "with topological level %d (%s) on communicator (%s/%s) "
1112+ "but this module cannot handle this collective. "
1113+ "Please check dynamic file/mca parameters\n" ,
1114+ GATHERV , mca_coll_base_colltype_to_str (GATHERV ),
1115+ topo_lvl , mca_coll_han_topo_lvl_to_str (topo_lvl ),
1116+ ompi_comm_print_cid (comm ), comm -> c_name );
1117+ OPAL_OUTPUT_VERBOSE ((30 , mca_coll_han_component .han_output ,
1118+ "HAN/GATHERV: the module found for the sub-"
1119+ "communicator cannot handle the GATHERV operation. "
1120+ "Falling back to another component\n" ));
1121+ gatherv = han_module -> previous_gatherv ;
1122+ sub_module = han_module -> previous_gatherv_module ;
1123+ } else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module ) {
1124+ /*
1125+ * No fallback mechanism activated for this configuration
1126+ * sub_module is valid
1127+ * sub_module->coll_gatherv is valid and point to this function
1128+ * Call han topological collective algorithm
1129+ */
1130+ int algorithm_id = get_algorithm (GATHERV , MCA_COLL_HAN_ANY_MESSAGE_SIZE , comm , han_module );
1131+ gatherv = (mca_coll_base_module_gatherv_fn_t ) mca_coll_han_algorithm_id_to_fn (GATHERV , algorithm_id );
1132+ if (NULL == gatherv ) { /* default behaviour */
1133+ gatherv = mca_coll_han_gatherv_intra ;
1134+ }
1135+ } else {
1136+ /*
1137+ * If we get here:
1138+ * sub_module is valid
1139+ * sub_module->coll_gatherv is valid
1140+ * They points to the collective to use, according to the dynamic rules
1141+ * Selector's job is done, call the collective
1142+ */
1143+ gatherv = sub_module -> coll_gatherv ;
1144+ }
1145+ return gatherv (sbuf , scount , sdtype , rbuf , rcounts , displs , rdtype , root , comm , sub_module );
1146+ }
1147+
10481148
10491149/*
10501150 * Reduce selector:
0 commit comments