diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict index 0c566d50812ffcdbd856d09f12ebac9244177468..aad15ee459b6e01cdf6fabba08eb2fa5b8c2a4dd 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict +++ b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict @@ -55,7 +55,17 @@ metisCoeffs } scotchCoeffs -{} +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} manualCoeffs { diff --git a/src/decompositionMethods/decompositionMethods/scotchDecomp/scotchDecomp.C b/src/decompositionMethods/decompositionMethods/scotchDecomp/scotchDecomp.C index f1e1cd27804982d580605d349cea628b2bef716f..994a82419285a24da2695f3e3850ee4580d1f8ac 100644 --- a/src/decompositionMethods/decompositionMethods/scotchDecomp/scotchDecomp.C +++ b/src/decompositionMethods/decompositionMethods/scotchDecomp/scotchDecomp.C @@ -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