@@ -692,7 +692,7 @@ ompi_comm_split_type(ompi_communicator_t *comm,
692692 int my_rsize ;
693693 int mode ;
694694 int rsize ;
695- int i , loc ;
695+ int i , loc , found ;
696696 int inter ;
697697 int * results = NULL , * sorted = NULL ;
698698 int * rresults = NULL , * rsorted = NULL ;
@@ -711,7 +711,51 @@ ompi_comm_split_type(ompi_communicator_t *comm,
711711 /* --------------------------------------------------------- */
712712
713713 /* sort according to participation and rank. Gather information from everyone */
714- myinfo [0 ] = (split_type == MPI_COMM_TYPE_SHARED ) ? 1 : 0 ;
714+ /* allowed splitting types:
715+ CLUSTER
716+ CU
717+ HOST
718+ BOARD
719+ NODE
720+ NUMA
721+ SOCKET
722+ L3CACHE
723+ L2CACHE
724+ L1CACHE
725+ CORE
726+ HWTHREAD
727+ Even though HWTHREAD/CORE etc. is overkill they are here for consistency.
728+ They will most likely return a communicator which is equal to MPI_COMM_SELF
729+ Unless oversubscribing.
730+ */
731+ myinfo [0 ] = 0 ; // default to no type splitting (also if non-recognized split-type)
732+ switch ( split_type ) {
733+ case OMPI_COMM_TYPE_HWTHREAD :
734+ myinfo [0 ] = 1 ; break ;
735+ case OMPI_COMM_TYPE_CORE :
736+ myinfo [0 ] = 2 ; break ;
737+ case OMPI_COMM_TYPE_L1CACHE :
738+ myinfo [0 ] = 3 ; break ;
739+ case OMPI_COMM_TYPE_L2CACHE :
740+ myinfo [0 ] = 4 ; break ;
741+ case OMPI_COMM_TYPE_L3CACHE :
742+ myinfo [0 ] = 5 ; break ;
743+ case OMPI_COMM_TYPE_SOCKET :
744+ myinfo [0 ] = 6 ; break ;
745+ case OMPI_COMM_TYPE_NUMA :
746+ myinfo [0 ] = 7 ; break ;
747+ //case MPI_COMM_TYPE_SHARED: // the standard implemented type
748+ case OMPI_COMM_TYPE_NODE :
749+ myinfo [0 ] = 8 ; break ;
750+ case OMPI_COMM_TYPE_BOARD :
751+ myinfo [0 ] = 9 ; break ;
752+ case OMPI_COMM_TYPE_HOST :
753+ myinfo [0 ] = 10 ; break ;
754+ case OMPI_COMM_TYPE_CU :
755+ myinfo [0 ] = 11 ; break ;
756+ case OMPI_COMM_TYPE_CLUSTER :
757+ myinfo [0 ] = 12 ; break ;
758+ }
715759 myinfo [1 ] = key ;
716760
717761 size = ompi_comm_size ( comm );
@@ -731,13 +775,65 @@ ompi_comm_split_type(ompi_communicator_t *comm,
731775 if ( OMPI_SUCCESS != rc ) {
732776 goto exit ;
733777 }
734-
778+
779+ /* check that all processors have been called with the same value */
780+ for ( i = 0 ; i < size ; i ++ ) {
781+ if ( results [2 * i ] != myinfo [0 ] ) {
782+ rc = OMPI_ERR_BAD_PARAM ;
783+ goto exit ;
784+ }
785+ }
786+
735787 /* how many are participating and on my node? */
736788 for ( my_size = 0 , i = 0 ; i < size ; i ++ ) {
737- if ( results [(2 * i )+ 0 ] == 1 ) {
789+ if ( results [2 * i ] == 1 ) {
790+ if (OPAL_PROC_ON_LOCAL_HWTHREAD (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
791+ my_size ++ ;
792+ }
793+ } else if ( results [2 * i ] == 2 ) {
794+ if (OPAL_PROC_ON_LOCAL_CORE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
795+ my_size ++ ;
796+ }
797+ } else if ( results [2 * i ] == 3 ) {
798+ if (OPAL_PROC_ON_LOCAL_L1CACHE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
799+ my_size ++ ;
800+ }
801+ } else if ( results [2 * i ] == 4 ) {
802+ if (OPAL_PROC_ON_LOCAL_L2CACHE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
803+ my_size ++ ;
804+ }
805+ } else if ( results [2 * i ] == 5 ) {
806+ if (OPAL_PROC_ON_LOCAL_L3CACHE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
807+ my_size ++ ;
808+ }
809+ } else if ( results [2 * i ] == 6 ) {
810+ if (OPAL_PROC_ON_LOCAL_SOCKET (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
811+ my_size ++ ;
812+ }
813+ } else if ( results [2 * i ] == 7 ) {
814+ if (OPAL_PROC_ON_LOCAL_NUMA (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
815+ my_size ++ ;
816+ }
817+ } else if ( results [2 * i ] == 8 ) {
738818 if (OPAL_PROC_ON_LOCAL_NODE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
739819 my_size ++ ;
740820 }
821+ } else if ( results [2 * i ] == 9 ) {
822+ if (OPAL_PROC_ON_LOCAL_BOARD (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
823+ my_size ++ ;
824+ }
825+ } else if ( results [2 * i ] == 10 ) {
826+ if (OPAL_PROC_ON_LOCAL_HOST (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
827+ my_size ++ ;
828+ }
829+ } else if ( results [2 * i ] == 11 ) {
830+ if (OPAL_PROC_ON_LOCAL_CU (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
831+ my_size ++ ;
832+ }
833+ } else if ( results [2 * i ] == 12 ) {
834+ if (OPAL_PROC_ON_LOCAL_CLUSTER (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
835+ my_size ++ ;
836+ }
741837 }
742838 }
743839
@@ -755,13 +851,63 @@ ompi_comm_split_type(ompi_communicator_t *comm,
755851
756852 /* ok we can now fill this info */
757853 for ( loc = 0 , i = 0 ; i < size ; i ++ ) {
758- if ( results [(2 * i )+ 0 ] == 1 ) {
854+ found = 0 ;
855+ if ( results [2 * i ] == 1 ) {
856+ if (OPAL_PROC_ON_LOCAL_HWTHREAD (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
857+ found = 1 ;
858+ }
859+ } else if ( results [2 * i ] == 2 ) {
860+ if (OPAL_PROC_ON_LOCAL_CORE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
861+ found = 1 ;
862+ }
863+ } else if ( results [2 * i ] == 3 ) {
864+ if (OPAL_PROC_ON_LOCAL_L1CACHE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
865+ found = 1 ;
866+ }
867+ } else if ( results [2 * i ] == 4 ) {
868+ if (OPAL_PROC_ON_LOCAL_L2CACHE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
869+ found = 1 ;
870+ }
871+ } else if ( results [2 * i ] == 5 ) {
872+ if (OPAL_PROC_ON_LOCAL_L3CACHE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
873+ found = 1 ;
874+ }
875+ } else if ( results [2 * i ] == 6 ) {
876+ if (OPAL_PROC_ON_LOCAL_SOCKET (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
877+ found = 1 ;
878+ }
879+ } else if ( results [2 * i ] == 7 ) {
880+ if (OPAL_PROC_ON_LOCAL_NUMA (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
881+ found = 1 ;
882+ }
883+ } else if ( results [2 * i ] == 8 ) {
759884 if (OPAL_PROC_ON_LOCAL_NODE (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
760- sorted [(2 * loc )+ 0 ] = i ; /* copy org rank */
761- sorted [(2 * loc )+ 1 ] = results [(2 * i )+ 1 ]; /* copy key */
762- loc ++ ;
885+ found = 1 ;
886+ }
887+ } else if ( results [2 * i ] == 9 ) {
888+ if (OPAL_PROC_ON_LOCAL_BOARD (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
889+ found = 1 ;
890+ }
891+ } else if ( results [2 * i ] == 10 ) {
892+ if (OPAL_PROC_ON_LOCAL_HOST (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
893+ found = 1 ;
894+ }
895+ } else if ( results [2 * i ] == 11 ) {
896+ if (OPAL_PROC_ON_LOCAL_CU (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
897+ found = 1 ;
898+ }
899+ } else if ( results [2 * i ] == 12 ) {
900+ if (OPAL_PROC_ON_LOCAL_CLUSTER (ompi_group_peer_lookup (comm -> c_local_group , i )-> super .proc_flags )) {
901+ found = 1 ;
763902 }
764903 }
904+
905+ /* we have found and occupied the index (i) */
906+ if ( found == 1 ) {
907+ sorted [2 * loc ] = i ; /* copy org rank */
908+ sorted [2 * loc + 1 ] = results [2 * i + 1 ]; /* copy key */
909+ loc ++ ;
910+ }
765911 }
766912
767913 /* the new array needs to be sorted so that it is in 'key' order */
@@ -800,10 +946,54 @@ ompi_comm_split_type(ompi_communicator_t *comm,
800946
801947 /* how many are participating and on my node? */
802948 for ( my_rsize = 0 , i = 0 ; i < rsize ; i ++ ) {
803- if ( rresults [(2 * i )+ 0 ] == 1 ) {
949+ if ( rresults [2 * i ] == 1 ) {
950+ if (OPAL_PROC_ON_LOCAL_HWTHREAD (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
951+ my_rsize ++ ;
952+ }
953+ } else if ( rresults [2 * i ] == 2 ) {
954+ if (OPAL_PROC_ON_LOCAL_CORE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
955+ my_rsize ++ ;
956+ }
957+ } else if ( rresults [2 * i ] == 3 ) {
958+ if (OPAL_PROC_ON_LOCAL_L1CACHE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
959+ my_rsize ++ ;
960+ }
961+ } else if ( rresults [2 * i ] == 4 ) {
962+ if (OPAL_PROC_ON_LOCAL_L2CACHE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
963+ my_rsize ++ ;
964+ }
965+ } else if ( rresults [2 * i ] == 5 ) {
966+ if (OPAL_PROC_ON_LOCAL_L3CACHE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
967+ my_rsize ++ ;
968+ }
969+ } else if ( rresults [2 * i ] == 6 ) {
970+ if (OPAL_PROC_ON_LOCAL_SOCKET (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
971+ my_rsize ++ ;
972+ }
973+ } else if ( rresults [2 * i ] == 7 ) {
974+ if (OPAL_PROC_ON_LOCAL_NUMA (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
975+ my_rsize ++ ;
976+ }
977+ } else if ( rresults [2 * i ] == 8 ) {
804978 if (OPAL_PROC_ON_LOCAL_NODE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
805979 my_rsize ++ ;
806980 }
981+ } else if ( rresults [2 * i ] == 9 ) {
982+ if (OPAL_PROC_ON_LOCAL_BOARD (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
983+ my_rsize ++ ;
984+ }
985+ } else if ( rresults [2 * i ] == 10 ) {
986+ if (OPAL_PROC_ON_LOCAL_HOST (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
987+ my_rsize ++ ;
988+ }
989+ } else if ( rresults [2 * i ] == 11 ) {
990+ if (OPAL_PROC_ON_LOCAL_CU (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
991+ my_rsize ++ ;
992+ }
993+ } else if ( rresults [2 * i ] == 12 ) {
994+ if (OPAL_PROC_ON_LOCAL_CLUSTER (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
995+ my_rsize ++ ;
996+ }
807997 }
808998 }
809999
@@ -816,12 +1006,61 @@ ompi_comm_split_type(ompi_communicator_t *comm,
8161006
8171007 /* ok we can now fill this info */
8181008 for ( loc = 0 , i = 0 ; i < rsize ; i ++ ) {
819- if ( rresults [(2 * i )+ 0 ] == 1 ) {
1009+ found = 0 ;
1010+ if ( rresults [2 * i ] == 1 ) {
1011+ if (OPAL_PROC_ON_LOCAL_HWTHREAD (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1012+ found = 1 ;
1013+ }
1014+ } else if ( rresults [2 * i ] == 2 ) {
1015+ if (OPAL_PROC_ON_LOCAL_CORE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1016+ found = 1 ;
1017+ }
1018+ } else if ( rresults [2 * i ] == 3 ) {
1019+ if (OPAL_PROC_ON_LOCAL_L1CACHE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1020+ found = 1 ;
1021+ }
1022+ } else if ( rresults [2 * i ] == 4 ) {
1023+ if (OPAL_PROC_ON_LOCAL_L2CACHE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1024+ found = 1 ;
1025+ }
1026+ } else if ( rresults [2 * i ] == 5 ) {
1027+ if (OPAL_PROC_ON_LOCAL_L3CACHE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1028+ found = 1 ;
1029+ }
1030+ } else if ( rresults [2 * i ] == 6 ) {
1031+ if (OPAL_PROC_ON_LOCAL_SOCKET (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1032+ found = 1 ;
1033+ }
1034+ } else if ( rresults [2 * i ] == 7 ) {
1035+ if (OPAL_PROC_ON_LOCAL_NUMA (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1036+ found = 1 ;
1037+ }
1038+ } else if ( rresults [2 * i ] == 8 ) {
8201039 if (OPAL_PROC_ON_LOCAL_NODE (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
821- rsorted [(2 * loc )+ 0 ] = i ; /* org rank */
822- rsorted [(2 * loc )+ 1 ] = rresults [(2 * i )+ 1 ]; /* key */
823- loc ++ ;
1040+ found = 1 ;
1041+ }
1042+ } else if ( rresults [2 * i ] == 9 ) {
1043+ if (OPAL_PROC_ON_LOCAL_BOARD (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1044+ found = 1 ;
1045+ }
1046+ } else if ( rresults [2 * i ] == 10 ) {
1047+ if (OPAL_PROC_ON_LOCAL_HOST (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1048+ found = 1 ;
8241049 }
1050+ } else if ( rresults [2 * i ] == 11 ) {
1051+ if (OPAL_PROC_ON_LOCAL_CU (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1052+ found = 1 ;
1053+ }
1054+ } else if ( rresults [2 * i ] == 12 ) {
1055+ if (OPAL_PROC_ON_LOCAL_CLUSTER (ompi_group_peer_lookup (comm -> c_remote_group , i )-> super .proc_flags )) {
1056+ found = 1 ;
1057+ }
1058+ }
1059+
1060+ if ( found == 1 ) {
1061+ rsorted [2 * loc ] = i ; /* org rank */
1062+ rsorted [2 * loc + 1 ] = rresults [2 * i + 1 ]; /* key */
1063+ loc ++ ;
8251064 }
8261065 }
8271066
0 commit comments