mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use PrecisionAdaptor in kahipDecomp
This commit is contained in:
committed by
Andrew Heather
parent
328513fcaa
commit
fd4ffc8a27
@ -26,6 +26,7 @@ License
|
||||
#include "kahipDecomp.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "Time.H"
|
||||
#include "PrecisionAdaptor.H"
|
||||
|
||||
#include "kaHIP_interface.h"
|
||||
|
||||
@ -33,6 +34,9 @@ License
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
// Provide a clear error message if we have a severe size mismatch
|
||||
// Allow widening, but not narrowing
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -217,59 +221,30 @@ Foam::label Foam::kahipDecomp::decomposeSerial
|
||||
// Output: number of cut edges
|
||||
int edgeCut = 0;
|
||||
|
||||
#if WM_LABEL_SIZE == 32
|
||||
|
||||
// Input:
|
||||
int* xadjPtr = const_cast<int*>(xadj.begin());
|
||||
int* adjncyPtr = const_cast<int*>(adjncy.begin());
|
||||
// Addressing
|
||||
ConstPrecisionAdaptor<int, label, List> xadj_param(xadj);
|
||||
ConstPrecisionAdaptor<int, label, List> adjncy_param(adjncy);
|
||||
|
||||
// Output: cell -> processor addressing
|
||||
decomp.setSize(numCells);
|
||||
int* decompPtr = decomp.begin();
|
||||
decomp.resize(numCells);
|
||||
PrecisionAdaptor<int, label, List> decomp_param(decomp);
|
||||
|
||||
#elif WM_LABEL_SIZE == 64
|
||||
|
||||
// input (copy)
|
||||
List<int> xadjCopy(xadj.size());
|
||||
List<int> adjncyCopy(adjncy.size());
|
||||
|
||||
forAll(xadj,i)
|
||||
{
|
||||
xadjCopy[i] = xadj[i];
|
||||
}
|
||||
forAll(adjncy,i)
|
||||
{
|
||||
adjncyCopy[i] = adjncy[i];
|
||||
}
|
||||
|
||||
int* xadjPtr = xadjCopy.begin();
|
||||
int* adjncyPtr = adjncyCopy.begin();
|
||||
|
||||
if (decomp.size() != numCells)
|
||||
{
|
||||
decomp.clear();
|
||||
}
|
||||
|
||||
// Output: cell -> processor addressing
|
||||
List<int> decompCopy(numCells);
|
||||
int* decompPtr = decompCopy.begin();
|
||||
#endif
|
||||
|
||||
#if 0 // WIP: #ifdef KAFFPA_CPP_INTERFACE
|
||||
kaffpa_cpp
|
||||
(
|
||||
&numCells, // num vertices in graph
|
||||
(cellWeights.size() ? cellWeights.begin() : nullptr), // vertex wts
|
||||
xadjPtr, // indexing into adjncy
|
||||
xadj_param.constCast().data(), // indexing into adjncy
|
||||
nullptr, // edge wts
|
||||
adjncyPtr, // neighbour info
|
||||
adjncy_param.constCast().data(), // neighbour info
|
||||
&nParts, // nparts
|
||||
&imbalance, // amount of imbalance allowed
|
||||
!verbose, // suppress output
|
||||
seed, // for random
|
||||
int(kahipConfig),
|
||||
&edgeCut, // [output]
|
||||
decompPtr, // [output]
|
||||
&edgeCut, // [output]
|
||||
decomp_param.ref().data(), // [output]
|
||||
sizingParams
|
||||
);
|
||||
#else
|
||||
@ -277,35 +252,19 @@ Foam::label Foam::kahipDecomp::decomposeSerial
|
||||
(
|
||||
&numCells, // num vertices in graph
|
||||
(cellWeights.size() ? cellWeights.begin() : nullptr), // vertex wts
|
||||
xadjPtr, // indexing into adjncy
|
||||
xadj_param.constCast().data(), // indexing into adjncy
|
||||
nullptr, // edge wts
|
||||
adjncyPtr, // neighbour info
|
||||
adjncy_param.constCast().data(), // neighbour info
|
||||
&nParts, // nparts
|
||||
&imbalance, // amount of imbalance allowed
|
||||
!verbose, // suppress output
|
||||
seed, // for random
|
||||
int(kahipConfig),
|
||||
&edgeCut, // [output]
|
||||
decompPtr // [output]
|
||||
&edgeCut, // [output]
|
||||
decomp_param.ref().data() // [output]
|
||||
);
|
||||
#endif
|
||||
|
||||
#if WM_LABEL_SIZE == 64
|
||||
|
||||
// Drop input copy
|
||||
xadjCopy.clear();
|
||||
adjncyCopy.clear();
|
||||
|
||||
// Copy back to List<label>
|
||||
decomp.setSize(numCells);
|
||||
forAll(decompCopy, i)
|
||||
{
|
||||
decomp[i] = decompCopy[i];
|
||||
}
|
||||
|
||||
decompCopy.clear();
|
||||
#endif
|
||||
|
||||
return edgeCut;
|
||||
}
|
||||
|
||||
|
||||
@ -190,12 +190,12 @@ Foam::label Foam::metisDecomp::decomposeSerial
|
||||
idx_t nProcs = nDomains_;
|
||||
|
||||
// Addressing
|
||||
ConstPrecisionAdaptor<idx_t, label, List> xadj_metis(xadj);
|
||||
ConstPrecisionAdaptor<idx_t, label, List> adjncy_metis(adjncy);
|
||||
ConstPrecisionAdaptor<idx_t, label, List> xadj_param(xadj);
|
||||
ConstPrecisionAdaptor<idx_t, label, List> adjncy_param(adjncy);
|
||||
|
||||
// Output: cell -> processor addressing
|
||||
PrecisionAdaptor<idx_t, label, List> decomp_metis(decomp);
|
||||
decomp_metis.ref().setSize(numCells);
|
||||
decomp.resize(numCells);
|
||||
PrecisionAdaptor<idx_t, label, List> decomp_param(decomp);
|
||||
|
||||
// Output: number of cut edges
|
||||
idx_t edgeCut = 0;
|
||||
@ -206,8 +206,8 @@ Foam::label Foam::metisDecomp::decomposeSerial
|
||||
(
|
||||
&numCells, // num vertices in graph
|
||||
&ncon, // num balancing constraints
|
||||
xadj_metis.ref().data(), // indexing into adjncy
|
||||
adjncy_metis.ref().data(), // neighbour info
|
||||
xadj_param.constCast().data(), // indexing into adjncy
|
||||
adjncy_param.constCast().data(), // neighbour info
|
||||
cellWeights.data(), // vertex wts
|
||||
nullptr, // vsize: total communication vol
|
||||
faceWeights.data(), // edge wts
|
||||
@ -216,7 +216,7 @@ Foam::label Foam::metisDecomp::decomposeSerial
|
||||
nullptr, // ubvec: processor imbalance (default)
|
||||
options.data(),
|
||||
&edgeCut,
|
||||
decomp_metis.ref().data()
|
||||
decomp_param.ref().data()
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -225,8 +225,8 @@ Foam::label Foam::metisDecomp::decomposeSerial
|
||||
(
|
||||
&numCells, // num vertices in graph
|
||||
&ncon, // num balancing constraints
|
||||
xadj_metis.ref().data(), // indexing into adjncy
|
||||
adjncy_metis.ref().data(), // neighbour info
|
||||
xadj_param.constCast().data(), // indexing into adjncy
|
||||
adjncy_param.constCast().data(), // neighbour info
|
||||
cellWeights.data(), // vertex wts
|
||||
nullptr, // vsize: total communication vol
|
||||
faceWeights.data(), // edge wts
|
||||
@ -235,7 +235,7 @@ Foam::label Foam::metisDecomp::decomposeSerial
|
||||
nullptr, // ubvec: processor imbalance (default)
|
||||
options.data(),
|
||||
&edgeCut,
|
||||
decomp_metis.ref().data()
|
||||
decomp_param.ref().data()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -127,10 +127,10 @@ Foam::label Foam::scotchDecomp::decomposeSerial
|
||||
const label numericflag = 10*hasEdgeWeights+hasVertexWeights;
|
||||
str << baseval << ' ' << numericflag << nl;
|
||||
|
||||
for (label celli = 0; celli < xadj.size()-1; ++celli)
|
||||
for (label celli = 1; celli < xadj.size(); ++celli)
|
||||
{
|
||||
const label start = xadj[celli];
|
||||
const label end = xadj[celli+1];
|
||||
const label start = xadj[celli-1];
|
||||
const label end = xadj[celli];
|
||||
|
||||
str << end-start; // size
|
||||
|
||||
|
||||
Reference in New Issue
Block a user