Skip to content

Commit 68be5e2

Browse files
committed
fix warning on GPUs
1 parent 080f2fc commit 68be5e2

File tree

51 files changed

+387
-457
lines changed

Some content is hidden

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

51 files changed

+387
-457
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- added exception handling for the time integration, which saves a final vtk when a error is detected in the time integration loop (!190)
1515
- fixed a bug in the test shearing box setup which led to memory corruption and incorrect pressure when ISOTHERMAL approximation was disabled (!190)
1616
- make RKL faster when running in 3D with MHD diffusion terms by skipping the evolution of cell-centered fields (!215)
17+
- fixed the many warning messages when compiling on CUDA (!229)
1718

1819
### Added
1920
- single precision version is validated and fully operational. Can be enabled from cmake. (!197)

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ option(Idefix_MHD "enable MHD" OFF)
77
option(Idefix_MPI "enable Message Passing Interface parallelisation" OFF)
88
option(Idefix_HIGH_ORDER_FARGO "Force Fargo to use a PPM reconstruction scheme" OFF)
99
option(Idefix_DEBUG "Enable Idefix debug features (makes the code very slow)" OFF)
10+
option(Idefix_WERROR "Treat compiler warnings as errors" OFF)
1011
set(Idefix_CXX_FLAGS "" CACHE STRING "Additional compiler/linker flag")
1112
set(Idefix_DEFS "definitions.hpp" CACHE FILEPATH "Problem definition header file")
1213
set(Idefix_RECONSTRUCTION "Linear" CACHE STRING "Type of cell reconstruction scheme")
@@ -36,6 +37,14 @@ add_subdirectory(src/kokkos build/kokkos)
3637
# Add Idefix CXX Flags
3738
add_compile_options(${Idefix_CXX_FLAGS})
3839

40+
if(Idefix_WERROR)
41+
if(Kokkos_ENABLE_CUDA)
42+
add_compile_options(-Xcudafe --promote_warnings)
43+
else()
44+
add_compile_options(-Werror)
45+
endif()
46+
endif()
47+
3948
# sub directories should be called after add_executable
4049
# because the binary target "idefix" should be defined
4150
# before adding source files via "target_sources"
@@ -74,10 +83,8 @@ endif()
7483
if(Idefix_DEBUG)
7584
add_compile_definitions("DEBUG")
7685
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
77-
set(Kokkos_ENABLE_DEBUG_BOUNDS_CHECK ON CACHE STRING "Enabled by Idefix_DEBUG" FORCE)
7886
endif()
7987

80-
8188
if(Idefix_HIGH_ORDER_FARGO)
8289
add_compile_definitions("HIGH_ORDER_FARGO")
8390
endif()

src/dataBlock/fargo.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ KOKKOS_INLINE_FUNCTION real FargoFlux(const IdefixArray4D<real> &Vin, int n, int
4444
int som2 = som1-1;
4545
if(!haveDomainDecomposition && (som2-sbeg< 0 )) som2 = som2+ds;
4646

47-
int sign = (eps>=0) ? 1 : -1;
4847
real dqm2,dqm1,dqp1,dqp2, q0,qm1, qp1;
4948
#if GEOMETRY == CARTESIAN || GEOMETRY == POLAR
5049
q0 = Vin(n,k,so,i);
@@ -140,11 +139,15 @@ void Fargo::Init(Input &input, DataBlock *data) {
140139
if(input.CheckBlock("Fargo")) {
141140
std::string opType = input.Get<std::string>("Fargo","velocity",0);
142141
if(opType.compare("userdef")==0) {
142+
#if GEOMETRY != SPHERICAL && GEOMETRY != POLAR
143+
IDEFIX_ERROR("Fargo+userdef is only compatible with SPHERICAL and POLAR geometries");
144+
#endif
143145
this->type=userdef;
144146
} else if(opType.compare("shearingbox")==0) {
145147
this->type=shearingbox;
146148
#if GEOMETRY != CARTESIAN
147-
IDEFIX_ERROR("Fargo+shearingbox only compatible with cartesian geometry");
149+
// Actually, this has never really been tested, so assumes it doesn't work...
150+
IDEFIX_ERROR("Fargo+shearingbox is only compatible with cartesian geometry");
148151
#endif
149152
} else {
150153
IDEFIX_ERROR("Unknown fargo velocity in the input file. "
@@ -302,8 +305,8 @@ void Fargo::CheckMaxDisplacement() {
302305
IdefixArray1D<real> xi;
303306
IdefixArray1D<real> xj;
304307
IdefixArray1D<real> dxk;
305-
FargoType fargoType = type;
306-
real sbS = hydro->sbS;
308+
[[maybe_unused]] FargoType fargoType = type;
309+
[[maybe_unused]] real sbS = hydro->sbS;
307310
real invDt = 0;
308311

309312
// Get domain size
@@ -360,8 +363,8 @@ void Fargo::AddVelocity(const real t) {
360363
IdefixArray1D<real> x1 = data->x[IDIR];
361364
IdefixArray4D<real> Vc = hydro->Vc;
362365
IdefixArray2D<real> meanV = this->meanVelocity;
363-
FargoType fargoType = type;
364-
real sbS = hydro->sbS;
366+
[[maybe_unused]] FargoType fargoType = type;
367+
[[maybe_unused]] real sbS = hydro->sbS;
365368

366369
idefix_for("FargoAddVelocity",
367370
0,data->np_tot[KDIR],
@@ -389,9 +392,9 @@ void Fargo::SubstractVelocity(const real t) {
389392
}
390393
IdefixArray1D<real> x1 = data->x[IDIR];
391394
IdefixArray4D<real> Vc = hydro->Vc;
392-
IdefixArray2D<real> meanV = this->meanVelocity;
393-
FargoType fargoType = type;
394-
real sbS = hydro->sbS;
395+
[[maybe_unused]] IdefixArray2D<real> meanV = this->meanVelocity;
396+
[[maybe_unused]] FargoType fargoType = type;
397+
[[maybe_unused]] real sbS = hydro->sbS;
395398

396399
idefix_for("FargoSubstractVelocity",
397400
0,data->np_tot[KDIR],
@@ -500,8 +503,8 @@ void Fargo::ShiftSolution(const real t, const real dt) {
500503
IdefixArray1D<real> dx3 = data->dx[KDIR];
501504
IdefixArray1D<real> sinx2 = data->sinx2;
502505
IdefixArray1D<real> sinx2m = data->sinx2m;
503-
FargoType fargoType = type;
504-
real sbS = hydro->sbS;
506+
[[maybe_unused]] FargoType fargoType = type;
507+
[[maybe_unused]] real sbS = hydro->sbS;
505508
bool haveDomainDecomposition = this->haveDomainDecomposition;
506509
int maxShift = this->maxShift;
507510

@@ -785,8 +788,6 @@ void Fargo::ShiftSolution(const real t, const real dt) {
785788
}
786789

787790
// Compute EMF due to the shift via second order reconstruction
788-
real dqm, dqp, dq;
789-
790791
#if GEOMETRY == CARTESIAN || GEOMETRY == POLAR
791792
if(eps>=ZERO_F) {
792793
int som1;

src/hydro/HDsolvers/hllHD.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ void Hydro::HllHD() {
3535
// Required for high order interpolations
3636
IdefixArray1D<real> dx = this->data->dx[DIR];
3737

38-
real gamma = this->gamma;
39-
real gamma_m1 = this->gamma - ONE_F;
40-
real csIso = this->isoSoundSpeed;
41-
HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
38+
[[maybe_unused]] real gamma = this->gamma;
39+
[[maybe_unused]] real gamma_m1 = gamma - ONE_F;
40+
[[maybe_unused]] real csIso = this->isoSoundSpeed;
41+
[[maybe_unused]] HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
4242

4343
SlopeLimiter<DIR,NVAR> slopeLim(Vc,data->dx[DIR],shockFlattening);
4444

@@ -48,9 +48,7 @@ void Hydro::HllHD() {
4848
data->beg[IDIR],data->end[IDIR]+ioffset,
4949
KOKKOS_LAMBDA (int k, int j, int i) {
5050
// Init the directions (should be in the kernel for proper optimisation by the compilers)
51-
EXPAND( const int Xn = DIR+MX1; ,
52-
const int Xt = (DIR == IDIR ? MX2 : MX1); ,
53-
const int Xb = (DIR == KDIR ? MX2 : MX3); )
51+
constexpr int Xn = DIR+MX1;
5452

5553
// Primitive variables
5654
real vL[NVAR];

src/hydro/HDsolvers/hllcHD.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ void Hydro::HllcHD() {
4242
IdefixArray3D<real> cMax = this->cMax;
4343
IdefixArray3D<real> csIsoArr = this->isoSoundSpeedArray;
4444

45-
real gamma = this->gamma;
46-
real gamma_m1 = this->gamma - ONE_F;
47-
real csIso = this->isoSoundSpeed;
48-
HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
45+
[[maybe_unused]] real gamma = this->gamma;
46+
[[maybe_unused]] real gamma_m1 = this->gamma - ONE_F;
47+
[[maybe_unused]] real csIso = this->isoSoundSpeed;
48+
[[maybe_unused]] HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
4949

5050
SlopeLimiter<DIR,NVAR> slopeLim(Vc,data->dx[DIR],shockFlattening);
5151

@@ -55,9 +55,9 @@ void Hydro::HllcHD() {
5555
data->beg[IDIR],data->end[IDIR]+ioffset,
5656
KOKKOS_LAMBDA (int k, int j, int i) {
5757
// Init the directions (should be in the kernel for proper optimisation by the compilers)
58-
EXPAND( const int Xn = DIR+MX1; ,
59-
const int Xt = (DIR == IDIR ? MX2 : MX1); ,
60-
const int Xb = (DIR == KDIR ? MX2 : MX3); )
58+
EXPAND( constexpr int Xn = DIR+MX1; ,
59+
constexpr int Xt = (DIR == IDIR ? MX2 : MX1); ,
60+
constexpr int Xb = (DIR == KDIR ? MX2 : MX3); )
6161

6262
// Primitive variables
6363
real vL[NVAR];

src/hydro/HDsolvers/roeHD.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ void Hydro::RoeHD() {
5959
IdefixArray3D<real> cMax = this->cMax;
6060
IdefixArray3D<real> csIsoArr = this->isoSoundSpeedArray;
6161

62-
real gamma = this->gamma;
63-
real gamma_m1 = this->gamma - ONE_F;
64-
real csIso = this->isoSoundSpeed;
65-
HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
62+
[[maybe_unused]] real gamma = this->gamma;
63+
[[maybe_unused]] real gamma_m1 = this->gamma - ONE_F;
64+
[[maybe_unused]] real csIso = this->isoSoundSpeed;
65+
[[maybe_unused]] HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
6666

6767
SlopeLimiter<DIR,NVAR> slopeLim(Vc,data->dx[DIR],shockFlattening);
6868

src/hydro/HDsolvers/tvdlfHD.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ void Hydro::TvdlfHD() {
3636
IdefixArray1D<real> dx = this->data->dx[DIR];
3737

3838
real gamma = this->gamma;
39-
real gamma_m1=this->gamma-ONE_F;
40-
real csIso = this->isoSoundSpeed;
41-
HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
39+
[[maybe_unused]] real gamma_m1=gamma-ONE_F;
40+
[[maybe_unused]] real csIso = this->isoSoundSpeed;
41+
[[maybe_unused]] HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
4242

4343
SlopeLimiter<DIR,NVAR> slopeLim(Vc,data->dx[DIR],shockFlattening);
4444

@@ -48,9 +48,8 @@ void Hydro::TvdlfHD() {
4848
data->beg[IDIR],data->end[IDIR]+ioffset,
4949
KOKKOS_LAMBDA (int k, int j, int i) {
5050
// Init the directions (should be in the kernel for proper optimisation by the compilers)
51-
EXPAND( const int Xn = DIR+MX1; ,
52-
const int Xt = (DIR == IDIR ? MX2 : MX1); ,
53-
const int Xb = (DIR == KDIR ? MX2 : MX3); )
51+
constexpr int Xn = DIR+MX1;
52+
5453
// Primitive variables
5554
real vL[NVAR];
5655
real vR[NVAR];

src/hydro/MHDsolvers/hllMHD.hpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ void Hydro::HllMHD() {
5757
IdefixArray3D<real> dR;
5858

5959
real gamma = this->gamma;
60-
real xHConstant = this->xH;
61-
real gamma_m1=this->gamma-ONE_F;
62-
real csIso = this->isoSoundSpeed;
63-
HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
60+
[[maybe_unused]] real xHConstant = this->xH;
61+
[[maybe_unused]] real gamma_m1=gamma-ONE_F;
62+
[[maybe_unused]] real csIso = this->isoSoundSpeed;
63+
[[maybe_unused]] HydroModuleStatus haveIsoCs = this->haveIsoSoundSpeed;
6464

6565
SlopeLimiter<DIR,NVAR> slopeLim(Vc,data->dx[DIR],shockFlattening);
6666

6767
// Define normal, tangent and bi-tanget indices
6868
// st and sb will be useful only when Hall is included
69-
real st,sb;
69+
real st = ONE_F, sb = ONE_F;
7070

7171
switch(DIR) {
7272
case(IDIR):
@@ -288,7 +288,7 @@ void Hydro::HllMHD() {
288288

289289
// 4-- Compute the Hall flux
290290
if(haveHall) {
291-
int ip1, jp1, kp1;
291+
[[maybe_unused]] int ip1, jp1, kp1;
292292
real Jx1, Jx2, Jx3;
293293
ip1=i+1;
294294
#if DIMENSIONS >=2
@@ -427,9 +427,11 @@ void Hydro::HllMHD() {
427427
K_StoreContact<DIR>(i,j,k,st,sb,Flux,Et,Eb,SV);
428428
} else if (emfAverage==ElectroMotiveForce::uct_hll) {
429429
K_StoreHLL<DIR>(i,j,k,st,sb,sl,sr,vL,vR,Et,Eb,aL,aR,dL,dR);
430-
} else if (emfAverage==ElectroMotiveForce::uct_hlld) {
431-
K_StoreHLLD<DIR>(i,j,k,st,sb,c2Iso,SLb,SRb,vL,vR,uL,uR,Et,Eb,aL,aR,dL,dR);
432430
}
431+
/* else if (emfAverage==ElectroMotiveForce::uct_hlld) {
432+
// We do not have the Alfven speed in the HLL solver
433+
K_StoreHLLD<DIR>(i,j,k,st,sb,c2Iso,SLb,SRb,vL,vR,uL,uR,Et,Eb,aL,aR,dL,dR);
434+
}*/
433435
});
434436

435437
idfx::popRegion();

0 commit comments

Comments
 (0)