Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Checks: >
-modernize-use-constraints,
-modernize-use-designated-initializers,
-modernize-use-integer-sign-comparison,
-modernize-use-ranges,
-modernize-use-starts-ends-with,
-modernize-use-std-numbers,
-modernize-use-trailing-return-type,
Expand Down Expand Up @@ -81,6 +80,5 @@ HeaderFileExtensions: ['', "H", 'h', 'hh', 'hpp', 'hxx']
# -modernize-use-constraints
# -modernize-use-designated-initializers
# -modernize-use-std-numbers
# -modernize-use-ranges
# -modernize-use-integer-sign-comparison
# -modernize-use-starts-ends-with
8 changes: 4 additions & 4 deletions Src/Amr/AMReX_Amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,14 @@ Amr::finalizeInSitu()
bool
Amr::isStatePlotVar (const std::string& name)
{
auto it = std::find(state_plot_vars.begin(), state_plot_vars.end(), name);
auto it = std::ranges::find(state_plot_vars, name);
return (it != state_plot_vars.end());
}

bool
Amr::isStateSmallPlotVar (const std::string& name)
{
auto it = std::find(state_small_plot_vars.begin(), state_small_plot_vars.end(), name);
auto it = std::ranges::find(state_small_plot_vars, name);
return (it != state_small_plot_vars.end());
}

Expand Down Expand Up @@ -676,14 +676,14 @@ Amr::deleteStatePlotVar (const std::string& name)
bool
Amr::isDerivePlotVar (const std::string& name) noexcept
{
auto it = std::find(derive_plot_vars.begin(), derive_plot_vars.end(), name);
auto it = std::ranges::find(derive_plot_vars, name);
return (it != derive_plot_vars.end());
}

bool
Amr::isDeriveSmallPlotVar (const std::string& name) noexcept
{
auto it = std::find(derive_small_plot_vars.begin(), derive_small_plot_vars.end(), name);
auto it = std::ranges::find(derive_small_plot_vars, name);
return (it != derive_small_plot_vars.end());
}

Expand Down
2 changes: 1 addition & 1 deletion Src/AmrCore/AMReX_AmrMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ AmrMesh::ChopGrids (int lev, BoxArray& ba, int target_size) const
chunk_dir{AMREX_D_DECL(std::make_pair(chunk[0],int(0)),
std::make_pair(chunk[1],int(1)),
std::make_pair(chunk[2],int(2)))};
std::sort(chunk_dir.begin(), chunk_dir.end());
std::ranges::sort(chunk_dir);

for (int idx = AMREX_SPACEDIM-1; idx >= 0; idx--) {
int idim = chunk_dir[idx].second;
Expand Down
8 changes: 4 additions & 4 deletions Src/AmrCore/AMReX_FillPatcher.H
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ FillPatcher<MF>::fillCoarseFineBoundary (MF& mf, IntVect const& nghost, Real tim
int ncmfs = cmf.size();
for (int icmf = 0; icmf < ncmfs; ++icmf) {
Real t = ct[icmf];
auto it = std::find_if(m_cf_crse_data.begin(), m_cf_crse_data.end(),
[=] (auto const& x) {
return amrex::almostEqual(x.first,t,5);
});
auto it = std::ranges::find_if(m_cf_crse_data,
[=] (auto const& x) {
return amrex::almostEqual(x.first,t,5);
});

if (it == std::end(m_cf_crse_data)) {
MF mf_crse_patch = detail::make_mf_crse_patch<MF>(fpc, m_ncomp);
Expand Down
4 changes: 2 additions & 2 deletions Src/AmrCore/AMReX_TagBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ TagBoxArray::collate (Gpu::PinnedVector<IntVect>& TheGlobalCollateSpace) const
auto countvec_int = std::vector<int>(countvec.size());
auto offset_int = std::vector<int>(offset.size());
const auto mul_funct = [](const auto el){return el*AMREX_SPACEDIM;};
std::transform(countvec.begin(), countvec.end(), countvec_int.begin(), mul_funct);
std::transform(offset.begin(), offset.end(), offset_int.begin(), mul_funct);
std::ranges::transform(countvec, countvec_int.begin(), mul_funct);
std::ranges::transform(offset, offset_int.begin(), mul_funct);
ParallelDescriptor::Gatherv(
psend_int, count_int, precv_int, countvec_int, offset_int, IOProcNumber);
#endif
Expand Down
12 changes: 6 additions & 6 deletions Src/Base/AMReX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,9 @@ AMReX::~AMReX ()
void
AMReX::push (AMReX* pamrex)
{
auto r = std::find_if(m_instance.begin(), m_instance.end(),
[=] (const std::unique_ptr<AMReX>& x) -> bool
{ return x.get() == pamrex; });
auto r = std::ranges::find_if(m_instance,
[=] (const std::unique_ptr<AMReX>& x) -> bool
{ return x.get() == pamrex; });
if (r == m_instance.end()) {
m_instance.emplace_back(pamrex);
} else if (r+1 != m_instance.end()) {
Expand All @@ -1021,9 +1021,9 @@ AMReX::push (std::unique_ptr<AMReX> pamrex)
void
AMReX::erase (AMReX* pamrex)
{
auto r = std::find_if(m_instance.begin(), m_instance.end(),
[=] (const std::unique_ptr<AMReX>& x) -> bool
{ return x.get() == pamrex; });
auto r = std::ranges::find_if(m_instance,
[=] (const std::unique_ptr<AMReX>& x) -> bool
{ return x.get() == pamrex; });
if (r != m_instance.end()) {
m_instance.erase(r);
}
Expand Down
10 changes: 5 additions & 5 deletions Src/Base/AMReX_BoxArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ bool match (const BoxArray& x, const BoxArray& y)
BoxArray decompose (Box const& domain, int nboxes,
Array<bool,AMREX_SPACEDIM> const& decomp, bool no_overlap)
{
auto ndecomp = std::count(decomp.begin(), decomp.end(), true);
auto ndecomp = std::ranges::count(decomp, true);

if (nboxes <= 1 || ndecomp == 0) {
return BoxArray(domain);
Expand Down Expand Up @@ -2021,7 +2021,7 @@ BoxArray decompose (Box const& domain, int nboxes,

int nprocs_tot = 1;
while (!factors.empty()) {
std::sort(procdim.begin(), procdim.end(), comp);
std::ranges::sort(procdim, comp);
auto f = factors.back();
factors.pop_back();
procdim.back().nproc *= f;
Expand All @@ -2035,9 +2035,9 @@ BoxArray decompose (Box const& domain, int nboxes,
// swap to see if the decomposition can be improved.
while (true)
{
std::sort(procdim.begin(), procdim.end(), comp);
auto fit = std::find_if(procdim.begin(),procdim.end(),
[] (ProcDim const& x) { return x.nproc > 1; });
std::ranges::sort(procdim, comp);
auto fit = std::ranges::find_if(procdim,
[] (ProcDim const& x) { return x.nproc > 1; });
if (fit == procdim.end()) { break; } // This should not actually happen.
auto& light = *fit;
auto& heavy = procdim.back();
Expand Down
8 changes: 4 additions & 4 deletions Src/Base/AMReX_BoxList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ BoxList::BoxList (const Box& bx, int nboxes, Direction dir)
bool
BoxList::ok () const noexcept
{
return std::all_of(this->cbegin(), this->cend(),
[] (Box const& b) { return b.ok(); });
return std::ranges::all_of(*this,
[] (Box const& b) { return b.ok(); });
}

bool
Expand All @@ -259,8 +259,8 @@ BoxList::contains (const BoxList& bl) const

BoxArray ba(*this);

return std::all_of(bl.cbegin(), bl.cend(),
[&ba] (Box const& b) { return ba.contains(b); });
return std::ranges::all_of(bl,
[&ba] (Box const& b) { return ba.contains(b); });
}

BoxList&
Expand Down
10 changes: 5 additions & 5 deletions Src/Base/AMReX_DistributionMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ DistributionMapping::Sort (std::vector<LIpair>& vec,
if (vec.size() > 1)
{
if (reverse) {
std::stable_sort(vec.begin(), vec.end(), LIpairGT());
std::ranges::stable_sort(vec, LIpairGT());
}
else {
std::stable_sort(vec.begin(), vec.end(), LIpairLT());
std::ranges::stable_sort(vec, LIpairLT());
}
}
}
Expand Down Expand Up @@ -1049,8 +1049,8 @@ DistributionMapping::KnapSackProcessorMap (const DistributionMapping& olddm,
}
}

AMREX_ASSERT(std::none_of(m_ref->m_pmap.cbegin(), m_ref->m_pmap.cend(),
[] (int i) { return i < 0; }));
AMREX_ASSERT(std::ranges::none_of(m_ref->m_pmap,
[] (int i) { return i < 0; }));
}
}
}
Expand Down Expand Up @@ -1590,7 +1590,7 @@ DistributionMapping::ConvertCostRealToLong (const Vector<Real>& rcost)
{
Vector<Long> cost(rcost.size());

Real wmax = *std::max_element(rcost.begin(), rcost.end());
Real wmax = *std::ranges::max_element(rcost);
Real scale = (wmax == 0) ? 1.e9_rt : 1.e9_rt/wmax;

for (Long i = 0; i < rcost.size(); ++i) {
Expand Down
24 changes: 12 additions & 12 deletions Src/Base/AMReX_Enum.H
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ namespace detail
} else if (kv.size() == 2) {
auto const& value_string = amrex::trim(kv[1]);
// For k = v, find if v exists as a key. If not, v must be an int.
auto it = std::find_if(r.begin(), r.end(),
[&] (auto const& x) -> bool
{ return x.first == value_string; });
auto it = std::ranges::find_if(r,
[&] (auto const& x) -> bool
{ return x.first == value_string; });
T this_value;
if (it != r.end()) {
this_value = it->second;
Expand Down Expand Up @@ -90,9 +90,9 @@ namespace detail
T getEnum (std::string_view const& s)
{
auto const& kv = getEnumNameValuePairs<T>();
auto it = std::find_if(kv.begin(), kv.end(),
[&] (auto const& x) -> bool
{ return x.first == s; });
auto it = std::ranges::find_if(kv,
[&] (auto const& x) -> bool
{ return x.first == s; });
if (it != kv.end()) {
return it->second;
} else {
Expand Down Expand Up @@ -125,9 +125,9 @@ namespace detail
{
auto const& kv = getEnumNameValuePairs<T>();
std::string ls = amrex::toLower(std::string(s));
auto it = std::find_if(kv.begin(), kv.end(),
[&] (auto const& x) -> bool
{ return amrex::toLower(x.first) == ls; });
auto it = std::ranges::find_if(kv,
[&] (auto const& x) -> bool
{ return amrex::toLower(x.first) == ls; });
if (it != kv.end()) {
return it->second;
} else {
Expand Down Expand Up @@ -157,9 +157,9 @@ namespace detail
std::string getEnumNameString (T const& v)
{
auto const& kv = getEnumNameValuePairs<T>();
auto it = std::find_if(kv.begin(), kv.end(),
[&] (auto const& x) -> bool
{ return x.second == v; });
auto it = std::ranges::find_if(kv,
[&] (auto const& x) -> bool
{ return x.second == v; });
if (it != kv.end()) {
return it->first;
} else {
Expand Down
8 changes: 4 additions & 4 deletions Src/Base/AMReX_FBI.H
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,8 @@ FabArray<FAB>::get_send_copy_tag_vector (Vector<char*> const& send_data,
{
using TagType = CommSendBufTag<value_type>;

auto kit = std::find_if(send_cctc.begin(), send_cctc.end(),
[] (CopyComTagsContainer const* p) { return p != nullptr; });
auto kit = std::ranges::find_if(send_cctc,
[] (CopyComTagsContainer const* p) { return p != nullptr; });
if (kit == send_cctc.end()) {
return nullptr;
}
Expand Down Expand Up @@ -1147,8 +1147,8 @@ FabArray<FAB>::get_recv_copy_tag_vector (Vector<char*> const& recv_data,
{
using TagType = CommRecvBufTag<value_type>;

auto kit = std::find_if(recv_cctc.begin(), recv_cctc.end(),
[] (CopyComTagsContainer const* p) { return p != nullptr; });
auto kit = std::ranges::find_if(recv_cctc,
[] (CopyComTagsContainer const* p) { return p != nullptr; });
if (kit == recv_cctc.end()) {
return nullptr;
}
Expand Down
6 changes: 3 additions & 3 deletions Src/Base/AMReX_FabArrayBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2403,9 +2403,9 @@ FabArrayBase::buildTileArray (const IntVect& tileSize, TileArray& ta) const
const int nworkers = ParallelDescriptor::TeamSize();
if (nworkers > 1) {
// reorder it so that each worker will be more likely to work on their own fabs
std::stable_sort(local_idxs.begin(), local_idxs.end(), [this](int i, int j)
{ return this->distributionMap[this->indexArray[i]]
< this->distributionMap[this->indexArray[j]]; });
std::ranges::stable_sort(local_idxs, [this](int i, int j)
{ return this->distributionMap[this->indexArray[i]]
< this->distributionMap[this->indexArray[j]]; });
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions Src/Base/AMReX_FabArrayCommI.H
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ FabArray<FAB>::FillBoundary_finish ()
}
}

int actual_n_rcvs = N_rcvs - std::count(fbd->recv_data.begin(), fbd->recv_data.end(), nullptr);
int actual_n_rcvs = N_rcvs - std::ranges::count(fbd->recv_data, nullptr);

if (actual_n_rcvs > 0) {
ParallelDescriptor::Waitall(fbd->recv_reqs, fbd->recv_stat);
Expand Down Expand Up @@ -597,7 +597,7 @@ FabArray<FAB>::ParallelCopy_nowait (const FabArray<FAB>& src,
if (N_rcvs > 0) {
PostRcvs(*thecpc.m_RcvTags, pcd->the_recv_data,
pcd->recv_data, pcd->recv_size, pcd->recv_from, pcd->recv_reqs, NC, pcd->tag);
pcd->actual_n_rcvs = N_rcvs - std::count(pcd->recv_size.begin(), pcd->recv_size.end(), 0);
pcd->actual_n_rcvs = N_rcvs - std::ranges::count(pcd->recv_size, 0);
}

//
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_GpuDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ Device::initialize_gpu (bool minimal)
}
#endif
}
auto found = std::find(sgss.begin(), sgss.end(), static_cast<decltype(sgss)::value_type>(warp_size));
auto found = std::ranges::find(sgss, static_cast<decltype(sgss)::value_type>(warp_size));
if (found == sgss.end()) { amrex::Abort("Incorrect subgroup size"); }
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions Src/Base/AMReX_MPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ namespace {
template <typename T>
int num_unique_elements (std::vector<T>& v)
{
std::sort(v.begin(), v.end());
auto last = std::unique(v.begin(), v.end());
return last - v.begin();
std::ranges::sort(v);
auto last = std::ranges::unique(v);
return static_cast<int>(last.begin() - v.begin());
}

}
Expand Down
8 changes: 4 additions & 4 deletions Src/Base/AMReX_MemProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void
MemProfiler::add (const std::string& name, std::function<MemInfo()>&& f)
{
MemProfiler& mprofiler = getInstance();
auto it = std::find(mprofiler.the_names.begin(), mprofiler.the_names.end(), name);
auto it = std::ranges::find(mprofiler.the_names, name);
if (it != mprofiler.the_names.end()) {
std::string s = "MemProfiler::add (MemInfo) failed because " + name + " already existed";
amrex::Abort(s.c_str());
Expand All @@ -38,7 +38,7 @@ void
MemProfiler::add (const std::string& name, std::function<NBuildsInfo()>&& f)
{
MemProfiler& mprofiler = getInstance();
auto it = std::find(mprofiler.the_names_builds.begin(), mprofiler.the_names_builds.end(), name);
auto it = std::ranges::find(mprofiler.the_names_builds, name);
if (it != mprofiler.the_names_builds.end()) {
std::string s = "MemProfiler::add (NBuildsInfo) failed because " + name + " already existed";
amrex::Abort(s.c_str());
Expand Down Expand Up @@ -249,8 +249,8 @@ MemProfiler::report_ (const std::string& prefix, const std::string& memory_log_n

std::vector<int> idxs(the_names.size());
std::iota(idxs.begin(), idxs.end(), 0);
std::sort(idxs.begin(), idxs.end(), [&](int i, int j)
{ return hwm_max[i] > hwm_max[j]; });
std::ranges::sort(idxs, [&](int i, int j)
{ return hwm_max[i] > hwm_max[j]; });

for (int ii = 0; ii < idxs.size(); ++ii) {
int i = idxs[ii];
Expand Down
21 changes: 12 additions & 9 deletions Src/Base/AMReX_ParallelDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,21 @@ namespace amrex::ParallelDescriptor {
std::vector<unsigned short> PMI_y_meshcoord(all_y_meshcoords, all_y_meshcoords + ParallelDescriptor::NProcs());
std::vector<unsigned short> PMI_z_meshcoord(all_z_meshcoords, all_z_meshcoords + ParallelDescriptor::NProcs());

std::sort(PMI_x_meshcoord.begin(), PMI_x_meshcoord.end());
std::sort(PMI_y_meshcoord.begin(), PMI_y_meshcoord.end());
std::sort(PMI_z_meshcoord.begin(), PMI_z_meshcoord.end());
std::ranges::sort(PMI_x_meshcoord);
std::ranges::sort(PMI_y_meshcoord);
std::ranges::sort(PMI_z_meshcoord);

auto last = std::unique(PMI_x_meshcoord.begin(), PMI_x_meshcoord.end());
amrex::Print() << "# of unique groups: " << std::distance(PMI_x_meshcoord.begin(), last) << '\n';
auto last = std::ranges::unique(PMI_x_meshcoord);
amrex::Print() << "# of unique groups: "
<< std::distance(PMI_x_meshcoord.begin(), last.begin()) << '\n';

last = std::unique(PMI_y_meshcoord.begin(), PMI_y_meshcoord.end());
amrex::Print() << "# of unique groups: " << std::distance(PMI_y_meshcoord.begin(), last) << '\n';
last = std::ranges::unique(PMI_y_meshcoord);
amrex::Print() << "# of unique groups: "
<< std::distance(PMI_y_meshcoord.begin(), last.begin()) << '\n';

last = std::unique(PMI_z_meshcoord.begin(), PMI_z_meshcoord.end());
amrex::Print() << "# of unique groups: " << std::distance(PMI_z_meshcoord.begin(), last) << '\n';
last = std::ranges::unique(PMI_z_meshcoord);
amrex::Print() << "# of unique groups: "
<< std::distance(PMI_z_meshcoord.begin(), last.begin()) << '\n';
}
#endif

Expand Down
Loading
Loading