[MOAB-dev] r2105 - MOAB/trunk/tools/mbzoltan
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Mon Sep 29 15:57:48 CDT 2008
Author: kraftche
Date: 2008-09-29 15:57:42 -0500 (Mon, 29 Sep 2008)
New Revision: 2105
Modified:
MOAB/trunk/tools/mbzoltan/MBZoltan.cpp
MOAB/trunk/tools/mbzoltan/MBZoltan.hpp
Log:
Patch from Jed Brown fixing MBZoltan, which I broke with recent
changes to the handling of MPI rank and size data in MOAB.
Modified: MOAB/trunk/tools/mbzoltan/MBZoltan.cpp
===================================================================
--- MOAB/trunk/tools/mbzoltan/MBZoltan.cpp 2008-09-29 20:54:32 UTC (rev 2104)
+++ MOAB/trunk/tools/mbzoltan/MBZoltan.cpp 2008-09-29 20:57:42 UTC (rev 2105)
@@ -61,7 +61,7 @@
!strcmp(zmethod, "PHG") && !strcmp(zmethod, "PARMETIS") &&
!strcmp(zmethod, "OCTPART"))
{
- std::cout << "ERROR node " << mbImpl->proc_rank() << ": Method must be "
+ std::cout << "ERROR node " << mbpc->proc_config().proc_rank() << ": Method must be "
<< "RCB, RIB, HSFC, Hypergraph (PHG), PARMETIS, or OCTPART"
<< std::endl;
return MB_FAILURE;
@@ -76,7 +76,7 @@
MBErrorCode result;
- if (mbImpl->proc_rank() == 0) {
+ if (mbpc->proc_config().proc_rank() == 0) {
result = assemble_graph(3, pts, ids, adjs, length, elems); RR;
}
@@ -166,8 +166,8 @@
mbFinalizePoints((int)ids.size(), numExport, exportLocalIds,
exportProcs, &assignment);
- if (mbImpl->proc_rank() == 0) {
- MBErrorCode result = write_partition(mbImpl->proc_size(), elems, assignment,
+ if (mbpc->proc_config().proc_rank() == 0) {
+ MBErrorCode result = write_partition(mbpc->proc_config().proc_size(), elems, assignment,
write_as_sets, write_as_tags);
if (MB_SUCCESS != result) return result;
@@ -202,7 +202,7 @@
const int part_dim)
{
// should only be called in serial
- if (mbImpl->proc_size() != 1) {
+ if (mbpc->proc_config().proc_size() != 1) {
std::cout << "MBZoltan::partition_mesh must be called in serial."
<< std::endl;
return MB_FAILURE;
@@ -213,7 +213,7 @@
strcmp(zmethod, "PHG") && strcmp(zmethod, "PARMETIS") &&
strcmp(zmethod, "OCTPART"))
{
- std::cout << "ERROR node " << mbImpl->proc_rank() << ": Method must be "
+ std::cout << "ERROR node " << mbpc->proc_config().proc_rank() << ": Method must be "
<< "RCB, RIB, HSFC, Hypergraph (PHG), PARMETIS, or OCTPART"
<< std::endl;
return MB_FAILURE;
@@ -334,8 +334,7 @@
if (MB_SUCCESS != result || elems.empty()) return result;
// assign global ids
- MBParallelComm mbpc(mbImpl);
- result = mbpc.assign_global_ids(0, dimension); RR;
+ result = mbpc->assign_global_ids(0, dimension); RR;
// now assemble the graph, calling MeshTopoUtil to get bridge adjacencies through d-1 dimensional
// neighbors
@@ -477,7 +476,7 @@
void MBZoltan::SetRCB_Parameters()
{
- if (mbImpl->proc_rank() == 0) std::cout << "\nRecursive Coordinate Bisection" << std::endl;
+ if (mbpc->proc_config().proc_rank() == 0) std::cout << "\nRecursive Coordinate Bisection" << std::endl;
// General parameters:
myZZ->Set_Param("DEBUG_LEVEL", "0"); // no debug messages
@@ -492,7 +491,7 @@
void MBZoltan::SetRIB_Parameters()
{
- if (mbImpl->proc_rank() == 0) std::cout << "\nRecursive Inertial Bisection" << std::endl;
+ if (mbpc->proc_config().proc_rank() == 0) std::cout << "\nRecursive Inertial Bisection" << std::endl;
// General parameters:
myZZ->Set_Param("DEBUG_LEVEL", "0"); // no debug messages
@@ -506,7 +505,7 @@
void MBZoltan::SetHSFC_Parameters()
{
- if (mbImpl->proc_rank() == 0) std::cout << "\nHilbert Space Filling Curve" << std::endl;
+ if (mbpc->proc_config().proc_rank() == 0) std::cout << "\nHilbert Space Filling Curve" << std::endl;
// General parameters:
myZZ->Set_Param("DEBUG_LEVEL", "0"); // no debug messages
@@ -519,7 +518,7 @@
void MBZoltan::SetHypergraph_Parameters(const char *phg_method)
{
- if (mbImpl->proc_rank() == 0) std::cout << "\nHypergraph (or PHG): " << std::endl;
+ if (mbpc->proc_config().proc_rank() == 0) std::cout << "\nHypergraph (or PHG): " << std::endl;
// General parameters:
myZZ->Set_Param("DEBUG_LEVEL", "0"); // no debug messages
@@ -531,7 +530,7 @@
void MBZoltan::SetPARMETIS_Parameters(const char *parmetis_method)
{
- if (mbImpl->proc_rank() == 0) std::cout << "\nPARMETIS: " << parmetis_method << std::endl;
+ if (mbpc->proc_config().proc_rank() == 0) std::cout << "\nPARMETIS: " << parmetis_method << std::endl;
// General parameters:
myZZ->Set_Param("DEBUG_LEVEL", "0"); // no debug messages
@@ -544,7 +543,7 @@
void MBZoltan::SetOCTPART_Parameters(const char *oct_method)
{
- if (mbImpl->proc_rank() == 0) std::cout << "\nOctree Partitioning: " << oct_method
+ if (mbpc->proc_config().proc_rank() == 0) std::cout << "\nOctree Partitioning: " << oct_method
<< std::endl;
// General parameters:
@@ -571,23 +570,23 @@
int *sendNborId;
int *sendProcs;
- if (mbImpl->proc_rank() == 0)
+ if (mbpc->proc_config().proc_rank() == 0)
{
/* divide pts to start */
- numPts = (int *)malloc(sizeof(int) * mbImpl->proc_size());
- ptsPerProc = npts / mbImpl->proc_size();
+ numPts = (int *)malloc(sizeof(int) * mbpc->proc_config().proc_size());
+ ptsPerProc = npts / mbpc->proc_config().proc_size();
ptsAssigned = 0;
- for (i=0; (int) i < mbImpl->proc_size()-1; i++)
+ for (i=0; (int) i < mbpc->proc_config().proc_size()-1; i++)
{
numPts[i] = ptsPerProc;
ptsAssigned += ptsPerProc;
}
- numPts[mbImpl->proc_size()-1] = npts - ptsAssigned;
+ numPts[mbpc->proc_config().proc_size()-1] = npts - ptsAssigned;
- mySize = numPts[mbImpl->proc_rank()];
+ mySize = numPts[mbpc->proc_config().proc_rank()];
sendPts = pts + (3 * numPts[0]);
sendIds = ids + numPts[0];
sendEdges = length + numPts[0];
@@ -604,14 +603,14 @@
nborProcs = (int *)malloc(sizeof(int) * sum);
for (j=0; j<sum; j++)
- if ((i = adjs[j]/ptsPerProc) < mbImpl->proc_size())
+ if ((i = adjs[j]/ptsPerProc) < mbpc->proc_config().proc_size())
nborProcs[j] = i;
else
- nborProcs[j] = mbImpl->proc_size() - 1;
+ nborProcs[j] = mbpc->proc_config().proc_size() - 1;
sendProcs = nborProcs + (sendNborId - adjs);
- for (i=1; (int)i<mbImpl->proc_size(); i++)
+ for (i=1; (int)i<mbpc->proc_config().proc_size(); i++)
{
MPI_Send(&numPts[i], 1, MPI_INT, i, 0x00,MPI_COMM_WORLD);
MPI_Send(sendPts, 3 * numPts[i], MPI_DOUBLE, i, 0x01,MPI_COMM_WORLD);
@@ -675,24 +674,24 @@
/* assign pts to start */
- if (mbImpl->proc_rank() == 0)
+ if (mbpc->proc_config().proc_rank() == 0)
MyAssignment = (int *)malloc(sizeof(int) * npts);
else
MyAssignment = (int *)malloc(sizeof(int) * NumPoints);
for (i=0; i<NumPoints; i++)
- MyAssignment[i] = mbImpl->proc_rank();
+ MyAssignment[i] = mbpc->proc_config().proc_rank();
for (i=0; i<numExport; i++)
MyAssignment[exportLocalIDs[i]] = exportProcs[i];
- if (mbImpl->proc_rank() == 0)
+ if (mbpc->proc_config().proc_rank() == 0)
{
/* collect pts */
recvA = MyAssignment + NumPoints;
- for (i=1; i< (int) mbImpl->proc_size(); i++)
+ for (i=1; i< (int) mbpc->proc_config().proc_size(); i++)
{
MPI_Recv(&numPts, 1, MPI_INT, i, 0x04, MPI_COMM_WORLD, &stat);
MPI_Recv(recvA, numPts, MPI_INT, i, 0x05, MPI_COMM_WORLD, &stat);
@@ -713,13 +712,13 @@
{
int fail = 0;
int i;
- int *vals = (int *)malloc(mbImpl->proc_size() * sizeof(int));
+ int *vals = (int *)malloc(mbpc->proc_config().proc_size() * sizeof(int));
MPI_Allgather(&rc, 1, MPI_INT, vals, 1, MPI_INT, MPI_COMM_WORLD);
- for (i=0; i<mbImpl->proc_size(); i++){
+ for (i=0; i<mbpc->proc_config().proc_size(); i++){
if (vals[i] != ZOLTAN_OK){
- if (0 == mbImpl->proc_rank()){
+ if (0 == mbpc->proc_config().proc_rank()){
mbShowError(vals[i], "Result on process ");
}
fail = 1;
@@ -743,15 +742,15 @@
v1[2] = exp;
v1[3] = change;
- if (mbImpl->proc_rank() == 0){
- v2 = (int *)malloc(4 * mbImpl->proc_size() * sizeof(int));
+ if (mbpc->proc_config().proc_rank() == 0){
+ v2 = (int *)malloc(4 * mbpc->proc_config().proc_size() * sizeof(int));
}
MPI_Gather(v1, 4, MPI_INT, v2, 4, MPI_INT, 0, MPI_COMM_WORLD);
- if (mbImpl->proc_rank() == 0){
+ if (mbpc->proc_config().proc_rank() == 0){
fprintf(stdout,"======%s======\n",s);
- for (i=0, v=v2; i<mbImpl->proc_size(); i++, v+=4){
+ for (i=0, v=v2; i<mbpc->proc_config().proc_size(); i++, v+=4){
fprintf(stdout,"%d: originally had %d, import %d, exp %d, %s\n",
i, v[0], v[1], v[2],
v[3] ? "a change of partitioning" : "no change");
@@ -774,19 +773,19 @@
switch (val)
{
case ZOLTAN_OK:
- printf("%d: SUCCESSFUL\n", mbImpl->proc_rank());
+ printf("%d: SUCCESSFUL\n", mbpc->proc_config().proc_rank());
break;
case ZOLTAN_WARN:
- printf("%d: WARNING\n", mbImpl->proc_rank());
+ printf("%d: WARNING\n", mbpc->proc_config().proc_rank());
break;
case ZOLTAN_FATAL:
- printf("%d: FATAL ERROR\n", mbImpl->proc_rank());
+ printf("%d: FATAL ERROR\n", mbpc->proc_config().proc_rank());
break;
case ZOLTAN_MEMERR:
- printf("%d: MEMORY ALLOCATION ERROR\n", mbImpl->proc_rank());
+ printf("%d: MEMORY ALLOCATION ERROR\n", mbpc->proc_config().proc_rank());
break;
default:
- printf("%d: INVALID RETURN CODE\n", mbImpl->proc_rank());
+ printf("%d: INVALID RETURN CODE\n", mbpc->proc_config().proc_rank());
break;
}
return;
Modified: MOAB/trunk/tools/mbzoltan/MBZoltan.hpp
===================================================================
--- MOAB/trunk/tools/mbzoltan/MBZoltan.hpp 2008-09-29 20:54:32 UTC (rev 2104)
+++ MOAB/trunk/tools/mbzoltan/MBZoltan.hpp 2008-09-29 20:57:42 UTC (rev 2105)
@@ -57,6 +57,7 @@
#include <vector>
#include "MBInterface.hpp"
+#include "MBParallelComm.hpp"
class MBZoltan
{
@@ -66,7 +67,9 @@
int argc = 0, char **argv = NULL)
: mbImpl(impl), myZZ(NULL), newMoab(false), useCoords(use_coords),
argcArg(argc), argvArg(argv)
- {}
+ {
+ mbpc = MBParallelComm::get_pcomm(mbImpl, 0);
+ }
~MBZoltan();
@@ -111,6 +114,8 @@
MBInterface *mbImpl;
+ MBParallelComm *mbpc;
+
Zoltan *myZZ;
bool newMoab;
More information about the moab-dev
mailing list