Skip to content

Commit b475855

Browse files
authored
Use better compiler optimization options by default (#2779)
* use good defaults * swig fix * more warnings * more warnings * one more warning, no arch in tsan tests * not all runner are equal I guess * start updating tests, consistent flags for different Eigen's * [skip ci] * file diffs * try again
1 parent c3ab015 commit b475855

22 files changed

Lines changed: 563 additions & 550 deletions

File tree

.github/workflows/regression.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@ jobs:
2626
config_set: [BaseMPI, ReverseMPI, ForwardMPI, BaseNoMPI, ReverseNoMPI, ForwardNoMPI, ReverseTagNoMPI, BaseOMP, ReverseOMP, ForwardOMP]
2727
include:
2828
- config_set: BaseMPI
29-
flags: '-Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2'
29+
flags: '-Dcpu-arch=skylake -Denable-pywrapper=true -Denable-coolprop=true -Denable-mpp=true -Dinstall-mpp=true -Denable-mlpcpp=true -Denable-tests=true --warnlevel=2'
3030
- config_set: ReverseMPI
31-
flags: '-Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true -Denable-mlpcpp=true --warnlevel=3 --werror'
31+
flags: '-Dcpu-arch=skylake -Denable-autodiff=true -Denable-normal=false -Denable-pywrapper=true -Denable-tests=true -Denable-mlpcpp=true --warnlevel=3 --werror'
3232
- config_set: ForwardMPI
33-
flags: '-Denable-directdiff=true -Denable-normal=false -Denable-tests=true -Denable-mlpcpp=true --warnlevel=3 --werror'
33+
flags: '-Dcpu-arch=skylake -Denable-directdiff=true -Denable-normal=false -Denable-tests=true -Denable-mlpcpp=true --warnlevel=3 --werror'
3434
- config_set: BaseNoMPI
35-
flags: '-Denable-pywrapper=true -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true -Denable-tests=true --warnlevel=3 --werror'
35+
flags: '-Dcpu-arch=skylake -Denable-pywrapper=true -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true -Denable-tests=true --warnlevel=3 --werror'
3636
- config_set: ReverseNoMPI
37-
flags: '-Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror'
37+
flags: '-Dcpu-arch=skylake -Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror'
3838
- config_set: ForwardNoMPI
39-
flags: '-Denable-directdiff=true -Denable-normal=false -Dwith-mpi=disabled -Denable-tests=true --warnlevel=3 --werror'
39+
flags: '-Dcpu-arch=skylake -Denable-directdiff=true -Denable-normal=false -Dwith-mpi=disabled -Denable-tests=true --warnlevel=3 --werror'
4040
- config_set: ReverseTagNoMPI
41-
flags: '-Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror -Dcodi-tape=Tag'
41+
flags: '-Dcpu-arch=skylake -Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled -Denable-pywrapper=true -Denable-tests=true --warnlevel=3 --werror -Dcodi-tape=Tag'
4242
- config_set: BaseOMP
43-
flags: '-Dwith-omp=true -Denable-mixedprec=true -Denable-pywrapper=true -Denable-tecio=false --warnlevel=3 --werror'
43+
flags: '-Dcpu-arch=skylake -Dwith-omp=true -Denable-mixedprec=true -Denable-pywrapper=true -Denable-tecio=false --warnlevel=3 --werror'
4444
- config_set: ReverseOMP
45-
flags: '-Denable-autodiff=true -Denable-normal=false -Dwith-omp=true -Denable-mixedprec=true -Denable-pywrapper=true -Denable-tecio=false --warnlevel=3 --werror'
45+
flags: '-Dcpu-arch=skylake -Denable-autodiff=true -Denable-normal=false -Dwith-omp=true -Denable-mixedprec=true -Denable-pywrapper=true -Denable-tecio=false --warnlevel=3 --werror'
4646
- config_set: ForwardOMP
47-
flags: '-Denable-directdiff=true -Denable-normal=false -Dwith-omp=true -Denable-mixedprec=true -Denable-pywrapper=true -Denable-tecio=false --warnlevel=3 --werror'
47+
flags: '-Dcpu-arch=skylake -Denable-directdiff=true -Denable-normal=false -Dwith-omp=true -Denable-mixedprec=true -Denable-pywrapper=true -Denable-tecio=false --warnlevel=3 --werror'
4848
runs-on: ${{ inputs.runner || 'ubuntu-latest' }}
4949
steps:
5050
- name: Cache Object Files
@@ -83,11 +83,11 @@ jobs:
8383
config_set: [BaseOMP-tsan, ReverseOMP-tsan] #ForwardOMP-tsan
8484
include:
8585
- config_set: BaseOMP-tsan
86-
flags: '--buildtype=debugoptimized -Dwith-omp=true -Denable-mixedprec=true -Denable-tecio=false --warnlevel=3'
86+
flags: '--buildtype=debugoptimized -Dcpu-arch=skylake -Dwith-omp=true -Denable-mixedprec=true -Denable-tecio=false --warnlevel=3'
8787
- config_set: ReverseOMP-tsan
88-
flags: '--buildtype=debugoptimized -Denable-autodiff=true -Denable-normal=false -Dwith-omp=true -Denable-mixedprec=true -Denable-tecio=false --warnlevel=3'
88+
flags: '--buildtype=debugoptimized -Dcpu-arch=skylake -Denable-autodiff=true -Denable-normal=false -Dwith-omp=true -Denable-mixedprec=true -Denable-tecio=false --warnlevel=3'
8989
#- config_set: ForwardOMP-tsan
90-
# flags: '--buildtype=debug -Denable-directdiff=true -Denable-normal=false -Dwith-omp=true -Denable-mixedprec=true -Denable-pywrapper=true -Denable-tecio=false --warnlevel=3 --werror'
90+
# flags: '--buildtype=debug -Dcpu-arch=skylake -Denable-directdiff=true -Denable-normal=false -Dwith-omp=true -Denable-mixedprec=true -Denable-pywrapper=true -Denable-tecio=false --warnlevel=3 --werror'
9191
runs-on: ${{ inputs.runner || 'ubuntu-latest' }}
9292
steps:
9393
- name: Cache Object Files
@@ -125,9 +125,9 @@ jobs:
125125
config_set: [BaseNoMPI-asan, ReverseNoMPI-asan]
126126
include:
127127
- config_set: BaseNoMPI-asan
128-
flags: '--buildtype=debugoptimized -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true --warnlevel=3 --werror'
128+
flags: '--buildtype=debugoptimized -Dcpu-arch=skylake -Denable-openblas=true -Dwith-mpi=disabled -Denable-mlpcpp=true --warnlevel=3 --werror'
129129
- config_set: ReverseNoMPI-asan
130-
flags: '--buildtype=debugoptimized --optimization=1 -Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled --warnlevel=3 --werror'
130+
flags: '--buildtype=debugoptimized -Dcpu-arch=skylake --optimization=1 -Denable-autodiff=true -Denable-normal=false -Dwith-mpi=disabled --warnlevel=3 --werror'
131131
runs-on: ${{ inputs.runner || 'ubuntu-latest' }}
132132
steps:
133133
- name: Cache Object Files

.github/workflows/release-management.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
os_bin: [macos64-omp, macos64-mpi, linux64-omp, linux64-mpi, win64-omp, win64-mpi]
15+
os_bin: [macos64, macos64-mpi, linux64-omp, linux64-mpi, win64-omp, win64-mpi]
1616
include:
1717
- os_bin: win64-omp
18-
flags: '-Dwith-omp=true -Dwith-mpi=disabled --cross-file=/hostfiles/hostfile_windows'
18+
flags: '-Dcpu-arch=haswell -Dwith-omp=true -Dwith-mpi=disabled --cross-file=/hostfiles/hostfile_windows'
1919
- os_bin: win64-mpi
20-
flags: '-Dcustom-mpi=true --cross-file=/hostfiles/hostfile_windows_mpi'
21-
- os_bin: macos64-omp
22-
flags: '-Dwith-omp=true -Dwith-mpi=disabled --cross-file=/hostfiles/hostfile_darwin'
20+
flags: '-Dcpu-arch=haswell -Dcustom-mpi=true --cross-file=/hostfiles/hostfile_windows_mpi'
21+
- os_bin: macos64
22+
flags: '-Dcpu-arch= -Dwith-mpi=disabled --cross-file=/hostfiles/hostfile_darwin'
2323
- os_bin: macos64-mpi
24-
flags: '-Dcustom-mpi=true --cross-file=/hostfiles/hostfile_darwin_mpi'
24+
flags: '-Dcpu-arch= -Dcustom-mpi=true --cross-file=/hostfiles/hostfile_darwin_mpi'
2525
- os_bin: linux64-omp
26-
flags: '-Dwith-omp=true -Dwith-mpi=disabled -Dstatic-cgns-deps=true --cross-file=/hostfiles/hostfile_linux'
26+
flags: '-Dcpu-arch=haswell -Dwith-omp=true -Dwith-mpi=disabled -Dstatic-cgns-deps=true --cross-file=/hostfiles/hostfile_linux'
2727
- os_bin: linux64-mpi
28-
flags: '-Dcustom-mpi=true --cross-file=/hostfiles/hostfile_linux_mpi'
28+
flags: '-Dcpu-arch=haswell -Dcustom-mpi=true --cross-file=/hostfiles/hostfile_linux_mpi'
2929
runs-on: ubuntu-latest
3030
steps:
3131
- name: Cache Object Files

SU2_CFD/include/solvers/CHeatSolver.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ class CHeatSolver final : public CScalarSolver<CHeatVariable> {
8888
LinSysRes(iPoint, 0) -= thermal_diffusivity * dTdn * Area;
8989

9090
if (implicit) {
91-
su2double Jacobian_i[] = {-thermal_diffusivity / dist_ij * Area};
92-
Jacobian.SubtractBlock2Diag(iPoint, &Jacobian_i);
91+
su2double Jacobian_i[1][1] = {{-thermal_diffusivity / dist_ij * Area}};
92+
Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i);
9393
}
9494
}
9595

SU2_CFD/src/solvers/CGradientSmoothingSolver.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,6 @@ void CGradientSmoothingSolver::Compute_Surface_Residual(CGeometry* geometry, con
550550
int EL_KIND = 0;
551551
std::array<unsigned long, MAXNNODE_2D> indexNode;
552552
std::array<unsigned long, MAXNNODE_2D> indexVertex;
553-
su2double Weight, Jac_X, norm, val_Coord, normalSens = 0.0, Residual=0.0;
554-
su2double normal[MAXNDIM];
555553

556554
for (iElem = 0; iElem < geometry->GetnElem_Bound(val_marker); iElem++) {
557555
/*--- Identify the kind of boundary element ---*/
@@ -562,7 +560,7 @@ void CGradientSmoothingSolver::Compute_Surface_Residual(CGeometry* geometry, con
562560
indexNode[iNode] = geometry->bound[val_marker][iElem]->GetNode(iNode);
563561

564562
for (iDim = 0; iDim < nDim; iDim++) {
565-
val_Coord = Get_ValCoord(geometry, indexNode[iNode], iDim);
563+
const su2double val_Coord = Get_ValCoord(geometry, indexNode[iNode], iDim);
566564
element_container[GRAD_TERM][EL_KIND]->SetRef_Coord(iNode, iDim, val_Coord);
567565
}
568566
}
@@ -575,31 +573,27 @@ void CGradientSmoothingSolver::Compute_Surface_Residual(CGeometry* geometry, con
575573
}
576574
}
577575

578-
element_container[GRAD_TERM][EL_KIND]
579-
->ClearElement(); /*--- Restarts the element: avoids adding over previous results in other elements --*/
576+
/*--- Restarts the element: avoids adding over previous results in other elements --*/
577+
element_container[GRAD_TERM][EL_KIND]->ClearElement();
580578
element_container[GRAD_TERM][EL_KIND]->ComputeGrad_SurfaceEmbedded();
581579
unsigned int nGauss = element_container[GRAD_TERM][EL_KIND]->GetnGaussPoints();
582580

583581
for (unsigned int iGauss = 0; iGauss < nGauss; iGauss++) {
584-
Weight = element_container[GRAD_TERM][EL_KIND]->GetWeight(iGauss);
585-
Jac_X = element_container[GRAD_TERM][EL_KIND]->GetJ_X(iGauss);
582+
const su2double Weight = element_container[GRAD_TERM][EL_KIND]->GetWeight(iGauss);
583+
const su2double Jac_X = element_container[GRAD_TERM][EL_KIND]->GetJ_X(iGauss);
586584

587585
for (unsigned int iNode = 0; iNode < nNodes; iNode++) {
586+
su2double normal[MAXNDIM] = {};
588587
geometry->vertex[val_marker][indexVertex[iNode]]->GetNormal(normal);
589-
norm = GeometryToolbox::Norm(nDim, normal);
588+
const su2double norm = GeometryToolbox::Norm(nDim, normal);
590589
for (iDim = 0; iDim < nDim; iDim++) {
591590
normal[iDim] = normal[iDim] / norm;
592591
}
593-
592+
su2double normalSens = 0;
594593
for (iDim = 0; iDim < nDim; iDim++) {
595594
normalSens += normal[iDim] * nodes->GetSensitivity(indexNode[iNode], iDim);
596595
}
597-
598-
Residual += Weight * Jac_X * element_container[GRAD_TERM][EL_KIND]->GetNi(iNode, iGauss) * normalSens;
599-
LinSysRes.AddBlock(indexNode[iNode], &Residual);
600-
601-
Residual = 0;
602-
normalSens = 0;
596+
LinSysRes(indexNode[iNode], 0) += Weight * Jac_X * element_container[GRAD_TERM][EL_KIND]->GetNi(iNode, iGauss) * normalSens;
603597
}
604598
}
605599
}

SU2_CFD/src/solvers/CHeatSolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ void CHeatSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solv
594594
HeatFlux = HeatFluxDensity * Area;
595595

596596
if (implicit) {
597-
su2double Jacobian_i[] = {-thermal_diffusivity*Area};
598-
Jacobian.SubtractBlock2Diag(iPoint, &Jacobian_i);
597+
su2double Jacobian_i[1][1] = {{-thermal_diffusivity*Area}};
598+
Jacobian.SubtractBlock2Diag(iPoint, Jacobian_i);
599599
}
600600
}
601601
else {

SU2_CFD/src/solvers/CTurbSASolver.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,8 @@ void CTurbSASolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_conta
503503
su2double coeff = (nu_total/sigma);
504504
su2double RoughWallBC = nodes->GetSolution(iPoint,0)/(0.03*Roughness_Height);
505505

506-
su2double Res_Wall;// = new su2double [nVar];
507-
Res_Wall = coeff*RoughWallBC*Area;
508-
LinSysRes.SubtractBlock(iPoint, &Res_Wall);
506+
su2double Res_Wall = coeff*RoughWallBC*Area;
507+
LinSysRes(iPoint, 0) -= Res_Wall;
509508

510509
su2double Jacobian_i = (laminar_viscosity /density *Area)/(0.03*Roughness_Height*sigma);
511510
Jacobian_i += 2.0*RoughWallBC*Area/sigma;

SU2_PY/pySU2/meson.build

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@ else
1919
mpi4py_include = ''
2020
endif
2121

22+
su2_swig_args = []
23+
foreach arg : su2_cpp_args
24+
if not arg.startswith('-f') and not arg.startswith('-m')
25+
su2_swig_args += arg
26+
endif
27+
endforeach
28+
2229
swig_gen = generator(
2330
swig,
2431
output: ['@BASENAME@.cxx'],
25-
arguments: su2_cpp_args +
32+
arguments: su2_swig_args +
2633
[ '-c++', '-python', '-I'+mpi4py_include, '-outdir', meson.current_build_dir(), '-o', './@OUTPUT@', '@INPUT@'],
2734
depfile: '@BASENAME@.d',
2835
)
@@ -43,7 +50,7 @@ if get_option('enable-normal')
4350
],
4451
install: true,
4552
include_directories : mpi4py_include,
46-
cpp_args : [default_warning_flags,su2_cpp_args],
53+
cpp_args : [default_warning_flags, su2_swig_args],
4754
name_prefix : '',
4855
install_dir: 'bin'
4956
)
@@ -62,7 +69,7 @@ if get_option('enable-autodiff')
6269
],
6370
install: true,
6471
include_directories : mpi4py_include,
65-
cpp_args : [default_warning_flags, su2_cpp_args, codi_rev_args],
72+
cpp_args : [default_warning_flags, su2_swig_args, codi_rev_args],
6673
name_prefix : '',
6774
install_dir: 'bin'
6875
)
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
INDEX GRAD
2-
0 -4.570880056076276e-04
3-
1 -2.401474032110094e-04
4-
2 -9.134741314806565e-05
5-
3 -1.628103414800329e-05
6-
4 -1.741046937496715e-05
7-
5 -9.462481743926707e-05
8-
6 -2.452469742444662e-04
9-
7 -4.635498236376295e-04
2+
0 -4.570880237875418e-04
3+
1 -2.401474145411196e-04
4+
2 -9.134741927897237e-05
5+
3 -1.628103641919142e-05
6+
4 -1.741046901352254e-05
7+
5 -9.462481564764888e-05
8+
6 -2.452469723327466e-04
9+
7 -4.635498231799566e-04

TestCases/fea_topology/grad_ref_node.dat.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6157,7 +6157,7 @@
61576157
-9.57383e-11
61586158
-2.60763e-10
61596159
-2.54078e-10
6160-
-1.57599e-10
6160+
-1.57598e-10
61616161
-8.68931e-12
61626162
-4.26927e-13
61636163
0

0 commit comments

Comments
 (0)