Skip to content

Commit

Permalink
Fixes for clang tidy 17 (#1017)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf authored Apr 11, 2024
1 parent 754dd54 commit 809a5a4
Show file tree
Hide file tree
Showing 33 changed files with 135 additions and 476 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Checks: 'bugprone-*,
-readability-function-cognitive-complexity'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
HeaderFileExtensions: ['', "H", 'h', 'hh', 'hpp', 'hxx']
AnalyzeTemporaryDtors: false
FormatStyle: none
User: user
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,18 @@ jobs:
echo "CCACHE_EXTRAFILES=${{github.workspace}}/.clang-tidy" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=50M" >> $GITHUB_ENV
echo "CTCACHE_DIR=~/.cache/ctcache" >> $GITHUB_ENV
echo "CLANG_TIDY_VERSION=17" >> $GITHUB_ENV
- name: Install clang-tidy
run: |
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries
if [[ ! -f /etc/apt/trusted.gpg.d/apt.llvm.org.asc ]]; then
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
fi
source /etc/os-release # set UBUNTU_CODENAME
sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME} main"
sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${CLANG_TIDY_VERSION} main"
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang-tidy-${CLANG_TIDY_VERSION} libomp-${CLANG_TIDY_VERSION}-dev
- name: Install Ccache
run: |
wget https://github.com/ccache/ccache/releases/download/v4.8/ccache-4.8-linux-x86_64.tar.xz
Expand Down Expand Up @@ -376,6 +388,7 @@ jobs:
-DAMR_WIND_ENABLE_ALL_WARNINGS:BOOL=ON \
-DAMR_WIND_ENABLE_CLANG_TIDY:BOOL=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache \
-DCLANG_TIDY_EXEC_NAME:STRING=clang-tidy-${CLANG_TIDY_VERSION} \
${{github.workspace}}
- name: Check
working-directory: ${{runner.workspace}}/build-clang-tidy
Expand Down Expand Up @@ -501,7 +514,7 @@ jobs:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
pull_request:
branches: [main]

concurrency:
group: ${{github.ref}}-${{github.head_ref}}-docs
cancel-in-progress: true

jobs:
Docs:
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{github.token}}
- name: Clone
uses: actions/checkout@v4
- name: Python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
Expand Down
35 changes: 0 additions & 35 deletions amr-wind/core/FieldBCOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -183,41 +183,6 @@ struct DirichletOp
m_wall_op(iv, field, geom, time, ori, n, dcomp, orig_comp);
}
}

#if 0
if (bc.lo(0) == amrex::BCType::ext_dir and
i < domain_box.smallEnd(0)) {
field(i, j, k, n) = m_bcv[amrex::Orientation(
amrex::Direction::x, amrex::Orientation::low)][n];
} else if (
bc.hi(0) == amrex::BCType::ext_dir and
i > domain_box.bigEnd(0)) {
field(i, j, k, n) = m_bcv[amrex::Orientation(
amrex::Direction::x, amrex::Orientation::high)][n];
}

if (bc.lo(1) == amrex::BCType::ext_dir and
j < domain_box.smallEnd(1)) {
field(i, j, k, n) = m_bcv[amrex::Orientation(
amrex::Direction::y, amrex::Orientation::low)][n];
} else if (
bc.hi(1) == amrex::BCType::ext_dir and
j > domain_box.bigEnd(1)) {
field(i, j, k, n) = m_bcv[amrex::Orientation(
amrex::Direction::y, amrex::Orientation::high)][n];
}

if (bc.lo(2) == amrex::BCType::ext_dir and
k < domain_box.smallEnd(2)) {
field(i, j, k, n) = m_bcv[amrex::Orientation(
amrex::Direction::z, amrex::Orientation::low)][n];
} else if (
bc.hi(2) == amrex::BCType::ext_dir and
k > domain_box.bigEnd(2)) {
field(i, j, k, n) = m_bcv[amrex::Orientation(
amrex::Direction::z, amrex::Orientation::high)][n];
}
#endif
}
}

Expand Down
42 changes: 0 additions & 42 deletions amr-wind/core/FieldFillPatchOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ public:
return ret;
}

#if 1
// Version that does no interpolation in time

void fillpatch(
Expand Down Expand Up @@ -259,47 +258,6 @@ public:
}
}

#else
// Version that handles fields at two states and performs interpolation in
// time.
void fillpatch(
int lev,
amrex::Real time,
amrex::MultiFab& mfab,
const amrex::IntVect& nghost) override
{
auto mfab_vec_lev = get_mfab_vec(lev);
if (lev == 0) {
amrex::PhysBCFunct<amrex::GpuBndryFuncFab<Functor>> physbc(
m_mesh.Geom(lev), m_field.bcrec(), bc_functor());
amrex::FillPatchSingleLevel(
mfab, nghost, time, mfab_vec_lev,
{m_time.current_time(), m_time.new_time()}, 0, 0,
m_field.num_comp(), m_mesh.Geom(lev), physbc, 0);
} else {
amrex::PhysBCFunct<amrex::GpuBndryFuncFab<Functor>> cphysbc(
m_mesh.Geom(lev - 1), m_field.bcrec(), bc_functor());
amrex::PhysBCFunct<amrex::GpuBndryFuncFab<Functor>> fphysbc(
m_mesh.Geom(lev), m_field.bcrec(), bc_functor());
auto mfab_vec_levm1 = get_mfab_vec(lev - 1);
amrex::FillPatchTwoLevels(
mfab, nghost, time, mfab_vec_levm1,
{m_time.current_time(), m_time.new_time()}, mfab_vec_lev,
{m_time.current_time(), m_time.new_time()}, 0, 0,
m_field.num_comp(), m_mesh.Geom(lev - 1), m_mesh.Geom(lev),
cphysbc, 0, fphysbc, 0, m_mesh.refRatio(lev - 1), m_mapper,
m_field.bcrec(), 0);
}
amrex::Print() << lev << " " << m_time.current_time() << " "
<< m_time.new_time() << std::endl;
}
#endif

void fillpatch_sibling_fields(
int lev,
amrex::Real time,
Expand Down
103 changes: 0 additions & 103 deletions amr-wind/core/vs/vectorI.H
Original file line number Diff line number Diff line change
Expand Up @@ -124,109 +124,6 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T>& VectorT<T>::normalize()
}
return *this;
}

#if 0
template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T>
operator+(VectorT<T>&& v1, const VectorT<T>& v2)
{
v1.x() += v2.x();
v1.y() += v2.y();
v1.z() += v2.z();
return v1;
}

template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T>
operator+(const VectorT<T>& v2, VectorT<T>&& v1)
{
v1.x() += v2.x();
v1.y() += v2.y();
v1.z() += v2.z();
return v1;
}

template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T>
operator+(VectorT<T>&& v1, VectorT<T>&& v2)
{
v1.x() += v2.x();
v1.y() += v2.y();
v1.z() += v2.z();
return v1;
}

template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T>
operator-(VectorT<T>&& v1, const VectorT<T>& v2)
{
v1.x() -= v2.x();
v1.y() -= v2.y();
v1.z() -= v2.z();
return v1;
}

template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T>
operator-(const VectorT<T>& v2, VectorT<T>&& v1)
{
v1.x() -= v2.x();
v1.y() -= v2.y();
v1.z() -= v2.z();
return v1;
}

template <typename T>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T>
operator-(VectorT<T>&& v1, VectorT<T>&& v2)
{
v1.x() -= v2.x();
v1.y() -= v2.y();
v1.z() -= v2.z();
return v1;
}

template <typename T1, typename T2>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T1>
operator*(VectorT<T1>&& inp, const T2 fac)
{
inp.x() *= fac;
inp.y() *= fac;
inp.z() *= fac;
return inp;
}

template <typename T1, typename T2>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T1>
operator*(const T2 fac, VectorT<T1>&& inp)
{
inp.x() *= fac;
inp.y() *= fac;
inp.z() *= fac;
return inp;
}

template <typename T1, typename T2>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T1>
operator/(VectorT<T1>&& inp, const T2 fac)
{
inp.x() /= fac;
inp.y() /= fac;
inp.z() /= fac;
return inp;
}

template <typename T1, typename T2>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE VectorT<T1>
operator/(const T2 fac, VectorT<T1>&& inp)
{
inp.x() /= fac;
inp.y() /= fac;
inp.z() /= fac;
return inp;
}

#endif
} // namespace amr_wind::vs

#endif /* VS_VECTORI_H */
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/AdvOp_Godunov.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ template <typename PDE>
struct AdvectionOp<
PDE,
fvm::Godunov,
typename std::enable_if<std::is_base_of<ScalarTransport, PDE>::value>::type>
typename std::enable_if_t<std::is_base_of_v<ScalarTransport, PDE>>>
{
AdvectionOp(
PDEFields& fields_in,
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/AdvOp_MOL.H
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ template <typename PDE>
struct AdvectionOp<
PDE,
fvm::MOL,
typename std::enable_if<std::is_base_of<ScalarTransport, PDE>::value>::type>
typename std::enable_if_t<std::is_base_of_v<ScalarTransport, PDE>>>
{
// cppcheck-suppress uninitMemberVar
AdvectionOp(
Expand Down
4 changes: 1 addition & 3 deletions amr-wind/equation_systems/BCOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ namespace amr_wind::pde {
* \ingroup pdeop
*/
template <typename PDE>
struct BCOp<
PDE,
typename std::enable_if<std::is_base_of<ScalarTransport, PDE>::value>::type>
struct BCOp<PDE, std::enable_if_t<std::is_base_of_v<ScalarTransport, PDE>>>
{
BCOp(PDEFields& fields, const SimTime& time)
: m_fields(fields), m_time(time)
Expand Down
10 changes: 4 additions & 6 deletions amr-wind/equation_systems/DiffusionOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public:
template <typename L>
void set_bcoeffs(
L& linop,
typename std::enable_if<
std::is_same<L, amrex::MLTensorOp>::value>::type* /*unused*/
std::enable_if_t<std::is_same_v<L, amrex::MLTensorOp>>* /*unused*/
= nullptr)
{
const int nlevels = m_pdefields.repo.num_active_levels();
Expand All @@ -71,8 +70,7 @@ public:
template <typename L>
void set_bcoeffs(
L& linop,
typename std::enable_if<
std::is_same<L, amrex::MLABecLaplacian>::value>::type* /*unused*/
std::enable_if_t<std::is_same_v<L, amrex::MLABecLaplacian>>* /*unused*/
= nullptr)
{
const int nlevels = m_pdefields.repo.num_active_levels();
Expand Down Expand Up @@ -117,13 +115,13 @@ template <typename PDE, typename Scheme>
struct DiffusionOp<
PDE,
Scheme,
typename std::enable_if<std::is_base_of<ScalarTransport, PDE>::value>::type>
std::enable_if_t<std::is_base_of_v<ScalarTransport, PDE>>>
: public DiffSolverIface<typename PDE::MLDiffOp>
{
static_assert(
PDE::ndim == 1, "DiffusionOp invoked for non-scalar PDE type");
static_assert(
std::is_same<typename PDE::MLDiffOp, amrex::MLABecLaplacian>::value,
std::is_same_v<typename PDE::MLDiffOp, amrex::MLABecLaplacian>,
"Invalid linear operator for scalar diffusion operator");

DiffusionOp(
Expand Down
7 changes: 3 additions & 4 deletions amr-wind/equation_systems/sdr/sdr_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct DiffusionOp<SDR, Scheme> : public DiffSolverIface<typename SDR::MLDiffOp>
static_assert(
SDR::ndim == 1, "DiffusionOp invoked for non-scalar SDR type");
static_assert(
std::is_same<typename SDR::MLDiffOp, amrex::MLABecLaplacian>::value,
std::is_same_v<typename SDR::MLDiffOp, amrex::MLABecLaplacian>,
"Invalid linear operator for scalar diffusion operator");

DiffusionOp(
Expand Down Expand Up @@ -103,9 +103,8 @@ struct DiffusionOp<SDR, Scheme> : public DiffSolverIface<typename SDR::MLDiffOp>
{
this->setup_operator(*this->m_applier, 0.0, -1.0, fstate);

auto tau_state = std::is_same<Scheme, fvm::Godunov>::value
? FieldState::New
: fstate;
auto tau_state =
std::is_same_v<Scheme, fvm::Godunov> ? FieldState::New : fstate;
amrex::MLMG mlmg(*this->m_applier);
mlmg.apply(
this->m_pdefields.diff_term.state(tau_state).vec_ptrs(),
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/tke/tke_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct DiffusionOp<TKE, Scheme> : public DiffSolverIface<typename TKE::MLDiffOp>
static_assert(
TKE::ndim == 1, "DiffusionOp invoked for non-scalar TKE type");
static_assert(
std::is_same<typename TKE::MLDiffOp, amrex::MLABecLaplacian>::value,
std::is_same_v<typename TKE::MLDiffOp, amrex::MLABecLaplacian>,
"Invalid linear operator for scalar diffusion operator");

DiffusionOp(
Expand Down
Loading

0 comments on commit 809a5a4

Please sign in to comment.