Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hybrid Parallel AD (Part 3/?) #1294

Merged
merged 47 commits into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
bb27a0b
CoDiPack update.
jblueh Jun 1, 2021
183c3ca
CoDiPack tape choice via build options.
jblueh Jun 11, 2021
f501dc1
Fix for the disc_adj_fsi problem.
jblueh Jun 11, 2021
3b0ebd3
Merge branch 'develop' into hybrid_parallel_ad4
pcarruscag Jun 24, 2021
6f3c86a
work estimate for OpenMP scheduling of preconditioners based on num n…
pcarruscag Jun 24, 2021
d5f8ac9
small fix
pcarruscag Jun 24, 2021
53bd274
update tests
pcarruscag Jun 24, 2021
0fe1e67
add hybrid AD regressions
pcarruscag Jun 24, 2021
5017a90
set reference residuals
pcarruscag Jun 25, 2021
b7b3dd7
remove heat case because heat solver does not have openmp
pcarruscag Jun 25, 2021
967704c
Make preaccumulation threadprivate.
jblueh Jun 28, 2021
0a72b67
Re-enable parallel preaccumulation.
jblueh Jun 28, 2021
c38bf14
Remove unused variable.
jblueh Jun 28, 2021
b61684b
PreaccActive was never reset.
jblueh Jun 28, 2021
781092a
Identify some faulty preaccumulation regions.
jblueh Jun 29, 2021
77aa7d0
Disable preaccumulation for parallel boundary numerics.
jblueh Jun 30, 2021
742118d
Add assert.
jblueh Jun 30, 2021
9b09003
Merge remote-tracking branch 'upstream/develop' into hybrid_parallel_ad4
pcarruscag Jul 5, 2021
1d2c206
disable preacc when coloring fails
pcarruscag Jul 5, 2021
a573f9a
small fix
pcarruscag Jul 5, 2021
bc90f74
Add shared reading switches.
jblueh Jul 6, 2021
cba486d
Apply some shared reading optimizations.
jblueh Jul 6, 2021
8e7a9c6
Apply suggestions.
jblueh Jul 6, 2021
e03f11b
Update Arina2K regression
pcarruscag Jul 6, 2021
15d3666
Remove redundant init.
jblueh Jul 7, 2021
e10abcc
OpDiLib update.
jblueh Jul 13, 2021
2726ca6
Add build option for shared reading optimization.
jblueh Jul 13, 2021
f8fe252
Fix.
jblueh Jul 13, 2021
ab91794
Merge branch 'develop' into hybrid_parallel_ad4
pcarruscag Jul 15, 2021
d8656aa
update discadj_fea (hybrid AD)
pcarruscag Jul 15, 2021
ac18c09
Merge branch 'develop' into hybrid_parallel_ad4
pcarruscag Jul 20, 2021
3c84ad1
Missing barrier.
jblueh Jul 20, 2021
c8ff857
CoDiPack update.
jblueh Jul 20, 2021
5901d8b
Merge remote-tracking branch 'su2github/hybrid_parallel_ad4' into hyb…
jblueh Jul 20, 2021
fcc39ce
Move barrier inside HandleTemporariesOut.
jblueh Jul 22, 2021
028d1e0
Further shared reading optimizations.
jblueh Jul 28, 2021
7acc44f
Test without boundary treatment.
jblueh Jul 28, 2021
7586e7c
Merge branch 'develop' into hybrid_parallel_ad4
jblueh Jul 28, 2021
2830dea
Source_Residual shared reading optimizations.
jblueh Jul 28, 2021
25ba4e3
revise some shared readings and add others
pcarruscag Aug 1, 2021
3b4a018
Merge branch 'develop' into hybrid_parallel_ad4
pcarruscag Aug 1, 2021
a9466bb
Suggestion for an option that disabled OpDiLib.
jblueh Aug 2, 2021
1ce5115
OpDiLib update.
jblueh Aug 4, 2021
e81a8ff
Revert "Suggestion for an option that disabled OpDiLib."
jblueh Aug 4, 2021
3f81059
Replace assert by warning.
jblueh Aug 4, 2021
d64d620
Update SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp
pcarruscag Aug 5, 2021
597c637
Merge branch 'develop' into hybrid_parallel_ad4
pcarruscag Aug 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions Common/include/basic_types/ad_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace AD{

/*!
* \brief Start a passive region, i.e. stop recording.
* \return True is tape was active.
* \return True if tape was active.
*/
inline bool BeginPassive() { return false; }

Expand All @@ -262,6 +262,18 @@ namespace AD{
*/
inline void EndPassive(bool wasActive) {}

/*!
* \brief Pause the use of preaccumulation.
* \return True if preaccumulation was active.
*/
inline bool PausePreaccumulation() { return false; }

/*!
* \brief Resume the use of preaccumulation.
* \param[in] wasActive - Whether preaccumulation was active before pausing.
*/
inline void ResumePreaccumulation(bool wasActive) {}
jblueh marked this conversation as resolved.
Show resolved Hide resolved

#else
using CheckpointHandler = codi::DataStore;

Expand All @@ -273,7 +285,7 @@ namespace AD{

extern bool PreaccActive;
#ifdef HAVE_OPDI
#pragma omp threadprivate(PreaccActive)
SU2_OMP(threadprivate(PreaccActive))
#endif

extern bool PreaccEnabled;
Expand All @@ -292,7 +304,7 @@ namespace AD{

extern codi::PreaccumulationHelper<su2double> PreaccHelper;
#ifdef HAVE_OPDI
#pragma omp threadprivate(PreaccHelper)
SU2_OMP(threadprivate(PreaccHelper))
#endif

/*--- Reference to the tape. ---*/
Expand Down Expand Up @@ -527,6 +539,26 @@ namespace AD{

FORCEINLINE void EndPassive(bool wasActive) { if(wasActive) StartRecording(); }

FORCEINLINE bool PausePreaccumulation() {
const auto current = PreaccEnabled;
if (!current) return false;
SU2_OMP_BARRIER
SU2_OMP_MASTER
PreaccEnabled = false;
END_SU2_OMP_MASTER
SU2_OMP_BARRIER
return true;
}

FORCEINLINE void ResumePreaccumulation(bool wasActive) {
if (!wasActive) return;
SU2_OMP_BARRIER
SU2_OMP_MASTER
PreaccEnabled = true;
END_SU2_OMP_MASTER
SU2_OMP_BARRIER
}

pcarruscag marked this conversation as resolved.
Show resolved Hide resolved
#endif // CODI_REVERSE_TYPE

} // namespace AD
Expand Down
2 changes: 1 addition & 1 deletion Common/include/toolboxes/graph_toolbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ T createNaturalColoring(Index_t numInnerIndexes)
* \param[out] indexColor - Optional, vector with colors given to the outer indices.
* \return Coloring in the same type of the input pattern.
*/
template<class T, typename Color_t = char, size_t MaxColors = 32, size_t MaxMB = 128>
template<class T, typename Color_t = char, size_t MaxColors = 64, size_t MaxMB = 128>
T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false,
std::vector<Color_t>* indexColor = nullptr)
{
Expand Down
4 changes: 2 additions & 2 deletions Common/src/basic_types/ad_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ namespace AD {

bool PreaccActive = false;
#ifdef HAVE_OPDI
#pragma omp threadprivate(PreaccActive)
SU2_OMP(threadprivate(PreaccActive))
#endif

bool PreaccEnabled = true;

codi::PreaccumulationHelper<su2double> PreaccHelper;
#ifdef HAVE_OPDI
#pragma omp threadprivate(PreaccHelper)
SU2_OMP(threadprivate(PreaccHelper))
#endif

ExtFuncHelper* FuncHelper;
Expand Down
14 changes: 13 additions & 1 deletion SU2_CFD/include/solvers/CFVMFlowSolverBase.inl
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ void CFVMFlowSolverBase<V, R>::HybridParallelInitialization(const CConfig& confi
cout << "WARNING: On " << numRanksUsingReducer << " MPI ranks the coloring efficiency was less than "
<< COLORING_EFF_THRESH << " (min value was " << minEff << ").\n"
<< " Those ranks will now use a fallback strategy, better performance may be possible\n"
<< " with a different value of config option EDGE_COLORING_GROUP_SIZE (default 512)." << endl;
<< " with a different value of config option EDGE_COLORING_GROUP_SIZE (default 512)."
#ifdef HAVE_OPDI
<< "\n The memory usage of the discrete adjoint solver is higher when using the fallback."
#endif
<< endl;
}

if (config.GetUseVectorization() && (omp_get_max_threads() > 1) &&
Expand Down Expand Up @@ -1535,6 +1539,10 @@ void CFVMFlowSolverBase<V, R>::EdgeFluxResidual(const CGeometry *geometry,
InstantiateEdgeNumerics(solvers, config);
}

#ifdef HAVE_OPDI
const auto preaccEnabled = ReducerStrategy && AD::PausePreaccumulation();
#endif
pcarruscag marked this conversation as resolved.
Show resolved Hide resolved

/*--- Loop over edge colors. ---*/
for (auto color : EdgeColoring) {
/*--- Chunk size is at least OMP_MIN_SIZE and a multiple of the color group size. ---*/
Expand All @@ -1557,6 +1565,10 @@ void CFVMFlowSolverBase<V, R>::EdgeFluxResidual(const CGeometry *geometry,
END_SU2_OMP_FOR
}

#ifdef HAVE_OPDI
AD::ResumePreaccumulation(preaccEnabled);
#endif

if (ReducerStrategy) {
SumEdgeFluxes(geometry);
if (config->GetKind_TimeIntScheme() == EULER_IMPLICIT) {
Expand Down
6 changes: 2 additions & 4 deletions SU2_CFD/src/integration/CIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ void CIntegration::Space_Integration(CGeometry *geometry,
CNumerics* visc_bound_numerics = numerics[VISC_BOUND_TERM + omp_get_thread_num()*MAX_TERMS];

#ifdef HAVE_OPDI
/* disable preaccumulation for parallel boundary numerics */
bool preaccEnabled = AD::PreaccEnabled;
AD::PreaccEnabled = false;
const auto preaccEnabled = AD::PausePreaccumulation();
#endif

/*--- Boundary conditions that depend on other boundaries (they require MPI sincronization)---*/
Expand Down Expand Up @@ -185,7 +183,7 @@ void CIntegration::Space_Integration(CGeometry *geometry,
}

#ifdef HAVE_OPDI
AD::PreaccEnabled = preaccEnabled;
AD::ResumePreaccumulation(preaccEnabled);
#endif

}
Expand Down
8 changes: 8 additions & 0 deletions SU2_CFD/src/solvers/CEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,10 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain
su2double Primitive_i[MAXNVAR] = {0.0}, Primitive_j[MAXNVAR] = {0.0};
su2double Secondary_i[MAXNVAR] = {0.0}, Secondary_j[MAXNVAR] = {0.0};

#ifdef HAVE_OPDI
const auto preaccEnabled = ReducerStrategy && AD::PausePreaccumulation();
#endif

/*--- Loop over edge colors. ---*/
for (auto color : EdgeColoring)
{
Expand Down Expand Up @@ -2176,6 +2180,10 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain
END_SU2_OMP_FOR
} // end color loop

#ifdef HAVE_OPDI
AD::ResumePreaccumulation(preaccEnabled);
#endif

if (ReducerStrategy) {
SumEdgeFluxes(geometry);
if (implicit)
Expand Down
16 changes: 16 additions & 0 deletions SU2_CFD/src/solvers/CIncEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,10 @@ void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co
bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
bool jst_scheme = ((config->GetKind_Centered_Flow() == JST) && (iMesh == MESH_0));

#ifdef HAVE_OPDI
const auto preaccEnabled = ReducerStrategy && AD::PausePreaccumulation();
#endif

/*--- Loop over edge colors. ---*/
for (auto color : EdgeColoring)
{
Expand Down Expand Up @@ -1082,6 +1086,10 @@ void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co
END_SU2_OMP_FOR
} // end color loop

#ifdef HAVE_OPDI
AD::ResumePreaccumulation(preaccEnabled);
#endif

if (ReducerStrategy) {
SumEdgeFluxes(geometry);
if (implicit)
Expand Down Expand Up @@ -1110,6 +1118,10 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont
const bool limiter = (config->GetKind_SlopeLimit_Flow() != NO_LIMITER);
const bool van_albada = (config->GetKind_SlopeLimit_Flow() == VAN_ALBADA_EDGE);

#ifdef HAVE_OPDI
const auto preaccEnabled = ReducerStrategy && AD::PausePreaccumulation();
#endif

/*--- Loop over edge colors. ---*/
for (auto color : EdgeColoring)
{
Expand Down Expand Up @@ -1250,6 +1262,10 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont
END_SU2_OMP_FOR
} // end color loop

#ifdef HAVE_OPDI
AD::ResumePreaccumulation(preaccEnabled);
#endif

if (ReducerStrategy) {
SumEdgeFluxes(geometry);
if (implicit)
Expand Down
8 changes: 8 additions & 0 deletions SU2_CFD/src/solvers/CTurbSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe
su2double solution_i[MAXNVAR] = {0.0}, flowPrimVar_i[MAXNVARFLOW] = {0.0};
su2double solution_j[MAXNVAR] = {0.0}, flowPrimVar_j[MAXNVARFLOW] = {0.0};

#ifdef HAVE_OPDI
const auto preaccEnabled = ReducerStrategy && AD::PausePreaccumulation();
#endif

/*--- Loop over edge colors. ---*/
for (auto color : EdgeColoring)
{
Expand Down Expand Up @@ -232,6 +236,10 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe
END_SU2_OMP_FOR
} // end color loop

#ifdef HAVE_OPDI
AD::ResumePreaccumulation(preaccEnabled);
#endif

if (ReducerStrategy) {
SumEdgeFluxes(geometry);
if (implicit) Jacobian.SetDiagonalAsColumnSum();
Expand Down