mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
work around scotch fpe bug
This commit is contained in:
@ -55,7 +55,17 @@ metisCoeffs
|
||||
}
|
||||
|
||||
scotchCoeffs
|
||||
{}
|
||||
{
|
||||
//processorWeights
|
||||
//(
|
||||
// 1
|
||||
// 1
|
||||
// 1
|
||||
// 1
|
||||
//);
|
||||
//writeGraph true;
|
||||
//strategy "b";
|
||||
}
|
||||
|
||||
manualCoeffs
|
||||
{
|
||||
|
||||
@ -75,6 +75,24 @@ extern "C"
|
||||
}
|
||||
|
||||
|
||||
// Hack: scotch generates floating point errors so need to switch of error
|
||||
// trapping!
|
||||
#if defined(linux) || defined(linuxAMD64) || defined(linuxIA64)
|
||||
# define LINUX
|
||||
#endif
|
||||
|
||||
#if defined(LINUX) && defined(__GNUC__)
|
||||
# define LINUX_GNUC
|
||||
#endif
|
||||
|
||||
#ifdef LINUX_GNUC
|
||||
# ifndef __USE_GNU
|
||||
# define __USE_GNU
|
||||
# endif
|
||||
# include <fenv.h>
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -113,13 +131,30 @@ Foam::label Foam::scotchDecomp::decompose
|
||||
{
|
||||
// Strategy
|
||||
// ~~~~~~~~
|
||||
|
||||
// Default.
|
||||
SCOTCH_Strat stradat;
|
||||
check(SCOTCH_stratInit(&stradat), "SCOTCH_stratInit");
|
||||
//SCOTCH_stratGraphMap(&stradat, &argv[i][2]);
|
||||
//fprintf(stdout, "S\tStrat=");
|
||||
//SCOTCH_stratSave(&stradat, stdout);
|
||||
//fprintf(stdout, "\n");
|
||||
|
||||
if (decompositionDict_.found("scotchCoeffs"))
|
||||
{
|
||||
const dictionary& scotchCoeffs =
|
||||
decompositionDict_.subDict("scotchCoeffs");
|
||||
|
||||
|
||||
string strategy;
|
||||
if (scotchCoeffs.readIfPresent("strategy", strategy))
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "scotchDecomp : Using strategy " << strategy << endl;
|
||||
}
|
||||
SCOTCH_stratGraphMap(&stradat, strategy.c_str());
|
||||
//fprintf(stdout, "S\tStrat=");
|
||||
//SCOTCH_stratSave(&stradat, stdout);
|
||||
//fprintf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Graph
|
||||
@ -198,12 +233,36 @@ Foam::label Foam::scotchDecomp::decompose
|
||||
|
||||
SCOTCH_Arch archdat;
|
||||
check(SCOTCH_archInit(&archdat), "SCOTCH_archInit");
|
||||
check
|
||||
(
|
||||
// SCOTCH_archCmpltw for weighted.
|
||||
SCOTCH_archCmplt(&archdat, nProcessors_),
|
||||
"SCOTCH_archCmplt"
|
||||
);
|
||||
|
||||
List<label> processorWeights;
|
||||
if (decompositionDict_.found("scotchCoeffs"))
|
||||
{
|
||||
const dictionary& scotchCoeffs =
|
||||
decompositionDict_.subDict("scotchCoeffs");
|
||||
|
||||
scotchCoeffs.readIfPresent("processorWeights", processorWeights);
|
||||
}
|
||||
if (processorWeights.size())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "scotchDecomp : Using procesor weights " << processorWeights
|
||||
<< endl;
|
||||
}
|
||||
check
|
||||
(
|
||||
SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
|
||||
"SCOTCH_archCmpltw"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
check
|
||||
(
|
||||
SCOTCH_archCmplt(&archdat, nProcessors_),
|
||||
"SCOTCH_archCmplt"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//SCOTCH_Mapping mapdat;
|
||||
@ -212,6 +271,16 @@ Foam::label Foam::scotchDecomp::decompose
|
||||
//SCOTCH_graphMapExit(&grafdat, &mapdat);
|
||||
|
||||
|
||||
// Hack:switch off fpu error trapping
|
||||
# ifdef LINUX_GNUC
|
||||
int oldExcepts = fedisableexcept
|
||||
(
|
||||
FE_DIVBYZERO
|
||||
| FE_INVALID
|
||||
| FE_OVERFLOW
|
||||
);
|
||||
# endif
|
||||
|
||||
finalDecomp.setSize(xadj.size()-1);
|
||||
finalDecomp = 0;
|
||||
check
|
||||
@ -226,6 +295,11 @@ Foam::label Foam::scotchDecomp::decompose
|
||||
"SCOTCH_graphMap"
|
||||
);
|
||||
|
||||
# ifdef LINUX_GNUC
|
||||
feenableexcept(oldExcepts);
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
//finalDecomp.setSize(xadj.size()-1);
|
||||
//check
|
||||
|
||||
Reference in New Issue
Block a user