Skip to content

Commit bc39e7e

Browse files
authored
Merge pull request #1022 from su2code/feature_simd_numerics
Vectorized (SIMD) Numerical Schemes
2 parents e6cff74 + 6ea6116 commit bc39e7e

90 files changed

Lines changed: 4805 additions & 1355 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Common/include/CConfig.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
#include <map>
4444
#include <assert.h>
4545

46-
#include "./option_structure.hpp"
47-
#include "./toolboxes/C2DContainer.hpp"
46+
#include "option_structure.hpp"
47+
#include "containers/container_decorators.hpp"
4848

4949
#ifdef HAVE_CGNS
5050
#include "cgnslib.h"
@@ -419,6 +419,7 @@ class CConfig {
419419
su2double *RK_Alpha_Step; /*!< \brief Runge-Kutta beta coefficients. */
420420

421421
unsigned short nQuasiNewtonSamples; /*!< \brief Number of samples used in quasi-Newton solution methods. */
422+
bool UseVectorization; /*!< \brief Whether to use vectorized numerics schemes. */
422423

423424
unsigned short nMGLevels; /*!< \brief Number of multigrid levels (coarse levels). */
424425
unsigned short nCFL; /*!< \brief Number of CFL, one for each multigrid level. */
@@ -591,10 +592,10 @@ class CConfig {
591592
*Kappa_AdjFlow, /*!< \brief Numerical dissipation coefficients for the adjoint flow equations. */
592593
*Kappa_Heat; /*!< \brief Numerical dissipation coefficients for the (fvm) heat equation. */
593594
su2double* FFD_Axis; /*!< \brief Numerical dissipation coefficients for the adjoint equations. */
594-
su2double Kappa_1st_AdjFlow, /*!< \brief JST 1st order dissipation coefficient for adjoint flow equations (coarse multigrid levels). */
595+
su2double Kappa_1st_AdjFlow, /*!< \brief Lax 1st order dissipation coefficient for adjoint flow equations (coarse multigrid levels). */
595596
Kappa_2nd_AdjFlow, /*!< \brief JST 2nd order dissipation coefficient for adjoint flow equations. */
596597
Kappa_4th_AdjFlow, /*!< \brief JST 4th order dissipation coefficient for adjoint flow equations. */
597-
Kappa_1st_Flow, /*!< \brief JST 1st order dissipation coefficient for flow equations (coarse multigrid levels). */
598+
Kappa_1st_Flow, /*!< \brief Lax 1st order dissipation coefficient for flow equations (coarse multigrid levels). */
598599
Kappa_2nd_Flow, /*!< \brief JST 2nd order dissipation coefficient for flow equations. */
599600
Kappa_4th_Flow, /*!< \brief JST 4th order dissipation coefficient for flow equations. */
600601
Kappa_2nd_Heat, /*!< \brief 2nd order dissipation coefficient for heat equation. */
@@ -1164,7 +1165,7 @@ class CConfig {
11641165
ionization; /*!< \brief Flag for determining if free electron gas is in the mixture. */
11651166
string GasModel, /*!< \brief Gas Model. */
11661167
*Wall_Catalytic; /*!< \brief Pointer to catalytic walls. */
1167-
1168+
11681169
/*!
11691170
* \brief Set the default values of config options not set in the config file using another config object.
11701171
* \param config - Config object to use the default values from.
@@ -4114,6 +4115,11 @@ class CConfig {
41144115
*/
41154116
unsigned short GetnQuasiNewtonSamples(void) const { return nQuasiNewtonSamples; }
41164117

4118+
/*!
4119+
* \brief Get whether to use vectorized numerics (if available).
4120+
*/
4121+
bool GetUseVectorization(void) const { return UseVectorization; }
4122+
41174123
/*!
41184124
* \brief Get the relaxation coefficient of the linear solver for the implicit formulation.
41194125
* \return relaxation coefficient of the linear solver for the implicit formulation.
@@ -4509,7 +4515,7 @@ class CConfig {
45094515
* during the computation.
45104516
* \return Kind of center convective numerical scheme for the flow equations.
45114517
*/
4512-
unsigned short GetKind_Centered_Flow(void) const { return Kind_Centered_Flow; }
4518+
ENUM_CENTERED GetKind_Centered_Flow(void) const { return static_cast<ENUM_CENTERED>(Kind_Centered_Flow); }
45134519

45144520
/*!
45154521
* \brief Get the kind of center convective numerical scheme for the plasma equations.

Common/include/CMultiGridQueue.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#pragma once
3030

3131
#include <vector>
32-
#include "toolboxes/CFastFindAndEraseQueue.hpp"
32+
#include "containers/CFastFindAndEraseQueue.hpp"
3333
#include "geometry/CGeometry.hpp"
3434

3535
using namespace std;

Common/include/basic_types/ad_structure.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,7 @@ namespace AD{
353353
/*--- Base case for parameter pack expansion. ---*/
354354
FORCEINLINE void SetPreaccIn() {}
355355

356-
template<class T, class... Ts,
357-
typename std::enable_if<std::is_same<T,su2double>::value,bool>::type = 0>
356+
template<class T, class... Ts, su2enable_if<std::is_same<T,su2double>::value> = 0>
358357
FORCEINLINE void SetPreaccIn(const T& data, Ts&&... moreData) {
359358
if (!PreaccActive) return;
360359
if (data.isActive())
@@ -385,6 +384,18 @@ namespace AD{
385384
}
386385
}
387386

387+
template<class T>
388+
FORCEINLINE void SetPreaccIn(const T& data, const int size_x, const int size_y, const int size_z) {
389+
if (!PreaccActive) return;
390+
for (int i = 0; i < size_x; i++) {
391+
for (int j = 0; j < size_y; j++) {
392+
for (int k = 0; k < size_z; k++) {
393+
if (data[i][j][k].isActive()) PreaccHelper.addInput(data[i][j][k]);
394+
}
395+
}
396+
}
397+
}
398+
388399
FORCEINLINE void StartPreacc() {
389400
if (globalTape.isActive() && PreaccEnabled) {
390401
PreaccHelper.start();
@@ -395,8 +406,7 @@ namespace AD{
395406
/*--- Base case for parameter pack expansion. ---*/
396407
FORCEINLINE void SetPreaccOut() {}
397408

398-
template<class T, class... Ts,
399-
typename std::enable_if<std::is_same<T,su2double>::value,bool>::type = 0>
409+
template<class T, class... Ts, su2enable_if<std::is_same<T,su2double>::value> = 0>
400410
FORCEINLINE void SetPreaccOut(T& data, Ts&&... moreData) {
401411
if (!PreaccActive) return;
402412
if (data.isActive())

Common/include/basic_types/datatype_structure.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@
4040
#define FORCEINLINE inline
4141
#endif
4242

43+
#if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER)
44+
#define NEVERINLINE inline __attribute__((noinline))
45+
#else
46+
#define NEVERINLINE inline
47+
#endif
48+
49+
/*--- Convenience SFINAE typedef to conditionally
50+
* enable/disable function template overloads. ---*/
51+
template<bool condition>
52+
using su2enable_if = typename std::enable_if<condition,bool>::type;
53+
4354
/*--- Depending on the datatype defined during the configuration,
4455
* include the correct definition, and create the main typedef. ---*/
4556

@@ -194,10 +205,10 @@ namespace SU2_TYPE {
194205

195206
/*--- Special handling of the sprintf routine for non-primitive types. ---*/
196207
/*--- Pass-through for built-in types. ---*/
197-
template<class T, typename std::enable_if<std::is_trivial<T>::value,bool>::type = 0>
208+
template<class T, su2enable_if<std::is_trivial<T>::value> = 0>
198209
FORCEINLINE const T& _printGetValue(const T& val) {return val;}
199210
/*--- Overload for expressions of active types. ---*/
200-
template<class T, typename std::enable_if<!std::is_trivial<T>::value,bool>::type = 0>
211+
template<class T, su2enable_if<!std::is_trivial<T>::value> = 0>
201212
FORCEINLINE passivedouble _printGetValue(const T& val) { return val.getValue(); }
202213

203214
/*!

0 commit comments

Comments
 (0)