Skip to content

Commit

Permalink
add google checks
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Aug 4, 2023
1 parent 0055f3e commit 344504c
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 103 deletions.
4 changes: 3 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Checks: >
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-init-variables,
Expand All @@ -20,6 +19,9 @@ Checks: >
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-*,
google-build-explicit-make-pair,
google-build-namespaces,
google-global-names-in-headers,
misc-*,
-misc-const-correctness,
-misc-non-private-member-variables-in-classes,
Expand Down
4 changes: 2 additions & 2 deletions Src/Base/AMReX_DistributionMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ top: ;

max_weight = static_cast<Real>(bl_top->weight());
efficiency = sum_weight / (static_cast<Real>(nprocs)*max_weight);
goto top;
goto top; // NOLINT
}
}
}
Expand Down Expand Up @@ -1017,7 +1017,7 @@ DistributionMapping::KnapSackProcessorMap (const DistributionMapping& olddm,

max_weight = static_cast<Real>(bl_top->weight());
new_efficiency = avg_weight / max_weight;
goto top;
goto top; // NOLINT
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions Src/Base/AMReX_Lazy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ namespace amrex::Lazy
#ifdef BL_USE_MPI
reduction_queue.push_back(f);
const int max_queue_size = 64;
if (reduction_queue.size() >= max_queue_size)
if (reduction_queue.size() >= max_queue_size) {
EvalReduction();
}
#else
f();
#endif
Expand All @@ -22,8 +23,9 @@ namespace amrex::Lazy
static int count = 0;
++count;
if (count == 1) {
for (auto&& f : reduction_queue)
for (auto&& f : reduction_queue) {
f();
}
reduction_queue.clear();
count = 0;
}
Expand Down
3 changes: 1 addition & 2 deletions Src/Base/AMReX_ParallelDescriptor.H
Original file line number Diff line number Diff line change
Expand Up @@ -898,8 +898,7 @@ ParallelDescriptor::Bcast (T* t,
#ifdef BL_LAZY
int r;
MPI_Comm_compare(comm, Communicator(), &r);
if (r == MPI_IDENT)
Lazy::EvalReduction();
if (r == MPI_IDENT) { Lazy::EvalReduction(); }
#endif

BL_ASSERT(n < static_cast<size_t>(std::numeric_limits<int>::max()));
Expand Down
6 changes: 2 additions & 4 deletions Src/Base/AMReX_ParallelDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,7 @@ Barrier (const MPI_Comm &comm, const std::string &message)
#ifdef BL_LAZY
int r;
MPI_Comm_compare(comm, Communicator(), &r);
if (r == MPI_IDENT)
Lazy::EvalReduction();
if (r == MPI_IDENT) { Lazy::EvalReduction(); }
#endif

BL_PROFILE_S("ParallelDescriptor::Barrier(comm)");
Expand Down Expand Up @@ -1130,8 +1129,7 @@ Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
#ifdef BL_LAZY
int r;
MPI_Comm_compare(comm, Communicator(), &r);
if (r == MPI_IDENT)
Lazy::EvalReduction();
if (r == MPI_IDENT) { Lazy::EvalReduction(); }
#endif

BL_PROFILE_S("ParallelDescriptor::Bcast(viMiM)");
Expand Down
5 changes: 2 additions & 3 deletions Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_2D_K.H
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef compute_flux_2d_H_
#define compute_flux_2d_H_

#include <AMReX_BLFort.H>
#include <AMReX_Box.H>
#include <AMReX_Geometry.H>
#include <AMReX_Array4.H>
#include <AMReX_REAL.H>

AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
Expand Down
163 changes: 80 additions & 83 deletions Tests/Amr/Advection_AmrCore/Source/Src_K/compute_flux_3D_K.H
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
#ifndef compute_flux_3d_H_
#define compute_flux_3d_H_

#include <AMReX_BLFort.H>
#include <AMReX_Box.H>
#include <AMReX_Geometry.H>

using namespace amrex;
#include <AMReX_Array4.H>
#include <AMReX_REAL.H>

AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void flux_x(int i, int j, int k,
Array4<Real> const& px,
Array4<Real const> const& phi,
Array4<Real const> const& vx,
Array4<Real const> const& slope,
Real dtdx)
amrex::Array4<amrex::Real> const& px,
amrex::Array4<amrex::Real const> const& phi,
amrex::Array4<amrex::Real const> const& vx,
amrex::Array4<amrex::Real const> const& slope,
amrex::Real dtdx)
{
px(i,j,k) = ( (vx(i,j,k) < 0) ?
phi(i ,j,k) - slope(i ,j,k)*(0.5 + 0.5*dtdx*vx(i,j,k)) :
Expand All @@ -24,11 +21,11 @@ void flux_x(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void flux_y(int i, int j, int k,
Array4<Real> const& py,
Array4<Real const> const& phi,
Array4<Real const> const& vy,
Array4<Real const> const& slope,
Real dtdy)
amrex::Array4<amrex::Real> const& py,
amrex::Array4<amrex::Real const> const& phi,
amrex::Array4<amrex::Real const> const& vy,
amrex::Array4<amrex::Real const> const& slope,
amrex::Real dtdy)
{
py(i,j,k) = ( (vy(i,j,k) < 0) ?
phi(i,j ,k) - slope(i,j ,k)*(0.5 + 0.5*dtdy*vy(i,j,k)) :
Expand All @@ -38,11 +35,11 @@ void flux_y(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void flux_z(int i, int j, int k,
Array4<Real> const& pz,
Array4<Real const> const& phi,
Array4<Real const> const& vz,
Array4<Real const> const& slope,
Real dtdz)
amrex::Array4<amrex::Real> const& pz,
amrex::Array4<amrex::Real const> const& phi,
amrex::Array4<amrex::Real const> const& vz,
amrex::Array4<amrex::Real const> const& slope,
amrex::Real dtdz)
{
pz(i,j,k) = ( (vz(i,j,k) < 0) ?
phi(i,j,k ) - slope(i,j,k )*(0.5 + 0.5*dtdz*vz(i,j,k)) :
Expand All @@ -52,12 +49,12 @@ void flux_z(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void flux_xy(int i, int j, int k,
Array4<Real> const& pxy,
Array4<Real const> const& vx,
Array4<Real const> const& vy,
Array4<Real const> const& px,
Array4<Real const> const& py,
Real dtdy)
amrex::Array4<amrex::Real> const& pxy,
amrex::Array4<amrex::Real const> const& vx,
amrex::Array4<amrex::Real const> const& vy,
amrex::Array4<amrex::Real const> const& px,
amrex::Array4<amrex::Real const> const& py,
amrex::Real dtdy)
{
pxy(i,j,k) = ( (vx(i,j,k) < 0) ?
px(i,j,k) - dtdy/3.0 * ( 0.5*(vy(i, j+1,k) + vy(i ,j,k)) * (py(i ,j+1,k) - py(i ,j,k))) :
Expand All @@ -67,12 +64,12 @@ void flux_xy(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void flux_xz(int i, int j, int k,
Array4<Real> const& pxz,
Array4<Real const> const& vx,
Array4<Real const> const& vz,
Array4<Real const> const& px,
Array4<Real const> const& pz,
Real dtdz)
amrex::Array4<amrex::Real> const& pxz,
amrex::Array4<amrex::Real const> const& vx,
amrex::Array4<amrex::Real const> const& vz,
amrex::Array4<amrex::Real const> const& px,
amrex::Array4<amrex::Real const> const& pz,
amrex::Real dtdz)
{
pxz(i,j,k) = ( (vx(i,j,k) < 0) ?
px(i,j,k) - dtdz/3.0 * ( 0.5*(vz(i, j,k+1) + vz(i ,j,k)) * (pz(i ,j,k+1) - pz(i ,j,k))) :
Expand All @@ -82,12 +79,12 @@ void flux_xz(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void flux_yx(int i, int j, int k,
Array4<Real> const& pyx,
Array4<Real const> const& vx,
Array4<Real const> const& vy,
Array4<Real const> const& px,
Array4<Real const> const& py,
Real dtdx)
amrex::Array4<amrex::Real> const& pyx,
amrex::Array4<amrex::Real const> const& vx,
amrex::Array4<amrex::Real const> const& vy,
amrex::Array4<amrex::Real const> const& px,
amrex::Array4<amrex::Real const> const& py,
amrex::Real dtdx)
{
pyx(i,j,k) = ( (vy(i,j,k) < 0) ?
py(i,j,k) - dtdx/3.0 * ( 0.5*(vx(i+1,j ,k) + vx(i,j ,k)) * (px(i+1,j ,k) - px(i,j ,k))) :
Expand All @@ -97,12 +94,12 @@ void flux_yx(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void flux_yz(int i, int j, int k,
Array4<Real> const& pyz,
Array4<Real const> const& vy,
Array4<Real const> const& vz,
Array4<Real const> const& py,
Array4<Real const> const& pz,
Real dtdz)
amrex::Array4<amrex::Real> const& pyz,
amrex::Array4<amrex::Real const> const& vy,
amrex::Array4<amrex::Real const> const& vz,
amrex::Array4<amrex::Real const> const& py,
amrex::Array4<amrex::Real const> const& pz,
amrex::Real dtdz)
{
pyz(i,j,k) = ( (vy(i,j,k) < 0) ?
py(i,j,k) - dtdz/3.0 * ( 0.5*(vz(i, j,k+1) + vz(i,j ,k)) * (pz(i,j ,k+1) - pz(i,j ,k))) :
Expand All @@ -112,12 +109,12 @@ void flux_yz(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void flux_zx(int i, int j, int k,
Array4<Real> const& pzx,
Array4<Real const> const& vx,
Array4<Real const> const& vz,
Array4<Real const> const& px,
Array4<Real const> const& pz,
Real dtdx)
amrex::Array4<amrex::Real> const& pzx,
amrex::Array4<amrex::Real const> const& vx,
amrex::Array4<amrex::Real const> const& vz,
amrex::Array4<amrex::Real const> const& px,
amrex::Array4<amrex::Real const> const& pz,
amrex::Real dtdx)
{
pzx(i,j,k) = ( (vz(i,j,k) < 0) ?
pz(i,j,k) - dtdx/3.0 * ( 0.5*(vx(i+1,j,k ) + vx(i,j,k )) * (px(i+1,j,k ) - px(i,j,k ))) :
Expand All @@ -127,12 +124,12 @@ void flux_zx(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void flux_zy(int i, int j, int k,
Array4<Real> const& pzy,
Array4<Real const> const& vy,
Array4<Real const> const& vz,
Array4<Real const> const& py,
Array4<Real const> const& pz,
Real dtdy)
amrex::Array4<amrex::Real> const& pzy,
amrex::Array4<amrex::Real const> const& vy,
amrex::Array4<amrex::Real const> const& vz,
amrex::Array4<amrex::Real const> const& py,
amrex::Array4<amrex::Real const> const& pz,
amrex::Real dtdy)
{
pzy(i,j,k) = ( (vz(i,j,k) < 0) ?
pz(i,j,k) - dtdy/3.0 * ( 0.5*(vy(i,j+1,k ) + vy(i,j,k )) * (py(i,j+1,k ) - py(i,j,k ))) :
Expand All @@ -142,16 +139,16 @@ void flux_zy(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void create_flux_x(int i, int j, int k,
Array4<Real> const& fx,
Array4<Real const> const& vx,
Array4<Real const> const& vy,
Array4<Real const> const& vz,
Array4<Real const> const& px,
Array4<Real const> const& pyz,
Array4<Real const> const& pzy,
Real dtdy, Real dtdz)
amrex::Array4<amrex::Real> const& fx,
amrex::Array4<amrex::Real const> const& vx,
amrex::Array4<amrex::Real const> const& vy,
amrex::Array4<amrex::Real const> const& vz,
amrex::Array4<amrex::Real const> const& px,
amrex::Array4<amrex::Real const> const& pyz,
amrex::Array4<amrex::Real const> const& pzy,
amrex::Real dtdy, amrex::Real dtdz)
{
Real f = ( (vx(i,j,k) < 0) ?
amrex::Real f = ( (vx(i,j,k) < 0) ?
px(i,j,k) - 0.5*dtdy * ( 0.5*(vy(i ,j+1,k ) + vy(i ,j,k)) * (pyz(i ,j+1,k )-pyz(i ,j,k)))
- 0.5*dtdz * ( 0.5*(vz(i ,j ,k+1) + vz(i ,j,k)) * (pzy(i ,j ,k+1)-pzy(i ,j,k))) :
px(i,j,k) - 0.5*dtdy * ( 0.5*(vy(i-1,j+1,k ) + vy(i-1,j,k)) * (pyz(i-1,j+1,k )-pyz(i-1,j,k)))
Expand All @@ -163,16 +160,16 @@ void create_flux_x(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void create_flux_y(int i, int j, int k,
Array4<Real> const& fy,
Array4<Real const> const& vx,
Array4<Real const> const& vy,
Array4<Real const> const& vz,
Array4<Real const> const& py,
Array4<Real const> const& pxz,
Array4<Real const> const& pzx,
Real dtdx, Real dtdz)
amrex::Array4<amrex::Real> const& fy,
amrex::Array4<amrex::Real const> const& vx,
amrex::Array4<amrex::Real const> const& vy,
amrex::Array4<amrex::Real const> const& vz,
amrex::Array4<amrex::Real const> const& py,
amrex::Array4<amrex::Real const> const& pxz,
amrex::Array4<amrex::Real const> const& pzx,
amrex::Real dtdx, amrex::Real dtdz)
{
Real f = ( (vy(i,j,k) < 0) ?
amrex::Real f = ( (vy(i,j,k) < 0) ?
py(i,j,k) - 0.5*dtdx * ( 0.5*(vx(i+1,j ,k ) + vx(i,j ,k)) * (pxz(i+1,j ,k )-pxz(i,j ,k)))
- 0.5*dtdz * ( 0.5*(vz(i, j ,k+1) + vz(i,j ,k)) * (pzx(i, j ,k+1)-pzx(i,j ,k))) :
py(i,j,k) - 0.5*dtdx * ( 0.5*(vx(i+1,j-1,k ) + vx(i,j-1,k)) * (pxz(i+1,j-1,k )-pxz(i,j-1,k)))
Expand All @@ -184,16 +181,16 @@ void create_flux_y(int i, int j, int k,
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void create_flux_z(int i, int j, int k,
Array4<Real> const& fz,
Array4<Real const> const& vx,
Array4<Real const> const& vy,
Array4<Real const> const& vz,
Array4<Real const> const& pz,
Array4<Real const> const& pxy,
Array4<Real const> const& pyx,
Real dtdx, Real dtdy)
amrex::Array4<amrex::Real> const& fz,
amrex::Array4<amrex::Real const> const& vx,
amrex::Array4<amrex::Real const> const& vy,
amrex::Array4<amrex::Real const> const& vz,
amrex::Array4<amrex::Real const> const& pz,
amrex::Array4<amrex::Real const> const& pxy,
amrex::Array4<amrex::Real const> const& pyx,
amrex::Real dtdx, amrex::Real dtdy)
{
Real f = ( (vz(i,j,k) < 0) ?
amrex::Real f = ( (vz(i,j,k) < 0) ?
pz(i,j,k) - 0.5*dtdx * ( 0.5*(vx(i+1,j ,k ) + vx(i,j,k )) * (pxy(i+1,j ,k )-pxy(i,j,k )))
- 0.5*dtdy * ( 0.5*(vy(i, j+1,k ) + vy(i,j,k )) * (pyx(i, j+1,k )-pyx(i,j,k ))) :
pz(i,j,k) - 0.5*dtdx * ( 0.5*(vx(i+1,j ,k-1) + vx(i,j,k-1)) * (pxy(i+1,j ,k-1)-pxy(i,j,k-1)))
Expand Down
2 changes: 0 additions & 2 deletions Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/Prob_Parm.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include <AMReX_REAL.H>

using namespace amrex::literals;

// Define the struct to contain problem-specific variables here.
// For this case, since we don't need any, the struct is empty.
struct ProbParm {};
Expand Down
3 changes: 0 additions & 3 deletions Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/Prob_Parm.H
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#define PROB_PARM_H_

#include <AMReX_REAL.H>
#include <AMReX_Vector.H>

using namespace amrex::literals;

// Define the struct to contain problem-specific variables here.
struct ProbParm
Expand Down
1 change: 0 additions & 1 deletion Tests/EB/CNS/Source/CNS.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <AMReX_EBCellFlag.H>
#include <AMReX_EBFluxRegister.H>

using namespace amrex;
class CNS
:
public amrex::AmrLevel
Expand Down

0 comments on commit 344504c

Please sign in to comment.