Skip to content

Commit

Permalink
Clang-Tidy: readability-qualified-auto
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Dec 12, 2023
1 parent a1f1d67 commit 3bcb54d
Show file tree
Hide file tree
Showing 31 changed files with 77 additions and 78 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ Checks: '
-readability-magic-numbers,
-readability-make-member-function-const,
-readability-named-parameter,
-readability-qualified-auto,
-readability-uppercase-literal-suffix
'

Expand Down
2 changes: 1 addition & 1 deletion Source/AcceleratorLattice/LatticeElementFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ LatticeElementFinderDevice::InitLatticeElementFinderDevice (WarpXParIter const&
int const lev = a_pti.GetLevel();

m_get_position = GetParticlePosition<PIdx>(a_pti, a_offset);
auto& attribs = a_pti.GetAttribs();
const auto& attribs = a_pti.GetAttribs();
m_ux = attribs[PIdx::ux].dataPtr() + a_offset;
m_uy = attribs[PIdx::uy].dataPtr() + a_offset;
m_uz = attribs[PIdx::uz].dataPtr() + a_offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ LorentzTransformParticles::LorentzTransformParticles ( const WarpXParIter& a_pti
if (tmp_particle_data.empty()) return;
m_get_position = GetParticlePosition<PIdx>(a_pti, a_offset);

auto& attribs = a_pti.GetAttribs();
const auto& attribs = a_pti.GetAttribs();
m_wpnew = attribs[PIdx::w].dataPtr();
m_uxpnew = attribs[PIdx::ux].dataPtr();
m_uypnew = attribs[PIdx::uy].dataPtr();
Expand Down
6 changes: 3 additions & 3 deletions Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ JFunctor::operator() (amrex::MultiFab& mf_dst, int dcomp, const int /*i_buffer*/
amrex::Vector<std::array< std::unique_ptr<amrex::MultiFab>, 3 > > current_fp_temp;
current_fp_temp.resize(1);

auto& current_fp_x = warpx.getcurrent_fp(m_lev,0);
const auto& current_fp_x = warpx.getcurrent_fp(m_lev,0);
current_fp_temp[0][0] = std::make_unique<amrex::MultiFab>(
current_fp_x, amrex::make_alias, 0, current_fp_x.nComp()
);

auto& current_fp_y = warpx.getcurrent_fp(m_lev,1);
const auto& current_fp_y = warpx.getcurrent_fp(m_lev,1);
current_fp_temp[0][1] = std::make_unique<amrex::MultiFab>(
current_fp_y, amrex::make_alias, 0, current_fp_y.nComp()
);
auto& current_fp_z = warpx.getcurrent_fp(m_lev,2);
const auto& current_fp_z = warpx.getcurrent_fp(m_lev,2);
current_fp_temp[0][2] = std::make_unique<amrex::MultiFab>(
current_fp_z, amrex::make_alias, 0, current_fp_z.nComp()
);
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ FlushFormatCheckpoint::CheckpointParticles (
const std::string& dir,
const amrex::Vector<ParticleDiag>& particle_diags) const
{
for (auto& part_diag: particle_diags) {
for (const auto& part_diag: particle_diags) {
WarpXParticleContainer* pc = part_diag.getParticleContainer();

Vector<std::string> real_names;
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ FlushFormatPlotfile::WriteParticles(const std::string& dir,
const amrex::Real time, bool isBTD) const
{

for (auto& part_diag : particle_diags) {
for (const auto& part_diag : particle_diags) {
WarpXParticleContainer* pc = part_diag.getParticleContainer();
PinnedMemoryParticleContainer* pinned_pc = part_diag.getPinnedParticleContainer();
auto tmp = isBTD ?
Expand Down
4 changes: 2 additions & 2 deletions Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ bool FieldProbe::ProbeInDomain () const
auto & warpx = WarpX::GetInstance();
int const lev = 0;
const amrex::Geometry& gm = warpx.Geom(lev);
const auto prob_lo = gm.ProbLo();
const auto prob_hi = gm.ProbHi();
const auto *const prob_lo = gm.ProbLo();
const auto *const prob_hi = gm.ProbHi();

/*
* Determine if probe exists within simulation boundaries. During 2D simulations,
Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void LoadBalanceCosts::ComputeDiags (int step)
int nBoxes = 0;
for (int lev = 0; lev < nLevels; ++lev)
{
const auto cost = WarpX::getCosts(lev);
auto *const cost = WarpX::getCosts(lev);
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
cost, "ERROR: costs are not initialized on level " + std::to_string(lev) + " !");
nBoxes += cost->size();
Expand Down
6 changes: 3 additions & 3 deletions Source/Diagnostics/WarpXOpenPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ WarpXOpenPMDPlot::DumpToFile (ParticleContainer* pc,
for (auto i = 0; i < numParticleOnTile; i++) {
ids.get()[i] = ablastr::particles::localIDtoGlobal(static_cast<int>(aos[i].id()), static_cast<int>(aos[i].cpu()));
}
auto const scalar = openPMD::RecordComponent::SCALAR;
const auto *const scalar = openPMD::RecordComponent::SCALAR;
currSpecies["id"][scalar].storeChunk(ids, {offset}, {numParticleOnTile64});

}
Expand Down Expand Up @@ -1014,7 +1014,7 @@ WarpXOpenPMDPlot::SetupPos (
currSpecies["position"][comp].resetDataset( realType );
}

auto const scalar = openPMD::RecordComponent::SCALAR;
const auto *const scalar = openPMD::RecordComponent::SCALAR;
currSpecies["id"][scalar].resetDataset( idType );
}

Expand All @@ -1026,7 +1026,7 @@ WarpXOpenPMDPlot::SetConstParticleRecordsEDPIC (
amrex::ParticleReal const mass)
{
auto realType = openPMD::Dataset(openPMD::determineDatatype<amrex::ParticleReal>(), {np});
auto const scalar = openPMD::RecordComponent::SCALAR;
const auto *const scalar = openPMD::RecordComponent::SCALAR;

// define record shape to be number of particles
auto const positionComponents = detail::getParticlePositionComponentLabels(true);
Expand Down
4 changes: 2 additions & 2 deletions Source/Initialization/WarpXInitData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,12 +1391,12 @@ WarpX::ReadExternalFieldFromFile (

auto FC_chunk_data = FC.loadChunk<double>(chunk_offset,chunk_extent);
series.flush();
auto FC_data_host = FC_chunk_data.get();
auto *FC_data_host = FC_chunk_data.get();

// Load data to GPU
const size_t total_extent = size_t(extent[0]) * extent[1] * extent[2];
amrex::Gpu::DeviceVector<double> FC_data_gpu(total_extent);
auto FC_data = FC_data_gpu.data();
auto *FC_data = FC_data_gpu.data();
amrex::Gpu::copy(amrex::Gpu::hostToDevice, FC_data_host, FC_data_host + total_extent, FC_data);

// Loop over boxes
Expand Down
6 changes: 3 additions & 3 deletions Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ WarpXLaserProfiles::FromFileLaserProfile::internal_fill_amplitude_uniform_cartes
const auto tmp_y_max = m_params.y_max;
const auto tmp_nx = m_params.nx;
const auto tmp_ny = m_params.ny;
const auto p_E_lasy_data = m_params.E_lasy_data.dataPtr();
const auto *const p_E_lasy_data = m_params.E_lasy_data.dataPtr();
const auto tmp_idx_first_time = m_params.first_time_index;
const int idx_t_right = idx_t_left+1;
const auto t_left = idx_t_left*
Expand Down Expand Up @@ -523,7 +523,7 @@ WarpXLaserProfiles::FromFileLaserProfile::internal_fill_amplitude_uniform_cylind
const auto tmp_r_max = m_params.r_max;
const auto tmp_nr = m_params.nr;
const auto tmp_n_rz_azimuthal_components = m_params.n_rz_azimuthal_components;
const auto p_E_lasy_data = m_params.E_lasy_data.dataPtr();
const auto *const p_E_lasy_data = m_params.E_lasy_data.dataPtr();
const auto tmp_idx_first_time = m_params.first_time_index;
const int idx_t_right = idx_t_left+1;
const auto t_left = idx_t_left*
Expand Down Expand Up @@ -625,7 +625,7 @@ WarpXLaserProfiles::FromFileLaserProfile::internal_fill_amplitude_uniform_binary
const auto tmp_ny = m_params.ny;
#endif
const auto tmp_nx = m_params.nx;
const auto p_E_binary_data = m_params.E_binary_data.dataPtr();
const auto *const p_E_binary_data = m_params.E_binary_data.dataPtr();
const auto tmp_idx_first_time = m_params.first_time_index;
const int idx_t_right = idx_t_left+1;
const auto t_left = idx_t_left*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ BackgroundMCCCollision::doCollisions (amrex::Real cur_time, amrex::Real dt, Mult
auto const flvl = species1.finestLevel();
for (int lev = 0; lev <= flvl; ++lev) {

auto cost = WarpX::getCosts(lev);
auto *cost = WarpX::getCosts(lev);

// firstly loop over particles box by box and do all particle conserving
// scattering
Expand Down Expand Up @@ -324,7 +324,7 @@ void BackgroundMCCCollision::doBackgroundCollisionsWithinTile
auto T_a_func = m_background_temperature_func;

// get collision parameters
auto scattering_processes = m_scattering_processes_exe.data();
auto *scattering_processes = m_scattering_processes_exe.data();
auto const process_count = static_cast<int>(m_scattering_processes_exe.size());

auto const total_collision_prob = m_total_collision_prob;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ BackgroundStopping::doCollisions (amrex::Real cur_time, amrex::Real dt, MultiPar
auto const flvl = species.finestLevel();
for (int lev = 0; lev <= flvl; ++lev) {

auto cost = WarpX::getCosts(lev);
auto *cost = WarpX::getCosts(lev);

// loop over particles box by box
#ifdef _OPENMP
Expand Down
6 changes: 3 additions & 3 deletions Source/Particles/Collision/BinaryCollision/BinaryCollision.H
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public:
auto copy_species1_data = device_copy_species1.data();
auto copy_species2_data = device_copy_species2.data();
#else
auto copy_species1_data = copy_species1.data();
auto copy_species2_data = copy_species2.data();
auto *copy_species1_data = copy_species1.data();
auto *copy_species2_data = copy_species2.data();
#endif
if (m_have_product_species){
species1.defineAllParticleTiles();
Expand Down Expand Up @@ -239,7 +239,7 @@ public:
products_np.push_back(ptile_product.numParticles());
products_mass.push_back(product_species_vector[i]->getMass());
}
auto tile_products_data = tile_products.data();
auto *tile_products_data = tile_products.data();

if ( m_isSameSpecies ) // species_1 == species_2
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Particles/Deposition/ChargeDeposition.H
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void doChargeDepositionSharedShapeN (const GetParticlePosition<PIdx>& GetPositio
{
using namespace amrex;

auto permutation = a_bins.permutationPtr();
const auto *permutation = a_bins.permutationPtr();

#if !defined(AMREX_USE_GPU)
amrex::ignore_unused(ix_type, cost, load_balance_costs_update_algo, a_bins, box, geom, a_tbox_max_size, bin_size);
Expand Down
2 changes: 1 addition & 1 deletion Source/Particles/Gather/GetExternalFields.H
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct GetExternalEBField

std::optional<LatticeElementFinderDevice> d_lattice_element_finder;

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
bool isNoOp () const { return (m_Etype == None && m_Btype == None && !d_lattice_element_finder.has_value()); }

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Expand Down
2 changes: 1 addition & 1 deletion Source/Particles/Gather/GetExternalFields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ GetExternalEBField::GetExternalEBField (const WarpXParIter& a_pti, long a_offset
if (mypc.m_E_ext_particle_s == "repeated_plasma_lens") m_Etype = RepeatedPlasmaLens;
if (mypc.m_B_ext_particle_s == "repeated_plasma_lens") m_Btype = RepeatedPlasmaLens;
m_dt = warpx.getdt(a_pti.GetLevel());
auto& attribs = a_pti.GetAttribs();
const auto& attribs = a_pti.GetAttribs();
m_ux = attribs[PIdx::ux].dataPtr() + a_offset;
m_uy = attribs[PIdx::uy].dataPtr() + a_offset;
m_uz = attribs[PIdx::uz].dataPtr() + a_offset;
Expand Down
14 changes: 7 additions & 7 deletions Source/Particles/MultiParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ MultiParticleContainer::SetParticleDistributionMap (int lev, DistributionMapping
void
MultiParticleContainer::ContinuousInjection (const RealBox& injection_box) const
{
for (auto& pc : allcontainers){
for (const auto& pc : allcontainers){
if (pc->do_continuous_injection){
pc->ContinuousInjection(injection_box);
}
Expand All @@ -720,7 +720,7 @@ MultiParticleContainer::ContinuousInjection (const RealBox& injection_box) const
void
MultiParticleContainer::UpdateAntennaPosition (const amrex::Real dt) const
{
for (auto& pc : allcontainers){
for (const auto& pc : allcontainers){
if (pc->do_continuous_injection){
pc->UpdateAntennaPosition(dt);
}
Expand All @@ -731,7 +731,7 @@ int
MultiParticleContainer::doContinuousInjection () const
{
int warpx_do_continuous_injection = 0;
for (auto& pc : allcontainers){
for (const auto& pc : allcontainers){
if (pc->do_continuous_injection){
warpx_do_continuous_injection = 1;
}
Expand All @@ -746,7 +746,7 @@ MultiParticleContainer::doContinuousInjection () const
void
MultiParticleContainer::ContinuousFluxInjection (amrex::Real t, amrex::Real dt) const
{
for (auto& pc : allcontainers){
for (const auto& pc : allcontainers){
pc->ContinuousFluxInjection(t, dt);
}
}
Expand Down Expand Up @@ -870,7 +870,7 @@ MultiParticleContainer::doFieldIonization (int lev,
auto& pc_product = allcontainers[pc_source->ionization_product];

const SmartCopyFactory copy_factory(*pc_source, *pc_product);
auto phys_pc_ptr = static_cast<PhysicalParticleContainer*>(pc_source.get());
auto *phys_pc_ptr = static_cast<PhysicalParticleContainer*>(pc_source.get());

auto Copy = copy_factory.getSmartCopy();
auto Transform = IonizationTransformFunc();
Expand Down Expand Up @@ -1498,7 +1498,7 @@ void MultiParticleContainer::doQedBreitWheeler (int lev,

const SmartCopyFactory copy_factory_ele(*pc_source, *pc_product_ele);
const SmartCopyFactory copy_factory_pos(*pc_source, *pc_product_pos);
auto phys_pc_ptr = static_cast<PhysicalParticleContainer*>(pc_source.get());
auto *phys_pc_ptr = static_cast<PhysicalParticleContainer*>(pc_source.get());

const auto Filter = phys_pc_ptr->getPairGenerationFilterFunc();
const auto CopyEle = copy_factory_ele.getSmartCopy();
Expand Down Expand Up @@ -1578,7 +1578,7 @@ void MultiParticleContainer::doQedQuantumSync (int lev,
allcontainers[pc_source->m_qed_quantum_sync_phot_product];

const SmartCopyFactory copy_factory_phot(*pc_source, *pc_product_phot);
auto phys_pc_ptr =
auto *phys_pc_ptr =
static_cast<PhysicalParticleContainer*>(pc_source.get());

const auto Filter = phys_pc_ptr->getPhotonEmissionFilterFunc();
Expand Down
2 changes: 1 addition & 1 deletion Source/Particles/ParticleBoundaryBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void ParticleBoundaryBuffer::printNumParticles () const {
{
for (int iside = 0; iside < 2; ++iside)
{
auto& buffer = m_particle_containers[2*idim+iside];
const auto& buffer = m_particle_containers[2*idim+iside];
for (int i = 0; i < numSpecies(); ++i)
{
const auto np = buffer[i].isDefined() ? buffer[i].TotalNumberOfParticles(false) : 0;
Expand Down
8 changes: 4 additions & 4 deletions Source/Particles/ParticleCreation/FilterCopyTransform.H
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Index filterCopyTransformParticles (DstTile& dst, SrcTile& src, Index* mask, Ind
const Index num_added = N * total;
dst.resize(std::max(dst_index + num_added, dst.numParticles()));

const auto p_offsets = offsets.dataPtr();
auto *const p_offsets = offsets.dataPtr();

const auto src_data = src.getParticleTileData();
const auto dst_data = dst.getParticleTileData();
Expand Down Expand Up @@ -133,7 +133,7 @@ Index filterCopyTransformParticles (DstTile& dst, SrcTile& src, Index dst_index,

Gpu::DeviceVector<Index> mask(np);

auto p_mask = mask.dataPtr();
auto *p_mask = mask.dataPtr();
const auto src_data = src.getParticleTileData();

amrex::ParallelForRNG(np,
Expand Down Expand Up @@ -207,7 +207,7 @@ Index filterCopyTransformParticles (DstTile& dst1, DstTile& dst2, SrcTile& src,
dst1.resize(std::max(dst1_index + num_added, dst1.numParticles()));
dst2.resize(std::max(dst2_index + num_added, dst2.numParticles()));

auto p_offsets = offsets.dataPtr();
auto *p_offsets = offsets.dataPtr();

const auto src_data = src.getParticleTileData();
const auto dst1_data = dst1.getParticleTileData();
Expand Down Expand Up @@ -290,7 +290,7 @@ Index filterCopyTransformParticles (DstTile& dst1, DstTile& dst2, SrcTile& src,

Gpu::DeviceVector<Index> mask(np);

auto p_mask = mask.dataPtr();
auto *p_mask = mask.dataPtr();
const auto src_data = src.getParticleTileData();

amrex::ParallelForRNG(np,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Index filterCreateTransformFromFAB (DstTile& dst1, DstTile& dst2, const amrex::B
dst1.resize(std::max(dst1_index + num_added, dst1.numParticles()));
dst2.resize(std::max(dst2_index + num_added, dst2.numParticles()));

auto p_offsets = offsets.dataPtr();
auto *p_offsets = offsets.dataPtr();

const auto dst1_data = dst1.getParticleTileData();
const auto dst2_data = dst2.getParticleTileData();
Expand Down Expand Up @@ -188,7 +188,7 @@ Index filterCreateTransformFromFAB (DstTile& dst1, DstTile& dst2, const amrex::B

Gpu::DeviceVector<Index> mask(ncells);

auto p_mask = mask.dataPtr();
auto *p_mask = mask.dataPtr();

// for loop over all cells in the box. We apply the filter function to each cell
// and store the result in arrNumPartCreation. If the result is strictly greater than
Expand Down
12 changes: 6 additions & 6 deletions Source/Particles/PhotonParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,17 @@ PhotonParticleContainer::PushPX (WarpXParIter& pti,
nox, galerkin_interpolation);
}

[[maybe_unused]] auto& getExternalEB_tmp = getExternalEB; // workaround for nvcc
[[maybe_unused]] const auto& getExternalEB_tmp = getExternalEB; // workaround for nvcc
if constexpr (exteb_control == has_exteb) {
getExternalEB(i, Exp, Eyp, Ezp, Bxp, Byp, Bzp);
}

#ifdef WARPX_QED
[[maybe_unused]] auto& evolve_opt_tmp = evolve_opt;
[[maybe_unused]] auto p_optical_depth_BW_tmp = p_optical_depth_BW;
[[maybe_unused]] auto ux_tmp = ux; // for nvhpc
[[maybe_unused]] auto uy_tmp = uy;
[[maybe_unused]] auto uz_tmp = uz;
[[maybe_unused]] const auto& evolve_opt_tmp = evolve_opt;
[[maybe_unused]] auto *p_optical_depth_BW_tmp = p_optical_depth_BW;
[[maybe_unused]] auto *ux_tmp = ux; // for nvhpc
[[maybe_unused]] auto *uy_tmp = uy;
[[maybe_unused]] auto *uz_tmp = uz;
[[maybe_unused]] auto dt_tmp = dt;
if constexpr (qed_control == has_qed) {
evolve_opt(ux[i], uy[i], uz[i], Exp, Eyp, Ezp, Bxp, Byp, Bzp,
Expand Down
Loading

0 comments on commit 3bcb54d

Please sign in to comment.