Skip to content

Commit 76c608d

Browse files
authored
Merge pull request #1082 from su2code/feature_simd_numerics
Fix #1081
2 parents fd2fa75 + c3e8495 commit 76c608d

12 files changed

Lines changed: 135 additions & 124 deletions

File tree

Common/include/basic_types/datatype_structure.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#define FORCEINLINE inline
4141
#endif
4242

43-
#if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)
43+
#if defined(__GNUC__) || defined(__clang__)
4444
#define NEVERINLINE inline __attribute__((noinline))
4545
#else
4646
#define NEVERINLINE inline

Common/include/containers/C2DContainer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,12 @@ class C2DContainer :
519519
/*!
520520
* \brief Move ctor, implemented by base class (if fully static works as copy).
521521
*/
522-
C2DContainer(C2DContainer&&) noexcept(std::is_nothrow_move_constructible<Scalar>::value) = default;
522+
C2DContainer(C2DContainer&&) = default;
523523

524524
/*!
525525
* \brief Move assign operator, implemented by base class (if fully static works as copy).
526526
*/
527-
C2DContainer& operator= (C2DContainer&&) noexcept(std::is_nothrow_move_assignable<Scalar>::value) = default;
527+
C2DContainer& operator= (C2DContainer&&) = default;
528528

529529
/*!
530530
* \overload Set all entries to rhs value (syntax sugar, see "resize").

Common/include/mpi_structure.inl

Lines changed: 2 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -32,73 +32,6 @@
3232

3333
#ifdef HAVE_MPI
3434

35-
NEVERINLINE void CBaseMPIWrapper::Error(std::string ErrorMsg, std::string FunctionName){
36-
37-
/* Set MinRankError to Rank, as the error message is called on this rank. */
38-
MinRankError = Rank;
39-
int flag = 0;
40-
41-
#if MPI_VERSION >= 3
42-
/* Find out whether the error call is collective via MPI_Ibarrier. */
43-
Request barrierRequest;
44-
MPI_Ibarrier(currentComm, &barrierRequest);
45-
46-
/* Try to complete the non-blocking barrier call for a second. */
47-
double startTime = SU2_MPI::Wtime();
48-
while( true ) {
49-
50-
MPI_Test(&barrierRequest, &flag, MPI_STATUS_IGNORE);
51-
if( flag ) break;
52-
53-
double currentTime = SU2_MPI::Wtime();
54-
if(currentTime > startTime + 1.0) break;
55-
}
56-
#else
57-
/* MPI_Ibarrier function is not supported. Simply wait for one
58-
second to give other ranks the opportunity to reach this point. */
59-
#ifdef _MSC_VER
60-
_sleep(1);
61-
#else
62-
sleep(1);
63-
#endif
64-
#endif
65-
66-
if( flag ) {
67-
/* The barrier is completed and hence the error call is collective.
68-
Set MinRankError to 0. */
69-
MinRankError = 0;
70-
}
71-
else {
72-
/* The error call is not collective and the minimum rank must be
73-
determined by one sided communication. Loop over the lower numbered
74-
ranks to check if they participate in the error message. */
75-
for(int i=0; i<Rank; ++i) {
76-
77-
int MinRankErrorOther;
78-
MPI_Win_lock(MPI_LOCK_SHARED, i, 0, winMinRankError);
79-
MPI_Get(&MinRankErrorOther, 1, MPI_INT, i, 0, 1, MPI_INT, winMinRankError);
80-
MPI_Win_unlock(i, winMinRankError);
81-
82-
if(MinRankErrorOther < MinRankError) {
83-
MinRankError = MinRankErrorOther;
84-
break;
85-
}
86-
}
87-
}
88-
89-
/* Check if this rank must write the error message and do so. */
90-
if (Rank == MinRankError){
91-
std::cout << std::endl << std::endl;
92-
std::cout << "Error in \"" << FunctionName << "\": " << std::endl;
93-
std::cout << "-------------------------------------------------------------------------" << std::endl;
94-
std::cout << ErrorMsg << std::endl;
95-
std::cout << "------------------------------ Error Exit -------------------------------" << std::endl;
96-
std::cout << std::endl << std::endl;
97-
}
98-
Abort(currentComm, EXIT_FAILURE);
99-
}
100-
101-
10235
inline int CBaseMPIWrapper::GetRank(){
10336
return Rank;
10437
}
@@ -515,20 +448,9 @@ inline void CMediMPIWrapper::Waitany(int nrequests, Request *request,
515448
int *index, Status *status) {
516449
AMPI_Waitany(nrequests, request, index, status);
517450
}
518-
#endif
519-
#else // HAVE_MPI
451+
#endif // CODI
520452

521-
NEVERINLINE void CBaseMPIWrapper::Error(std::string ErrorMsg, std::string FunctionName){
522-
if (Rank == 0){
523-
std::cout << std::endl << std::endl;
524-
std::cout << "Error in \"" << FunctionName << "\": " << std::endl;
525-
std::cout << "-------------------------------------------------------------------------" << std::endl;
526-
std::cout << ErrorMsg << std::endl;
527-
std::cout << "------------------------------ Error Exit -------------------------------" << std::endl;
528-
std::cout << std::endl << std::endl;
529-
}
530-
Abort(currentComm, 0);
531-
}
453+
#else // HAVE_MPI
532454

533455
inline int CBaseMPIWrapper::GetRank(){
534456
return Rank;

Common/src/CConfig.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ void CConfig::SetConfig_Options() {
18141814
addBoolOption("USE_ACCURATE_FLUX_JACOBIANS", Use_Accurate_Jacobians, false);
18151815
/*!\brief CENTRAL_JACOBIAN_FIX_FACTOR \n DESCRIPTION: Improve the numerical properties (diagonal dominance) of the global Jacobian matrix, 3 to 4 is "optimum" (central schemes) \ingroup Config*/
18161816
addDoubleOption("CENTRAL_JACOBIAN_FIX_FACTOR", Cent_Jac_Fix_Factor, 4.0);
1817-
1817+
18181818
/*!\brief CONV_NUM_METHOD_ADJFLOW
18191819
* \n DESCRIPTION: Convective numerical method for the adjoint solver.
18201820
* \n OPTIONS: See \link Upwind_Map \endlink , \link Centered_Map \endlink. Note: not all methods are guaranteed to be implemented for the adjoint solver. \ingroup Config */
@@ -4659,7 +4659,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
46594659
nRough_Wall = nWall;
46604660
Roughness_Height = new su2double [nWall];
46614661
Kind_Wall = new unsigned short [nWall];
4662-
for (unsigned short iMarker = 0; iMarker < nMarker_HeatFlux; iMarker++) {
4662+
for (iMarker = 0; iMarker < nMarker_HeatFlux; iMarker++) {
46634663
Roughness_Height[iMarker] = 0.0;
46644664
Kind_Wall[iMarker] = SMOOTH;
46654665
}
@@ -5009,7 +5009,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
50095009
if (edgeColorGroupSize==0) edgeColorGroupSize = 1<<30;
50105010

50115011
/*--- Specifying a deforming surface requires a mesh deformation solver. ---*/
5012-
if (GetSurface_Movement(DEFORMING)) Deform_Mesh = true;
5012+
if (GetSurface_Movement(DEFORMING)) Deform_Mesh = true;
50135013

50145014
}
50155015

@@ -5042,7 +5042,7 @@ void CConfig::SetMarkers(unsigned short val_software) {
50425042
nMarker_CfgFile = nMarker_Euler + nMarker_FarField + nMarker_SymWall +
50435043
nMarker_PerBound + nMarker_NearFieldBound + nMarker_Fluid_InterfaceBound +
50445044
nMarker_CHTInterface + nMarker_Inlet + nMarker_Riemann + nMarker_Smoluchowski_Maxwell +
5045-
nMarker_Giles + nMarker_Outlet + nMarker_Isothermal +
5045+
nMarker_Giles + nMarker_Outlet + nMarker_Isothermal +
50465046
nMarker_HeatFlux +
50475047
nMarker_EngineInflow + nMarker_EngineExhaust + nMarker_Internal +
50485048
nMarker_Supersonic_Inlet + nMarker_Supersonic_Outlet + nMarker_Displacement + nMarker_Load +
@@ -5317,7 +5317,7 @@ void CConfig::SetMarkers(unsigned short val_software) {
53175317
Marker_CfgFile_KindBC[iMarker_CfgFile] = ISOTHERMAL;
53185318
iMarker_CfgFile++;
53195319
}
5320-
5320+
53215321
for (iMarker_Smoluchowski_Maxwell = 0; iMarker_Smoluchowski_Maxwell < nMarker_Smoluchowski_Maxwell; iMarker_Smoluchowski_Maxwell++) {
53225322
Marker_CfgFile_TagBound[iMarker_CfgFile] = Marker_Smoluchowski_Maxwell[iMarker_Smoluchowski_Maxwell];
53235323
Marker_CfgFile_KindBC[iMarker_CfgFile] = SMOLUCHOWSKI_MAXWELL;
@@ -5581,14 +5581,14 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) {
55815581
break;
55825582
case NEMO_EULER:
55835583
if (Kind_Regime == COMPRESSIBLE) cout << "Compressible two-temperature thermochemical non-equilibrium Euler equations." << endl;
5584-
if(Kind_FluidModel == USER_DEFINED_NONEQ){
5584+
if(Kind_FluidModel == USER_DEFINED_NONEQ){
55855585
if ((GasModel != "N2") && (GasModel != "AIR-5"))
55865586
SU2_MPI::Error("The GAS_MODEL given as input is not valid. Choose one of the options: N2, AIR-5.", CURRENT_FUNCTION);
55875587
}
55885588
break;
5589-
case NEMO_NAVIER_STOKES:
5589+
case NEMO_NAVIER_STOKES:
55905590
if (Kind_Regime == COMPRESSIBLE) cout << "Compressible two-temperature thermochemical non-equilibrium Navier-Stokes equations." << endl;
5591-
if(Kind_FluidModel == USER_DEFINED_NONEQ){
5591+
if(Kind_FluidModel == USER_DEFINED_NONEQ){
55925592
if ((GasModel != "N2") && (GasModel != "AIR-5"))
55935593
SU2_MPI::Error("The GAS_MODEL given as input is not valid. Choose one of the options: N2, AIR-5.", CURRENT_FUNCTION);
55945594
}
@@ -6384,7 +6384,7 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) {
63846384

63856385
if ((Kind_Solver == EULER) || (Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS) ||
63866386
(Kind_Solver == INC_EULER) || (Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS) ||
6387-
(Kind_Solver == NEMO_EULER) || (Kind_Solver == NEMO_NAVIER_STOKES) ||
6387+
(Kind_Solver == NEMO_EULER) || (Kind_Solver == NEMO_NAVIER_STOKES) ||
63886388
(Kind_Solver == DISC_ADJ_INC_EULER) || (Kind_Solver == DISC_ADJ_INC_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_INC_RANS) ||
63896389
(Kind_Solver == DISC_ADJ_EULER) || (Kind_Solver == DISC_ADJ_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_RANS) ||
63906390
(Kind_Solver == DISC_ADJ_FEM_EULER) || (Kind_Solver == DISC_ADJ_FEM_NS) || (Kind_Solver == DISC_ADJ_FEM_RANS)) {
@@ -9790,7 +9790,7 @@ void CConfig::SetMultizone(CConfig *driver_config, CConfig **config_container){
97909790
switch (config_container[iZone]->GetKind_Solver()) {
97919791
case EULER: case NAVIER_STOKES: case RANS:
97929792
case INC_EULER: case INC_NAVIER_STOKES: case INC_RANS:
9793-
case NEMO_EULER: case NEMO_NAVIER_STOKES:
9793+
case NEMO_EULER: case NEMO_NAVIER_STOKES:
97949794
fluid_zone = true;
97959795
break;
97969796
case FEM_ELASTICITY:

Common/src/mpi_structure.cpp

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* SU2 Project Website: https://su2code.github.io
88
*
9-
* The SU2 Project is maintained by the SU2 Foundation
9+
* The SU2 Project is maintained by the SU2 Foundation
1010
* (http://su2foundation.org)
1111
*
1212
* Copyright 2012-2020, SU2 Contributors (cf. AUTHORS.md)
@@ -35,6 +35,85 @@ CBaseMPIWrapper::Comm CBaseMPIWrapper::currentComm = MPI_COMM_WORLD;
3535
int CBaseMPIWrapper::MinRankError;
3636
bool CBaseMPIWrapper::winMinRankErrorInUse = false;
3737
CBaseMPIWrapper::Win CBaseMPIWrapper::winMinRankError;
38+
39+
void CBaseMPIWrapper::Error(std::string ErrorMsg, std::string FunctionName){
40+
41+
/* Set MinRankError to Rank, as the error message is called on this rank. */
42+
MinRankError = Rank;
43+
int flag = 0;
44+
45+
#if MPI_VERSION >= 3
46+
/* Find out whether the error call is collective via MPI_Ibarrier. */
47+
Request barrierRequest;
48+
MPI_Ibarrier(currentComm, &barrierRequest);
49+
50+
/* Try to complete the non-blocking barrier call for a second. */
51+
double startTime = SU2_MPI::Wtime();
52+
while( true ) {
53+
54+
MPI_Test(&barrierRequest, &flag, MPI_STATUS_IGNORE);
55+
if( flag ) break;
56+
57+
double currentTime = SU2_MPI::Wtime();
58+
if(currentTime > startTime + 1.0) break;
59+
}
60+
#else
61+
/* MPI_Ibarrier function is not supported. Simply wait for one
62+
second to give other ranks the opportunity to reach this point. */
63+
#ifdef _MSC_VER
64+
_sleep(1);
65+
#else
66+
sleep(1);
67+
#endif
68+
#endif
69+
70+
if( flag ) {
71+
/* The barrier is completed and hence the error call is collective.
72+
Set MinRankError to 0. */
73+
MinRankError = 0;
74+
}
75+
else {
76+
/* The error call is not collective and the minimum rank must be
77+
determined by one sided communication. Loop over the lower numbered
78+
ranks to check if they participate in the error message. */
79+
for(int i=0; i<Rank; ++i) {
80+
81+
int MinRankErrorOther;
82+
MPI_Win_lock(MPI_LOCK_SHARED, i, 0, winMinRankError);
83+
MPI_Get(&MinRankErrorOther, 1, MPI_INT, i, 0, 1, MPI_INT, winMinRankError);
84+
MPI_Win_unlock(i, winMinRankError);
85+
86+
if(MinRankErrorOther < MinRankError) {
87+
MinRankError = MinRankErrorOther;
88+
break;
89+
}
90+
}
91+
}
92+
93+
/* Check if this rank must write the error message and do so. */
94+
if (Rank == MinRankError){
95+
std::cout << std::endl << std::endl;
96+
std::cout << "Error in \"" << FunctionName << "\": " << std::endl;
97+
std::cout << "-------------------------------------------------------------------------" << std::endl;
98+
std::cout << ErrorMsg << std::endl;
99+
std::cout << "------------------------------ Error Exit -------------------------------" << std::endl;
100+
std::cout << std::endl << std::endl;
101+
}
102+
Abort(currentComm, EXIT_FAILURE);
103+
}
104+
#else // HAVE_MPI
105+
106+
void CBaseMPIWrapper::Error(std::string ErrorMsg, std::string FunctionName){
107+
if (Rank == 0){
108+
std::cout << std::endl << std::endl;
109+
std::cout << "Error in \"" << FunctionName << "\": " << std::endl;
110+
std::cout << "-------------------------------------------------------------------------" << std::endl;
111+
std::cout << ErrorMsg << std::endl;
112+
std::cout << "------------------------------ Error Exit -------------------------------" << std::endl;
113+
std::cout << std::endl << std::endl;
114+
}
115+
Abort(currentComm, 0);
116+
}
38117
#endif
39118

40119
#ifdef HAVE_MPI
@@ -43,4 +122,4 @@ MediTypes* mediTypes;
43122
#include <medi/medi.cpp>
44123
#endif // defined CODI_REVERSE_TYPE || defined CODI_FORWARD_TYPE
45124

46-
#endif// HAVE_MPI
125+
#endif // HAVE_MPI

SU2_CFD/include/numerics/CNumerics.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class CNumerics {
227227

228228
/* Supporting data structures for the eigenspace perturbation for UQ methodology */
229229
su2double **A_ij, **newA_ij, **Eig_Vec, **New_Eig_Vec, **Corners;
230-
su2double *Eig_Val, *Barycentric_Coord, *New_Coord;
230+
su2double *Eig_Val, *Barycentric_Coord, *New_Coord;
231231

232232
public:
233233
/*!
@@ -777,7 +777,7 @@ class CNumerics {
777777
void GetInviscidProjFlux(const su2double *val_density, const su2double *val_velocity,
778778
const su2double *val_pressure, const su2double *val_enthalpy,
779779
const su2double *val_normal, su2double *val_Proj_Flux) const;
780-
780+
781781
/*!
782782
* \brief Compute the projected inviscid flux vector for incompresible simulations
783783
* \param[in] val_density - Pointer to the density.
@@ -1168,7 +1168,7 @@ class CNumerics {
11681168
* \return A lightweight const-view (read-only) of the residual/flux and Jacobians.
11691169
*/
11701170
inline virtual ResidualType<> ComputeVibRelaxation(const CConfig* config) { return ResidualType<>(nullptr,nullptr,nullptr); }
1171-
1171+
11721172
/*!
11731173
* \brief Calculation of the chemistry source term
11741174
* \param[in] config - Definition of the particular problem.
@@ -1381,15 +1381,15 @@ class CNumerics {
13811381
*/
13821382
static void tql2(su2double **V, su2double *d, su2double *e, unsigned short n);
13831383

1384-
virtual inline void SetdPdU(su2double *val_dPdU_i, su2double *val_dPdU_j) { }
1385-
1386-
virtual inline void SetdTdU(su2double *val_dTdU_i, su2double *val_dTdU_j) { }
1387-
1388-
virtual inline void SetdTvedU(su2double *val_dTvedU_i, su2double *val_dTvedU_j) { }
1389-
1390-
virtual inline void SetEve(su2double *val_Eve_i, su2double *val_Eve_j) { }
1391-
1392-
virtual inline void SetCvve(su2double *val_Cvve_i, su2double *val_Cvve_j) { }
1384+
virtual inline void SetdPdU(su2double *val_dPdU_i, su2double *val_dPdU_j) { }
1385+
1386+
virtual inline void SetdTdU(su2double *val_dTdU_i, su2double *val_dTdU_j) { }
1387+
1388+
virtual inline void SetdTvedU(su2double *val_dTvedU_i, su2double *val_dTvedU_j) { }
1389+
1390+
virtual inline void SetEve(su2double *val_Eve_i, su2double *val_Eve_j) { }
1391+
1392+
virtual inline void SetCvve(su2double *val_Cvve_i, su2double *val_Cvve_j) { }
13931393

13941394
};
13951395

SU2_CFD/include/numerics_simd/flow/convection/centered.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ class CCenteredBase : public Base {
175175

176176
/*--- Stop preaccumulation. ---*/
177177

178-
AD::SetPreaccOut(flux, nVar, Double::Size);
179-
AD::EndPreacc();
178+
stopPreacc(flux);
180179

181180
/*--- Update the vector and system matrix. ---*/
182181

SU2_CFD/include/numerics_simd/flow/convection/roe.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ class CRoeBase : public Base {
204204

205205
/*--- Stop preaccumulation. ---*/
206206

207-
AD::SetPreaccOut(flux, nVar, Double::Size);
208-
AD::EndPreacc();
207+
stopPreacc(flux);
209208

210209
/*--- Update the vector and system matrix. ---*/
211210

SU2_CFD/include/numerics_simd/util.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ FORCEINLINE MatrixDbl<nRows,nCols> gatherVariables(Int iPoint, const Container&
145145
return x;
146146
}
147147

148+
/*!
149+
* \brief Stop the AD preaccumulation.
150+
*/
151+
template<size_t nVar>
152+
FORCEINLINE void stopPreacc(VectorDbl<nVar>& x) {
153+
AD::SetPreaccOut(x, nVar, Double::Size);
154+
AD::EndPreacc();
155+
}
156+
148157
/*!
149158
* \brief Distance vector, from point i to point j.
150159
*/

externals/cgns/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if build_machine.system() == 'windows'
1+
if build_machine.system() == 'windows' or meson.get_compiler('cpp').get_id() == 'intel'
22
cgns_default_warnings = []
33
else
44
cgns_default_warnings = ['-Wno-unused-result']

0 commit comments

Comments
 (0)