Skip to content

Commit 09efb1a

Browse files
committed
Increase the default number of colors.
1 parent e6ac3db commit 09efb1a

5 files changed

Lines changed: 8 additions & 20 deletions

File tree

Common/include/geometry/CGeometry.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,12 +1724,10 @@ class CGeometry {
17241724
* CGeometry::edgeColorGroupSize that yields a coloring that is at least as efficient as #COLORING_EFF_THRESH.
17251725
* \param[out] efficiency - optional output of the coloring efficiency.
17261726
* \param[in] maximizeEdgeColorGroupSize - use the maximum edge color group size that gives an efficient coloring.
1727-
* \param[in] largeNumberOfColors - allow up to 255 colors instead of 64 (default)
17281727
* \return Reference to the coloring.
17291728
*/
17301729
const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr,
1731-
bool maximizeEdgeColorGroupSize = false,
1732-
bool largeNumberOfColors = false);
1730+
bool maximizeEdgeColorGroupSize = false);
17331731

17341732
/*!
17351733
* \brief Force the natural (sequential) edge coloring.

Common/include/toolboxes/graph_toolbox.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ T createNaturalColoring(Index_t numInnerIndexes) {
484484
* \param[out] indexColor - Optional, vector with colors given to the outer indices.
485485
* \return Coloring in the same type of the input pattern.
486486
*/
487-
template <typename Color_t = char, size_t MaxColors = 64, size_t MaxMB = 128, class T>
487+
template <typename Color_t = unsigned char, size_t MaxColors = 255, size_t MaxMB = 128, class T>
488488
T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false,
489489
std::vector<Color_t>* indexColor = nullptr) {
490490
static_assert(std::is_integral<Color_t>::value, "");

Common/src/geometry/CGeometry.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,8 +3609,7 @@ const su2vector<unsigned long>& CGeometry::GetTransposeSparsePatternMap(Connecti
36093609
return pattern.transposePtr();
36103610
}
36113611

3612-
const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize,
3613-
bool largeNumberOfColors) {
3612+
const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize) {
36143613
/*--- Check for dry run mode with dummy geometry. ---*/
36153614
if (nEdge == 0) return edgeColoring;
36163615

@@ -3639,23 +3638,14 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien
36393638
/*--- Color the edges. ---*/
36403639
constexpr bool balanceColors = true;
36413640

3642-
/*--- Lambda to account for different numbers of colors. ---*/
3643-
auto getColorSparsePattern = [&](unsigned long edgeColorGroupSize) {
3644-
if (largeNumberOfColors) {
3645-
return colorSparsePattern<unsigned char, 255>(pattern, edgeColorGroupSize, balanceColors);
3646-
} else {
3647-
return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);
3648-
}
3649-
};
3650-
36513641
/*--- if requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize) ---*/
36523642
if (maximizeEdgeColorGroupSize) {
36533643
auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */
36543644
auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */
36553645
auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */
36563646

36573647
while (true) {
3658-
auto currentEdgeColoring = getColorSparsePattern(nextEdgeColorGroupSize);
3648+
const auto currentEdgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);
36593649

36603650
/*--- if the coloring fails, reduce the color group size ---*/
36613651
if (currentEdgeColoring.empty()) {
@@ -3675,7 +3665,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien
36753665
else {
36763666
lowerEdgeColorGroupSize = nextEdgeColorGroupSize;
36773667
}
3678-
auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2;
3668+
const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2;
36793669

36803670
nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment;
36813671

@@ -3687,7 +3677,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien
36873677
edgeColorGroupSize = nextEdgeColorGroupSize;
36883678
}
36893679

3690-
edgeColoring = getColorSparsePattern(edgeColorGroupSize);
3680+
edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors);
36913681

36923682
/*--- If the coloring fails use the natural coloring. This is a
36933683
* "soft" failure as this "bad" coloring should be detected

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void CFVMFlowSolverBase<V, R>::HybridParallelInitialization(const CConfig& confi
294294
* group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers
295295
* of colors. ---*/
296296
const bool relax = config.GetEdgeColoringRelaxDiscAdj();
297-
const auto& coloring = geometry.GetEdgeColoring(&parallelEff, relax, relax);
297+
const auto& coloring = geometry.GetEdgeColoring(&parallelEff, relax);
298298
#else
299299
const auto& coloring = geometry.GetEdgeColoring(&parallelEff);
300300
#endif

SU2_CFD/include/solvers/CScalarSolver.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ CScalarSolver<VariableType>::CScalarSolver(CGeometry* geometry, CConfig* config,
5151
* group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers
5252
* of colors. ---*/
5353
const bool relax = config->GetEdgeColoringRelaxDiscAdj();
54-
const auto& coloring = geometry->GetEdgeColoring(&parallelEff, relax, relax);
54+
const auto& coloring = geometry->GetEdgeColoring(&parallelEff, relax);
5555
#else
5656
const auto& coloring = geometry->GetEdgeColoring(&parallelEff);
5757
#endif

0 commit comments

Comments
 (0)