@@ -46,6 +46,7 @@ bool mca_coll_han_is_coll_dynamic_implemented(COLLTYPE_T coll_id)
4646 case GATHERV :
4747 case REDUCE :
4848 case SCATTER :
49+ case SCATTERV :
4950 return true;
5051 default :
5152 return false;
@@ -1397,3 +1398,113 @@ mca_coll_han_scatter_intra_dynamic(const void *sbuf, int scount,
13971398 root , comm ,
13981399 sub_module );
13991400}
1401+
1402+
1403+ /*
1404+ * Scatterv selector:
1405+ * On a sub-communicator, checks the stored rules to find the module to use
1406+ * On the global communicator, calls the han collective implementation, or
1407+ * calls the correct module if fallback mechanism is activated
1408+ */
1409+ int
1410+ mca_coll_han_scatterv_intra_dynamic (const void * sbuf , const int * scounts ,
1411+ const int * displs , struct ompi_datatype_t * sdtype ,
1412+ void * rbuf , int rcount ,
1413+ struct ompi_datatype_t * rdtype ,
1414+ int root ,
1415+ struct ompi_communicator_t * comm ,
1416+ mca_coll_base_module_t * module )
1417+ {
1418+ mca_coll_han_module_t * han_module = (mca_coll_han_module_t * ) module ;
1419+ TOPO_LVL_T topo_lvl = han_module -> topologic_level ;
1420+ mca_coll_base_module_scatterv_fn_t scatterv ;
1421+ mca_coll_base_module_t * sub_module ;
1422+ int rank , verbosity = 0 ;
1423+
1424+ if (!han_module -> enabled ) {
1425+ return han_module -> previous_scatterv (sbuf , scounts , displs , sdtype , rbuf , rcount , rdtype ,
1426+ root , comm , han_module -> previous_scatterv_module );
1427+ }
1428+
1429+ /* v collectives do not support message-size based dynamic rules */
1430+ sub_module = get_module (SCATTERV ,
1431+ MCA_COLL_HAN_ANY_MESSAGE_SIZE ,
1432+ comm ,
1433+ han_module );
1434+
1435+ /* First errors are always printed by rank 0 */
1436+ rank = ompi_comm_rank (comm );
1437+ if ( (0 == rank ) && (han_module -> dynamic_errors < mca_coll_han_component .max_dynamic_errors ) ) {
1438+ verbosity = 30 ;
1439+ }
1440+
1441+ if (NULL == sub_module ) {
1442+ /*
1443+ * No valid collective module from dynamic rules
1444+ * nor from mca parameter
1445+ */
1446+ han_module -> dynamic_errors ++ ;
1447+ opal_output_verbose (verbosity , mca_coll_han_component .han_output ,
1448+ "coll:han:mca_coll_han_scatterv_intra_dynamic "
1449+ "HAN did not find any valid module for collective %d (%s) "
1450+ "with topological level %d (%s) on communicator (%s/%s). "
1451+ "Please check dynamic file/mca parameters\n" ,
1452+ SCATTERV , mca_coll_base_colltype_to_str (SCATTERV ),
1453+ topo_lvl , mca_coll_han_topo_lvl_to_str (topo_lvl ),
1454+ ompi_comm_print_cid (comm ), comm -> c_name );
1455+ OPAL_OUTPUT_VERBOSE ((30 , mca_coll_han_component .han_output ,
1456+ "HAN/SCATTERV: No module found for the sub-communicator. "
1457+ "Falling back to another component\n" ));
1458+ scatterv = han_module -> previous_scatterv ;
1459+ sub_module = han_module -> previous_scatterv_module ;
1460+ } else if (NULL == sub_module -> coll_scatterv ) {
1461+ /*
1462+ * No valid collective from dynamic rules
1463+ * nor from mca parameter
1464+ */
1465+ han_module -> dynamic_errors ++ ;
1466+ opal_output_verbose (verbosity , mca_coll_han_component .han_output ,
1467+ "coll:han:mca_coll_han_scatterv_intra_dynamic "
1468+ "HAN found valid module for collective %d (%s) "
1469+ "with topological level %d (%s) on communicator (%s/%s) "
1470+ "but this module cannot handle this collective. "
1471+ "Please check dynamic file/mca parameters\n" ,
1472+ SCATTERV , mca_coll_base_colltype_to_str (SCATTERV ),
1473+ topo_lvl , mca_coll_han_topo_lvl_to_str (topo_lvl ),
1474+ ompi_comm_print_cid (comm ), comm -> c_name );
1475+ OPAL_OUTPUT_VERBOSE ((30 , mca_coll_han_component .han_output ,
1476+ "HAN/SCATTERV: the module found for the sub-"
1477+ "communicator cannot handle the SCATTERV operation. "
1478+ "Falling back to another component\n" ));
1479+ scatterv = han_module -> previous_scatterv ;
1480+ sub_module = han_module -> previous_scatterv_module ;
1481+ } else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module ) {
1482+ /*
1483+ * No fallback mechanism activated for this configuration
1484+ * sub_module is valid
1485+ * sub_module->coll_scatterv is valid and point to this function
1486+ * Call han topological collective algorithm
1487+ */
1488+ int algorithm_id = get_algorithm (SCATTERV ,
1489+ MCA_COLL_HAN_ANY_MESSAGE_SIZE ,
1490+ comm ,
1491+ han_module );
1492+ scatterv = (mca_coll_base_module_scatterv_fn_t )mca_coll_han_algorithm_id_to_fn (SCATTERV , algorithm_id );
1493+ if (NULL == scatterv ) { /* default behaviour */
1494+ scatterv = mca_coll_han_scatterv_intra ;
1495+ }
1496+ } else {
1497+ /*
1498+ * If we get here:
1499+ * sub_module is valid
1500+ * sub_module->coll_scatterv is valid
1501+ * They point to the collective to use, according to the dynamic rules
1502+ * Selector's job is done, call the collective
1503+ */
1504+ scatterv = sub_module -> coll_scatterv ;
1505+ }
1506+
1507+ return scatterv (sbuf , scounts , displs , sdtype ,
1508+ rbuf , rcount , rdtype ,
1509+ root , comm , sub_module );
1510+ }
0 commit comments