Skip to content

Commit 10f2e15

Browse files
committed
reduce size of gradient for output, print global tape memory stats
1 parent 4ba9b11 commit 10f2e15

4 files changed

Lines changed: 43 additions & 21 deletions

File tree

Common/src/geometry/CPhysicalGeometry.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7662,10 +7662,9 @@ void CPhysicalGeometry::SetBoundControlVolume(const CConfig *config, unsigned sh
76627662
vertex[iMarker][iVertex]->SetZeroValues();
76637663
}
76647664

7665-
SU2_OMP_MASTER {
7666-
76677665
/*--- Loop over all the boundary elements ---*/
76687666

7667+
SU2_OMP_FOR_DYN(1)
76697668
for (unsigned short iMarker = 0; iMarker < nMarker; iMarker++) {
76707669
for (unsigned long iElem = 0; iElem < nElem_Bound[iMarker]; iElem++) {
76717670

@@ -7726,7 +7725,6 @@ void CPhysicalGeometry::SetBoundControlVolume(const CConfig *config, unsigned sh
77267725
AD::EndPreacc();
77277726
}
77287727
}
7729-
} SU2_OMP_BARRIER
77307728

77317729
/*--- Check if there is a normal with null area ---*/
77327730

SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,20 @@ void CDiscAdjMultizoneDriver::SetRecording(unsigned short kind_recording, Kind_T
564564
}
565565
}
566566

567-
if (rank == MASTER_NODE) {
568-
if(kind_recording != NONE && config_container[record_zone]->GetWrt_AD_Statistics()) {
569-
AD::PrintStatistics();
567+
if (kind_recording != NONE && driver_config->GetWrt_AD_Statistics()) {
568+
if (rank == MASTER_NODE) AD::PrintStatistics();
569+
#ifdef CODI_REVERSE_TYPE
570+
if (size > SINGLE_NODE) {
571+
su2double myMem = AD::globalTape.getTapeValues().getUsedMemorySize(), totMem = 0.0;
572+
SU2_MPI::Allreduce(&myMem, &totMem, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
573+
if (rank == MASTER_NODE) {
574+
cout << "MPI\n";
575+
cout << "-------------------------------------\n";
576+
cout << " Total memory used : " << totMem << " MB\n";
577+
cout << "-------------------------------------\n" << endl;
578+
}
570579
}
571-
cout << "-------------------------------------------------------------------------\n" << endl;
580+
#endif
572581
}
573582

574583
AD::StopRecording();

SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,20 @@ void CDiscAdjSinglezoneDriver::SetRecording(unsigned short kind_recording){
291291

292292
SetObjFunction();
293293

294-
if (rank == MASTER_NODE && kind_recording != NONE && config_container[ZONE_0]->GetWrt_AD_Statistics()) {
295-
AD::PrintStatistics();
296-
cout << "-------------------------------------------------------------------------\n" << endl;
294+
if (kind_recording != NONE && config_container[ZONE_0]->GetWrt_AD_Statistics()) {
295+
if (rank == MASTER_NODE) AD::PrintStatistics();
296+
#ifdef CODI_REVERSE_TYPE
297+
if (size > SINGLE_NODE) {
298+
su2double myMem = AD::globalTape.getTapeValues().getUsedMemorySize(), totMem = 0.0;
299+
SU2_MPI::Allreduce(&myMem, &totMem, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
300+
if (rank == MASTER_NODE) {
301+
cout << "MPI\n";
302+
cout << "-------------------------------------\n";
303+
cout << " Total memory used : " << totMem << " MB\n";
304+
cout << "-------------------------------------\n" << endl;
305+
}
306+
}
307+
#endif
297308
}
298309

299310
AD::StopRecording();

SU2_CFD/src/solvers/CNSSolver.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C
110110

111111
CommonPreprocessing(geometry, solver_container, config, iMesh, iRKStep, RunTime_EqSystem, Output);
112112

113-
/*--- Compute gradient for MUSCL reconstruction. ---*/
113+
/*--- Compute gradient for MUSCL reconstruction, for output (i.e. the
114+
turbulence solver) only density and velocity are needed ---*/
115+
116+
const auto nPrimVarGrad_bak = nPrimVarGrad;
117+
if (Output) nPrimVarGrad = 1+nDim;
114118

115119
if (config->GetReconstructionGradientRequired() && (iMesh == MESH_0)) {
116120
switch (config->GetKind_Gradient_Method_Recon()) {
@@ -132,6 +136,8 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C
132136
SetPrimitive_Gradient_LS(geometry, config);
133137
}
134138

139+
nPrimVarGrad = nPrimVarGrad_bak;
140+
135141
/*--- Compute the limiter in case we need it in the turbulence model or to limit the
136142
* viscous terms (check this logic with JST and 2nd order turbulence model) ---*/
137143

@@ -150,21 +156,17 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C
150156

151157
nodes->SetVorticity_StrainMag();
152158

159+
/*--- Min and Max are not really differentiable ---*/
160+
const bool wasActive = AD::BeginPassive();
161+
153162
su2double strainMax = 0.0, omegaMax = 0.0;
154163

155164
SU2_OMP(for schedule(static,omp_chunk_size) nowait)
156165
for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) {
157-
158-
su2double StrainMag = nodes->GetStrainMag(iPoint);
159-
const su2double* Vorticity = nodes->GetVorticity(iPoint);
160-
su2double Omega = sqrt(Vorticity[0]*Vorticity[0]+ Vorticity[1]*Vorticity[1]+ Vorticity[2]*Vorticity[2]);
161-
162-
strainMax = max(strainMax, StrainMag);
163-
omegaMax = max(omegaMax, Omega);
164-
166+
strainMax = max(strainMax, nodes->GetStrainMag(iPoint));
167+
omegaMax = max(omegaMax, GeometryToolbox::Norm(3, nodes->GetVorticity(iPoint)));
165168
}
166-
SU2_OMP_CRITICAL
167-
{
169+
SU2_OMP_CRITICAL {
168170
StrainMag_Max = max(StrainMag_Max, strainMax);
169171
Omega_Max = max(Omega_Max, omegaMax);
170172
}
@@ -182,6 +184,8 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C
182184
SU2_OMP_BARRIER
183185
}
184186

187+
AD::EndPassive(wasActive);
188+
185189
/*--- Compute the TauWall from the wall functions ---*/
186190

187191
if (wall_functions) {

0 commit comments

Comments
 (0)