@@ -7447,7 +7447,6 @@ template <
74477447 unsigned int neighborhood_length = 1 ;
74487448
74497449 std::string load_balancing_method{" RCB" };
7450- int hierarchical_level_zero {16 };
74517450
74527451 // maximum value an MPI tag can have
74537452 unsigned int max_tag;
@@ -7603,6 +7602,7 @@ template <
76037602 Zoltan_Struct* zoltan;
76047603 // number of processes per part in a hierarchy level (numbering starts from 0)
76057604 std::vector<unsigned int > processes_per_part;
7605+ std::vector<unsigned int > partition_number;
76067606 // options for each level of hierarchial load balancing (numbering start from 0)
76077607 std::vector<std::unordered_map<std::string, std::string>> partitioning_options;
76087608 // record whether Zoltan_LB_Partition is expected to fail
@@ -7919,10 +7919,39 @@ template <
79197919
79207920 // Hardcoded for now
79217921 if (this ->load_balancing_method == " HIER" ) {
7922- add_partitioning_level (this ->hierarchical_level_zero ); // Level 0 - Nodes
7922+ // Automagical hierarchical partition
7923+ std::hash<std::string> hasher;
7924+
7925+ // get name of this node
7926+ char nodename[MPI_MAX_PROCESSOR_NAME];
7927+ int namelength, nodehash;
7928+ MPI_Get_processor_name (nodename,&namelength);
7929+ nodehash = static_cast <int >(hasher (std::string (nodename, namelength)) % std::numeric_limits<int >::max ());
7930+
7931+ // intra-node communicator
7932+ int rank;
7933+ MPI_Comm_rank (MPI_COMM_WORLD, &rank);
7934+ MPI_Comm nodeComm;
7935+ MPI_Comm_split (MPI_COMM_WORLD, nodehash, rank, &nodeComm);
7936+
7937+ // inter-node communicator
7938+ int nodeRank;
7939+ MPI_Comm_rank (nodeComm,&nodeRank);
7940+ MPI_Comm interComm;
7941+ MPI_Comm_split (MPI_COMM_WORLD, nodeRank, rank, &interComm);
7942+ int interRank;
7943+ MPI_Comm_rank (interComm, &interRank);
7944+
7945+ // Make sure everyone in node agrees on the number of the node
7946+ int nodeNumber {interRank};
7947+ MPI_Bcast (&nodeNumber, 1 , MPI_INT, 0 , nodeComm);
7948+
7949+ add_partitioning_level (1 ); // Level 0 - Nodes
7950+ partition_number.push_back (nodeNumber);
79237951 add_partitioning_option (0 , " LB_METHOD" , " HYPERGRAPH" );
79247952
79257953 add_partitioning_level (1 ); // Level 1 - Processes
7954+ partition_number.push_back (nodeRank);
79267955 add_partitioning_option (1 , " LB_METHOD" , " RIB" );
79277956 // add_partitioning_option(1, "LB_METHOD", "RCB");
79287957 }
@@ -8455,24 +8484,6 @@ template <
84558484 return this ->load_balancing_method ;
84568485 }
84578486
8458- /* !
8459- Sets amount of tasks for node-level of HIER partition for Zoltan
8460-
8461- Must be called before initialize().
8462-
8463- \see balance_load()
8464- */
8465- Dccrg<
8466- Cell_Data,
8467- Geometry,
8468- std::tuple<Additional_Cell_Items...>,
8469- std::tuple<Additional_Neighbor_Items...>
8470- >& set_load_balancing_hier_level_zero (const int n) {
8471- this ->hierarchical_level_zero = n;
8472- return *this ;
8473- }
8474-
8475-
84768487private:
84778488 /* !
84788489 Initializes local cells' neighbor lists and related data structures.
@@ -11729,15 +11740,17 @@ template <
1172911740 *error = ZOLTAN_OK;
1173011741 }
1173111742
11732- int process = int (dccrg_instance->rank );
11733- int part;
11743+ return dccrg_instance->partition_number [level];
1173411744
11735- for (int i = 0 ; i <= level; i++) {
11736- part = process / dccrg_instance->processes_per_part [i];
11737- process %= dccrg_instance->processes_per_part [i];
11738- }
11745+ // int process = int(dccrg_instance->rank);
11746+ // int part;
11747+
11748+ // for (int i = 0; i <= level; i++) {
11749+ // part = process / dccrg_instance->processes_per_part[i];
11750+ // process %= dccrg_instance->processes_per_part[i];
11751+ // }
1173911752
11740- return part;
11753+ // return part;
1174111754 }
1174211755
1174311756
0 commit comments