Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1eb5a10
make FFTPoissonSolver's destructor = default
lucafedeli88 Oct 24, 2025
4cad3e6
add tool to run clang-tidy locally
lucafedeli88 Oct 27, 2025
8eb630a
Merge remote-tracking branch 'origin/development' into add_tools_to_u…
lucafedeli88 Oct 27, 2025
18077c4
Update tools/runClangTidy.sh
lucafedeli88 Oct 28, 2025
63e426d
Merge remote-tracking branch 'upstream/development' into add_tools_to…
lucafedeli88 Oct 29, 2025
5e015c9
Merge remote-tracking branch 'origin/development' into add_tools_to_u…
lucafedeli88 Nov 20, 2025
a44e221
add clang-tidy in CI
lucafedeli88 Nov 24, 2025
8d81667
add missing dependency
lucafedeli88 Nov 24, 2025
77e124a
update runClangTidy script
lucafedeli88 Nov 24, 2025
a169d14
add missing dependency
lucafedeli88 Nov 24, 2025
cc675d9
add missing dependency
lucafedeli88 Nov 24, 2025
8674d76
silence two warnings
lucafedeli88 Nov 24, 2025
99e0b9a
disable vectorization warnings in CI
lucafedeli88 Nov 24, 2025
949465f
disable vectorization errors also for the linking step
lucafedeli88 Nov 24, 2025
dafc962
fix env. variables bug
lucafedeli88 Nov 24, 2025
6238b6e
add clearer messages and exit with code 1 if clang-tidy finds issues
lucafedeli88 Nov 24, 2025
e8b0780
check file size
lucafedeli88 Nov 24, 2025
0d5d04d
add checks of the cert-* family
lucafedeli88 Nov 24, 2025
8555a3d
fix bug
lucafedeli88 Nov 24, 2025
5826dee
only keep cert-err58-cpp for the moment
lucafedeli88 Nov 24, 2025
542090f
remove cert checks and enable most checks of the bugprone family
lucafedeli88 Nov 24, 2025
884c2b5
update rules
lucafedeli88 Nov 26, 2025
b05306f
implement fixes
lucafedeli88 Nov 26, 2025
f308ac3
fix bug introduced in previous commit
lucafedeli88 Nov 26, 2025
e769987
fix bug introduced in previous commit
lucafedeli88 Nov 26, 2025
cf3857b
Merge remote-tracking branch 'origin/development' into add_tools_to_u…
lucafedeli88 Nov 26, 2025
a5b63ae
remove unused phys_const from 2 files
lucafedeli88 Nov 26, 2025
ccda6b6
fix bug
lucafedeli88 Nov 26, 2025
2ff0b94
fix bug
lucafedeli88 Nov 26, 2025
fccf114
address issue found with clang-tidy
lucafedeli88 Nov 26, 2025
0af034b
change how the has_value check is done
lucafedeli88 Nov 26, 2025
b4d7e2f
Merge remote-tracking branch 'origin/development' into add_tools_to_u…
lucafedeli88 Dec 5, 2025
5ff5a6b
Update .github/workflows/clangtidy.yml
lucafedeli88 Dec 8, 2025
f88aac3
revert changes in MultiBuffer.cpp
lucafedeli88 Dec 8, 2025
3d70f1f
revert last change to .clang-tidy
lucafedeli88 Dec 8, 2025
07639ad
delete check option
lucafedeli88 Dec 8, 2025
e2db756
use NOLINT
lucafedeli88 Dec 8, 2025
929df68
add comment to clang-tidy configuration file
lucafedeli88 Dec 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Enabled checks:
#
# - all the checks of the bugprone-* group except:
# easily-swappable-parameters, implicit-widening-of-multiplication-result,
# misplaced-widening-cast, narrowing-conversions
#
# - cppcoreguidelines-avoid-goto
#
Checks: '
-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-misplaced-widening-cast,
-bugprone-narrowing-conversions,
cppcoreguidelines-avoid-goto
'

HeaderFilterRegex: 'src[a-z_A-Z0-9\/]+\.H$'
25 changes: 25 additions & 0 deletions .github/workflows/clangtidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

name: 🧹 clang-tidy

on:
push:
branches:
- development
pull_request:
branches:
- development

jobs:

linux_clang_tidy:
name: clang-tidy
runs-on: ubuntu-latest
env: {CXXFLAGS: "-Wno-pass-failed"}
steps:
- uses: actions/checkout@v4
- name: Dependencies
run: .github/workflows/setup/ubuntu_clang.sh
- name: Build & Install
run: |
./tools/runClangTidy.sh

19 changes: 0 additions & 19 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,3 @@ jobs:
cmake --build build -j 2
- name: Run Tests
run: ctest --test-dir build --output-on-failure

# enable again when we open-source (free core-hours for GH Actions)
#
# linux_clang7:
# name: Clang@7 C++17 OMPI
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Dependencies
# run: .github/workflows/setup/ubuntu_clang.sh
# - name: Build & Install
# run: |
# mkdir build
# cd build
# cmake .. \
# -DCMAKE_C_COMPILER=$(which clang-7) \
# -DCMAKE_CXX_COMPILER=$(which clang++-7)
# make -j 2 VERBOSE=ON
# ctest --output-on-failure
8 changes: 6 additions & 2 deletions .github/workflows/setup/ubuntu_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
ccache \
clang-7 \
clang \
clang-tidy \
libomp-dev \
libopenmpi-dev \
openmpi-bin
openmpi-bin \
libfftw3-dev \
libfftw3-single3
11 changes: 9 additions & 2 deletions src/mg_solver/HpMultiGrid.H
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ public:
return 2;
case 3:
return 1;
default:
amrex::Abort(std::to_string(system_type) + " is not a valid system_type!");
}
return 0;
return 0; //unreachable
}

/** \brief Return the number of acf components used for a given system type
Expand All @@ -201,8 +203,10 @@ public:
return 2;
case 3:
return 0;
default:
amrex::Abort(std::to_string(system_type) + " is not a valid system_type!");
}
return 0;
return 0; //unreachable
}

/** When applying Dirichlet boundary conditions, shift boundary value by offset number of cells */
Expand Down Expand Up @@ -230,8 +234,11 @@ private:
int m_num_mg_levels;
/** Number of single-block-kernel levels */
int m_num_single_block_levels;

#if defined(AMREX_USE_GPU)
/** If the single block kernel should be used */
bool m_use_single_block_kernel = true;
#endif

/** Alias to the solution argument passed in solve() */
amrex::FArrayBox m_sol;
Expand Down
4 changes: 3 additions & 1 deletion src/mg_solver/HpMultiGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ namespace hpmg {

namespace {

constexpr int n_cell_single = 32; // switch to single block when box is smaller than this
#if defined(AMREX_USE_GPU)
constexpr int n_cell_single = 32; // switch to single block when box is smaller than this
#endif

Box valid_domain_box (Box const& domain)
{
Expand Down
4 changes: 2 additions & 2 deletions src/utils/MultiBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ void MultiBuffer::pack_data (int slice, MultiBeam& beams, MultiLaser& laser, int

if (beam.communicateIdCpuComponent()) {
// only pack idcpu component if it should be communicated
memcpy_to_buffer(slice, bo.m_beam_idcpu[b].value(),
memcpy_to_buffer(slice, bo.m_beam_idcpu[b].value(), // NOLINT(bugprone-unchecked-optional-access)
soa.GetIdCPUData().dataPtr(),
num_particles * sizeof(std::uint64_t));
}
Expand Down Expand Up @@ -861,7 +861,7 @@ void MultiBuffer::unpack_data (int slice, MultiBeam& beams, MultiLaser& laser, i

if (beam.communicateIdCpuComponent()) {
// only undpack idcpu component if it should be communicated
memcpy_from_buffer(slice, bo.m_beam_idcpu[b].value(),
memcpy_from_buffer(slice, bo.m_beam_idcpu[b].value(), // NOLINT(bugprone-unchecked-optional-access)
soa.GetIdCPUData().dataPtr(),
num_particles * sizeof(std::uint64_t));
} else {
Expand Down
121 changes: 121 additions & 0 deletions tools/runClangTidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#! /usr/bin/env bash

# Copyright 2025
#
# This file is part of HiPACE++.
#
# Authors: Luca Fedeli
# License: BSD-3-Clause-LBNL

# This script is a developer's tool to perform
# checks with clang-tidy.
#
# Note: this script is only tested on Linux

set -eu -o pipefail

echo "============================================="
echo
echo "This script is a developer's tool to perform"
echo "checks with clang-tidy."
echo "_____________________________________________"

# Check source dir
REPO_DIR=$(cd $(dirname ${BASH_SOURCE})/../ && pwd)
echo
echo "Your current source directory is: ${REPO_DIR}"
echo "_____________________________________________"

# Set number of jobs to use for compilation
PARALLEL="${HIPACE_TOOLS_LINTER_PARALLEL:-4}"
echo
echo "${PARALLEL} jobs will be used for compilation."
echo "This can be overridden by setting the environment"
echo "variable HIPACE_TOOLS_LINTER_PARALLEL, e.g.: "
echo
echo "$ export HIPACE_TOOLS_LINTER_PARALLEL=8"
echo "$ ./tools/runClangTidy.sh"
echo "_____________________________________________"

# Check clang version
export CC="${CLANG:-"clang"}"
export CXX="${CLANGXX:-"clang++"}"
export CTIDY="${CLANGTIDY:-"clang-tidy"}"
echo
echo "The following versions of the clang compiler and"
echo "of the clang-tidy linter will be used:"
echo
echo "clang version:"
which ${CC}
${CC} --version
echo
echo "clang++ version:"
which ${CXX}
${CXX} --version
echo
echo "clang-tidy version:"
which ${CTIDY}
${CTIDY} --version
echo
echo "This can be overridden by setting the environment"
echo "variables CLANG, CLANGXX, and CLANGTIDY e.g.: "
echo "$ export CLANG=clang-20"
echo "$ export CLANGXX=clang++-20"
echo "$ export CTIDCLANGTIDYY=clang-tidy-20"
echo "$ ./tools/runClangTidy.sh"
echo "_____________________________________________"

# Prepare clang-tidy wrapper
echo
echo "Prepare clang-tidy wrapper"
echo "The following wrapper ensures that only source files"
echo "in hipace/src/* are actually processed by clang-tidy"
echo
cat > ${REPO_DIR}/clang_tidy_wrapper << EOF
#!/bin/bash
REGEX="[a-z_A-Z0-9\/]*hipace\/src[a-z_A-Z0-9\/]+.cpp"
if [[ \$4 =~ \$REGEX ]];then
${CTIDY} \$@
fi
EOF
chmod +x ${REPO_DIR}/clang_tidy_wrapper
echo "clang_tidy_wrapper: "
cat ${REPO_DIR}/clang_tidy_wrapper
echo "_____________________________________________"

# Compile HiPACE++ using clang-tidy
echo
echo "*******************************************"
echo "* Compile HiPACE++ using clang-tidy *"
echo "* Please ensure that all the dependencies *"
echo "* required to compile HiPACE++ are met *"
echo "*******************************************"
echo

rm -rf ${REPO_DIR}/build_clang_tidy

cmake -S ${REPO_DIR} -B ${REPO_DIR}/build_clang_tidy \
-DCMAKE_CXX_CLANG_TIDY="${REPO_DIR}/clang_tidy_wrapper;--system-headers=0;--config-file=${REPO_DIR}/.clang-tidy" \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DHiPACE_MPI=ON \
-DHiPACE_COMPUTE=OMP \
-DHiPACE_OPENPMD=ON \
-DHiPACE_PRECISION=SINGLE

cmake --build ${REPO_DIR}/build_clang_tidy -j ${PARALLEL} 2> ${REPO_DIR}/build_clang_tidy/clang-tidy.log

if [ -s ${REPO_DIR}/build_clang_tidy/clang-tidy.log ]; then
echo
echo "clang-tidy found the following issues:"
echo
cat ${REPO_DIR}/build_clang_tidy/clang-tidy.log
echo
echo "============================================="
exit 1
else
echo
echo "clang-tidy has not found any issue."
echo
echo "============================================="
exit 0
fi
Loading