diff --git a/.clang-tidy b/.clang-tidy index 9fada1bbdfe..915753633ac 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -47,7 +47,6 @@ Checks: ' -readability-magic-numbers, -readability-make-member-function-const, -readability-named-parameter, - -readability-qualified-auto, -readability-uppercase-literal-suffix ' diff --git a/Source/AcceleratorLattice/LatticeElementFinder.cpp b/Source/AcceleratorLattice/LatticeElementFinder.cpp index 62ebdcc1f4f..ef90871a62b 100644 --- a/Source/AcceleratorLattice/LatticeElementFinder.cpp +++ b/Source/AcceleratorLattice/LatticeElementFinder.cpp @@ -97,7 +97,7 @@ LatticeElementFinderDevice::InitLatticeElementFinderDevice (WarpXParIter const& int const lev = a_pti.GetLevel(); m_get_position = GetParticlePosition(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; diff --git a/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp index ce463a11ca3..027b3c3e5b4 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp @@ -40,7 +40,7 @@ LorentzTransformParticles::LorentzTransformParticles ( const WarpXParIter& a_pti if (tmp_particle_data.empty()) return; m_get_position = GetParticlePosition(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(); diff --git a/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp index 4663a5e1a70..b21bbded011 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp @@ -36,16 +36,16 @@ JFunctor::operator() (amrex::MultiFab& mf_dst, int dcomp, const int /*i_buffer*/ amrex::Vector, 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( 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( 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( current_fp_z, amrex::make_alias, 0, current_fp_z.nComp() ); diff --git a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp index 2247a7eaadf..5f59cd723da 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp @@ -172,7 +172,7 @@ FlushFormatCheckpoint::CheckpointParticles ( const std::string& dir, const amrex::Vector& particle_diags) const { - for (auto& part_diag: particle_diags) { + for (const auto& part_diag: particle_diags) { WarpXParticleContainer* pc = part_diag.getParticleContainer(); Vector real_names; diff --git a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp index c2e372b1fb8..df49e3a2731 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp @@ -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 ? diff --git a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp index c041a70aaef..d4595ad4a11 100644 --- a/Source/Diagnostics/ReducedDiags/FieldProbe.cpp +++ b/Source/Diagnostics/ReducedDiags/FieldProbe.cpp @@ -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, diff --git a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp index 7843527cbf5..04ee3ef597a 100644 --- a/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp +++ b/Source/Diagnostics/ReducedDiags/LoadBalanceCosts.cpp @@ -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(); diff --git a/Source/Diagnostics/WarpXOpenPMD.cpp b/Source/Diagnostics/WarpXOpenPMD.cpp index a375266b1d3..0e877efa1d9 100644 --- a/Source/Diagnostics/WarpXOpenPMD.cpp +++ b/Source/Diagnostics/WarpXOpenPMD.cpp @@ -782,7 +782,7 @@ WarpXOpenPMDPlot::DumpToFile (ParticleContainer* pc, for (auto i = 0; i < numParticleOnTile; i++) { ids.get()[i] = ablastr::particles::localIDtoGlobal(static_cast(aos[i].id()), static_cast(aos[i].cpu())); } - auto const scalar = openPMD::RecordComponent::SCALAR; + const auto *const scalar = openPMD::RecordComponent::SCALAR; currSpecies["id"][scalar].storeChunk(ids, {offset}, {numParticleOnTile64}); } @@ -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 ); } @@ -1026,7 +1026,7 @@ WarpXOpenPMDPlot::SetConstParticleRecordsEDPIC ( amrex::ParticleReal const mass) { auto realType = openPMD::Dataset(openPMD::determineDatatype(), {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); diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index bd8e6334f48..1697705b05d 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -1391,12 +1391,12 @@ WarpX::ReadExternalFieldFromFile ( auto FC_chunk_data = FC.loadChunk(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 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 diff --git a/Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp b/Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp index e29439c4bc0..b353ad43bf2 100644 --- a/Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp +++ b/Source/Laser/LaserProfilesImpl/LaserProfileFromFile.cpp @@ -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* @@ -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* @@ -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* diff --git a/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp b/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp index ebf8cb47172..2e591300e5d 100644 --- a/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp +++ b/Source/Particles/Collision/BackgroundMCC/BackgroundMCCCollision.cpp @@ -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 @@ -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(m_scattering_processes_exe.size()); auto const total_collision_prob = m_total_collision_prob; diff --git a/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp b/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp index 83f74840478..8122d7225b4 100644 --- a/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp +++ b/Source/Particles/Collision/BackgroundStopping/BackgroundStopping.cpp @@ -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 diff --git a/Source/Particles/Collision/BinaryCollision/BinaryCollision.H b/Source/Particles/Collision/BinaryCollision/BinaryCollision.H index 58fe2c9911a..a2d4229d4b2 100644 --- a/Source/Particles/Collision/BinaryCollision/BinaryCollision.H +++ b/Source/Particles/Collision/BinaryCollision/BinaryCollision.H @@ -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(); @@ -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 { diff --git a/Source/Particles/Deposition/ChargeDeposition.H b/Source/Particles/Deposition/ChargeDeposition.H index 50ed74439e5..d0db678dfda 100644 --- a/Source/Particles/Deposition/ChargeDeposition.H +++ b/Source/Particles/Deposition/ChargeDeposition.H @@ -261,7 +261,7 @@ void doChargeDepositionSharedShapeN (const GetParticlePosition& 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); diff --git a/Source/Particles/Gather/GetExternalFields.H b/Source/Particles/Gather/GetExternalFields.H index 5e74a409824..8999400ed43 100644 --- a/Source/Particles/Gather/GetExternalFields.H +++ b/Source/Particles/Gather/GetExternalFields.H @@ -58,7 +58,7 @@ struct GetExternalEBField std::optional 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 diff --git a/Source/Particles/Gather/GetExternalFields.cpp b/Source/Particles/Gather/GetExternalFields.cpp index 4aeb6ce05b9..e95d8d977da 100644 --- a/Source/Particles/Gather/GetExternalFields.cpp +++ b/Source/Particles/Gather/GetExternalFields.cpp @@ -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; diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 4eaf89c2aa4..88f292c2836 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -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); } @@ -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); } @@ -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; } @@ -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); } } @@ -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(pc_source.get()); + auto *phys_pc_ptr = static_cast(pc_source.get()); auto Copy = copy_factory.getSmartCopy(); auto Transform = IonizationTransformFunc(); @@ -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(pc_source.get()); + auto *phys_pc_ptr = static_cast(pc_source.get()); const auto Filter = phys_pc_ptr->getPairGenerationFilterFunc(); const auto CopyEle = copy_factory_ele.getSmartCopy(); @@ -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(pc_source.get()); const auto Filter = phys_pc_ptr->getPhotonEmissionFilterFunc(); diff --git a/Source/Particles/ParticleBoundaryBuffer.cpp b/Source/Particles/ParticleBoundaryBuffer.cpp index b6eba51347c..ce7844e654e 100644 --- a/Source/Particles/ParticleBoundaryBuffer.cpp +++ b/Source/Particles/ParticleBoundaryBuffer.cpp @@ -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; diff --git a/Source/Particles/ParticleCreation/FilterCopyTransform.H b/Source/Particles/ParticleCreation/FilterCopyTransform.H index 7a85f59318f..44170decaaa 100644 --- a/Source/Particles/ParticleCreation/FilterCopyTransform.H +++ b/Source/Particles/ParticleCreation/FilterCopyTransform.H @@ -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(); @@ -133,7 +133,7 @@ Index filterCopyTransformParticles (DstTile& dst, SrcTile& src, Index dst_index, Gpu::DeviceVector mask(np); - auto p_mask = mask.dataPtr(); + auto *p_mask = mask.dataPtr(); const auto src_data = src.getParticleTileData(); amrex::ParallelForRNG(np, @@ -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(); @@ -290,7 +290,7 @@ Index filterCopyTransformParticles (DstTile& dst1, DstTile& dst2, SrcTile& src, Gpu::DeviceVector mask(np); - auto p_mask = mask.dataPtr(); + auto *p_mask = mask.dataPtr(); const auto src_data = src.getParticleTileData(); amrex::ParallelForRNG(np, diff --git a/Source/Particles/ParticleCreation/FilterCreateTransformFromFAB.H b/Source/Particles/ParticleCreation/FilterCreateTransformFromFAB.H index 38dc1d6daf2..20757aeeb31 100644 --- a/Source/Particles/ParticleCreation/FilterCreateTransformFromFAB.H +++ b/Source/Particles/ParticleCreation/FilterCreateTransformFromFAB.H @@ -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(); @@ -188,7 +188,7 @@ Index filterCreateTransformFromFAB (DstTile& dst1, DstTile& dst2, const amrex::B Gpu::DeviceVector 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 diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp index 28dfcd8e280..552686813d1 100644 --- a/Source/Particles/PhotonParticleContainer.cpp +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -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, diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 182577a81cf..cf89d93263c 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1107,7 +1107,7 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int // count the number of particles that each cell in overlap_box could add Gpu::DeviceVector counts(overlap_box.numPts(), 0); Gpu::DeviceVector offset(overlap_box.numPts()); - auto pcounts = counts.data(); + auto *pcounts = counts.data(); const amrex::IntVect lrrfac = rrfac; Box fine_overlap_box; // default Box is NOT ok(). if (refine_injection) { @@ -1275,7 +1275,7 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int // particles, in particular does not consider xmin, xmax etc.). // The invalid ones are given negative ID and are deleted during the // next redistribute. - const auto poffset = offset.data(); + auto *const poffset = offset.data(); #ifdef WARPX_DIM_RZ const bool rz_random_theta = m_rz_random_theta; #endif @@ -1679,7 +1679,7 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector, // count the number of particles that each cell in overlap_box could add Gpu::DeviceVector counts(overlap_box.numPts(), 0); Gpu::DeviceVector offset(overlap_box.numPts()); - auto pcounts = counts.data(); + auto *pcounts = counts.data(); const amrex::IntVect lrrfac = rrfac; Box fine_overlap_box; // default Box is NOT ok(). if (refine_injection) { @@ -1828,7 +1828,7 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector, // particles, in particular does not consider xmin, xmax etc.). // The invalid ones are given negative ID and are deleted during the // next redistribute. - const auto poffset = offset.data(); + auto *const poffset = offset.data(); amrex::ParallelForRNG(overlap_box, [=] AMREX_GPU_DEVICE (int i, int j, int k, amrex::RandomEngine const& engine) noexcept { @@ -2653,7 +2653,7 @@ PhysicalParticleContainer::PushP (int lev, Real dt, } // Externally applied E and B-field in Cartesian co-ordinates - [[maybe_unused]] auto& getExternalEB_tmp = getExternalEB; + [[maybe_unused]] const auto& getExternalEB_tmp = getExternalEB; if constexpr (exteb_control == has_exteb) { getExternalEB(ip, Exp, Eyp, Ezp, Bxp, Byp, Bzp); } @@ -2903,7 +2903,7 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti, nox, galerkin_interpolation); } - [[maybe_unused]] auto& getExternalEB_tmp = getExternalEB; + [[maybe_unused]] const auto& getExternalEB_tmp = getExternalEB; if constexpr (exteb_control == has_exteb) { getExternalEB(ip, Exp, Eyp, Ezp, Bxp, Byp, Bzp); } @@ -2940,8 +2940,8 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti, #ifdef WARPX_QED [[maybe_unused]] auto foo_local_has_quantum_sync = local_has_quantum_sync; - [[maybe_unused]] auto foo_podq = p_optical_depth_QSR; - [[maybe_unused]] auto& foo_evolve_opt = evolve_opt; // have to do all these for nvcc + [[maybe_unused]] auto *foo_podq = p_optical_depth_QSR; + [[maybe_unused]] const auto& foo_evolve_opt = evolve_opt; // have to do all these for nvcc if constexpr (qed_control == has_qed) { if (local_has_quantum_sync) { evolve_opt(ux[ip], uy[ip], uz[ip], diff --git a/Source/Particles/Pusher/CopyParticleAttribs.H b/Source/Particles/Pusher/CopyParticleAttribs.H index 1f0cee67421..1a79839db4f 100644 --- a/Source/Particles/Pusher/CopyParticleAttribs.H +++ b/Source/Particles/Pusher/CopyParticleAttribs.H @@ -51,7 +51,7 @@ struct CopyParticleAttribs { if (tmp_particle_data.empty()) return; - auto& attribs = a_pti.GetAttribs(); + const auto& attribs = a_pti.GetAttribs(); uxp = attribs[PIdx::ux].dataPtr() + a_offset; uyp = attribs[PIdx::uy].dataPtr() + a_offset; diff --git a/Source/Particles/Resampling/LevelingThinning.cpp b/Source/Particles/Resampling/LevelingThinning.cpp index e3910286c91..5f4fe0c5642 100644 --- a/Source/Particles/Resampling/LevelingThinning.cpp +++ b/Source/Particles/Resampling/LevelingThinning.cpp @@ -71,8 +71,8 @@ void LevelingThinning::operator() (WarpXParIter& pti, const int lev, auto bins = ParticleUtils::findParticlesInEachCell(lev, pti, ptile); const auto n_cells = static_cast(bins.numBins()); - const auto indices = bins.permutationPtr(); - const auto cell_offsets = bins.offsetsPtr(); + auto *const indices = bins.permutationPtr(); + auto *const cell_offsets = bins.offsetsPtr(); const amrex::Real target_ratio = m_target_ratio; const int min_ppc = m_min_ppc; diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index d0e19af155a..4cee48376a7 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -117,9 +117,9 @@ RigidInjectedParticleContainer::RemapParticles() for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti) { const auto& attribs = pti.GetAttribs(); - const auto uxp = attribs[PIdx::ux].dataPtr(); - const auto uyp = attribs[PIdx::uy].dataPtr(); - const auto uzp = attribs[PIdx::uz].dataPtr(); + const auto *const uxp = attribs[PIdx::ux].dataPtr(); + const auto *const uyp = attribs[PIdx::uy].dataPtr(); + const auto *const uzp = attribs[PIdx::uz].dataPtr(); const auto GetPosition = GetParticlePosition(pti); auto SetPosition = SetParticlePosition(pti); @@ -447,7 +447,7 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt, dx_arr, xyzmin_arr, lo, n_rz_azimuthal_modes, nox, galerkin_interpolation); - [[maybe_unused]] auto& getExternalEB_tmp = getExternalEB; + [[maybe_unused]] const auto& getExternalEB_tmp = getExternalEB; if constexpr (exteb_control == has_exteb) { getExternalEB(ip, Exp, Eyp, Ezp, Bxp, Byp, Bzp); } diff --git a/Source/Particles/Sorting/Partition.cpp b/Source/Particles/Sorting/Partition.cpp index 18bebed185f..58511cfd5e7 100644 --- a/Source/Particles/Sorting/Partition.cpp +++ b/Source/Particles/Sorting/Partition.cpp @@ -76,7 +76,7 @@ PhysicalParticleContainer::PartitionParticlesInBuffers( // - Find the indices that reorder particles so that the last particles // are in the larger buffer fillWithConsecutiveIntegers( pid ); - auto const sep = stablePartition( pid.begin(), pid.end(), inexflag ); + auto *const sep = stablePartition( pid.begin(), pid.end(), inexflag ); // At the end of this step, `pid` contains the indices that should be used to // reorder the particles, and `sep` is the position in the array that // separates the particles that deposit/gather on the fine patch (first part) @@ -110,7 +110,7 @@ PhysicalParticleContainer::PartitionParticlesInBuffers( // the smaller buffer, by looking up the mask. Store the answer in `inexflag`. amrex::ParallelFor( np - n_fine, fillBufferFlagRemainingParticles(pti, bmasks, inexflag, Geom(lev), pid, n_fine) ); - auto const sep2 = stablePartition( sep, pid.end(), inexflag ); + auto *const sep2 = stablePartition( sep, pid.end(), inexflag ); if (bmasks == gather_masks) { nfine_gather = iteratorDistance(pid.begin(), sep2); diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp index d44bc8ad9c3..f2f8d4793be 100644 --- a/Source/Particles/WarpXParticleContainer.cpp +++ b/Source/Particles/WarpXParticleContainer.cpp @@ -470,7 +470,7 @@ WarpXParticleContainer::DepositCurrent (WarpXParIter& pti, { auto& ptile = ParticlesAt(lev, pti); auto& aos = ptile.GetArrayOfStructs(); - auto pstruct_ptr = aos().dataPtr(); + auto *pstruct_ptr = aos().dataPtr(); const int ntiles = numTilesInBox(box, true, bin_size); @@ -795,7 +795,7 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector const& wp, auto& ptile = ParticlesAt(lev, pti); auto& aos = ptile.GetArrayOfStructs(); - auto pstruct_ptr = aos().dataPtr(); + auto *pstruct_ptr = aos().dataPtr(); Box box = pti.validbox(); box.grow(ng_rho); @@ -824,15 +824,15 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector const& wp, auto& ptile = ParticlesAt(lev, pti); auto& aos = ptile.GetArrayOfStructs(); - auto pstruct_ptr = aos().dataPtr(); + auto *pstruct_ptr = aos().dataPtr(); Box box = pti.validbox(); box.grow(ng_rho); const amrex::IntVect bin_size = WarpX::shared_tilesize; - const auto offsets_ptr = bins.offsetsPtr(); - auto tbox_ptr = tboxes.dataPtr(); - auto permutation = bins.permutationPtr(); + auto *const offsets_ptr = bins.offsetsPtr(); + auto *tbox_ptr = tboxes.dataPtr(); + auto *permutation = bins.permutationPtr(); amrex::ParallelFor(bins.numBins(), [=] AMREX_GPU_DEVICE (int ibin) { const auto bin_start = offsets_ptr[ibin]; @@ -857,7 +857,7 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector const& wp, ReduceData reduce_data(reduce_op); using ReduceTuple = typename decltype(reduce_data)::Type; - const auto boxes_ptr = tboxes.dataPtr(); + auto *const boxes_ptr = tboxes.dataPtr(); reduce_op.eval(tboxes.size(), reduce_data, [=] AMREX_GPU_DEVICE (int i) -> ReduceTuple { @@ -1107,7 +1107,7 @@ amrex::ParticleReal WarpXParticleContainer::sumParticleCharge(bool local) { for (int lev = 0; lev <= nLevels; ++lev) { for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti) { - const auto wp = pti.GetAttribs(PIdx::w).data(); + auto *const wp = pti.GetAttribs(PIdx::w).data(); reduce_op.eval(pti.numParticles(), reduce_data, [=] AMREX_GPU_DEVICE (int ip) diff --git a/Source/Utils/ParticleUtils.H b/Source/Utils/ParticleUtils.H index ecd6b7c2739..b04176d4d83 100644 --- a/Source/Utils/ParticleUtils.H +++ b/Source/Utils/ParticleUtils.H @@ -181,8 +181,8 @@ namespace ParticleUtils { */ AMREX_GPU_HOST_DEVICE AMREX_INLINE bool containsInclusive (amrex::RealBox const& tilebox, amrex::XDim3 const point) { - const auto xlo = tilebox.lo(); - const auto xhi = tilebox.hi(); + const auto *const xlo = tilebox.lo(); + const auto *const xhi = tilebox.hi(); return AMREX_D_TERM((xlo[0] <= point.x) && (point.x <= xhi[0]), && (xlo[1] <= point.y) && (point.y <= xhi[1]), && (xlo[2] <= point.z) && (point.z <= xhi[2])); diff --git a/Source/ablastr/utils/Communication.cpp b/Source/ablastr/utils/Communication.cpp index c33e6a1d154..ab33305f4df 100644 --- a/Source/ablastr/utils/Communication.cpp +++ b/Source/ablastr/utils/Communication.cpp @@ -124,7 +124,7 @@ void FillBoundary (amrex::Vector const &mf, bool do_single_precision_comms, const amrex::Periodicity &period, std::optional nodal_sync) { - for (auto x : mf) { + for (auto *x : mf) { ablastr::utils::communication::FillBoundary(*x, do_single_precision_comms, period, nodal_sync); } } diff --git a/Source/ablastr/utils/SignalHandling.cpp b/Source/ablastr/utils/SignalHandling.cpp index 18d43409ec3..24a776fbccb 100644 --- a/Source/ablastr/utils/SignalHandling.cpp +++ b/Source/ablastr/utils/SignalHandling.cpp @@ -171,12 +171,12 @@ SignalHandling::CheckSignals () } #if defined(AMREX_USE_MPI) - auto comm = amrex::ParallelDescriptor::Communicator(); // Due to a bug in Cray's MPICH 8.1.13 implementation (CUDA builds on Perlmutter@NERSC in 2022), // we cannot use the MPI_CXX_BOOL C++ datatype here. See WarpX PR #3029 and NERSC INC0183281 static_assert(sizeof(bool) == 1, "We communicate bools as 1 byte-sized type in MPI"); BL_MPI_REQUIRE(MPI_Ibcast(signal_actions_requested, SIGNAL_REQUESTS_SIZE, - MPI_BYTE, 0, comm,&signal_mpi_ibcast_request)); + MPI_BYTE, 0, amrex::ParallelDescriptor::Communicator(), + &signal_mpi_ibcast_request)); #endif }