Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang-Tidy 17: performance-avoid-endl #3830

Merged
merged 2 commits into from
Mar 21, 2024
Merged
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
12 changes: 7 additions & 5 deletions Src/Amr/AMReX_Amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2206,7 +2206,8 @@ Amr::coarseTimeStep (Real stop_time)
}
if (record_run_info_terse && ParallelDescriptor::IOProcessor()) {
runlog_terse << level_steps[0] << " " << cumtime << " " << dt_level[0];
runlog_terse << std::endl; // Make sure we flush!
runlog_terse << '\n';
runlog_terse.flush();
}

int check_test = 0;
Expand Down Expand Up @@ -2346,11 +2347,11 @@ Amr::coarseTimeStep (Real stop_time)
if(ParallelDescriptor::IOProcessor()) {
if (to_checkpoint)
{
amrex::ErrorStream() << "Stopped by user w/ checkpoint" << std::endl;
amrex::ErrorStream() << "Stopped by user w/ checkpoint" << '\n';
}
else
{
amrex::ErrorStream() << "Stopped by user w/o checkpoint" << std::endl;
amrex::ErrorStream() << "Stopped by user w/o checkpoint" << '\n';
}
}
}
Expand Down Expand Up @@ -2735,7 +2736,7 @@ Amr::regrid (int lbase,
<< time
<< " : REGRID with lbase = "
<< lbase
<< std::endl;
<< '\n';

if (verbose > 1)
{
Expand Down Expand Up @@ -2916,7 +2917,8 @@ Amr::printGridInfo (std::ostream& os,
}
}

os << std::endl; // Make sure we flush!
os << '\n';
os.flush();
}


Expand Down
3 changes: 2 additions & 1 deletion Src/AmrCore/AMReX_AmrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ AmrCore::printGridSummary (std::ostream& os, int min_lev, int max_lev) const noe
}
}

os << std::endl; // Make sure we flush!
os << '\n';
os.flush();
}

}
20 changes: 10 additions & 10 deletions Src/AmrCore/AMReX_AmrMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,12 +1133,12 @@ AmrMesh::checkInput ()
{
int len = domain.length(idim);
if (blocking_factor[0][idim] <= max_grid_size[0][idim]) {
if (len%blocking_factor[0][idim] != 0)
{
amrex::Print() << "domain size in direction " << idim << " is " << len << std::endl;
amrex::Print() << "blocking_factor is " << blocking_factor[0][idim] << std::endl;
amrex::Error("domain size not divisible by blocking_factor");
}
if (len%blocking_factor[0][idim] != 0)
{
amrex::Print() << "domain size in direction " << idim << " is " << len << '\n'
<< "blocking_factor is " << blocking_factor[0][idim] << '\n';
amrex::Error("domain size not divisible by blocking_factor");
}
}
}

Expand Down Expand Up @@ -1168,7 +1168,7 @@ AmrMesh::checkInput ()
amrex::Print() << "Blocking factors on levels " << i << " and " << i+1
<< " are " << blocking_factor[i] << " " << blocking_factor[i+1]
<< ". Ref ratio is " << ref_ratio[i]
<< ". They vary too much between levels." << std::endl;
<< ". They vary too much between levels." << '\n';
amrex::Error("Blocking factors vary too much between levels");
}
}
Expand All @@ -1183,8 +1183,8 @@ AmrMesh::checkInput ()
if (blocking_factor[i][idim] <= max_grid_size[i][idim]) {
if (max_grid_size[i][idim]%blocking_factor[i][idim] != 0) {
amrex::Print() << "max_grid_size in direction " << idim
<< " is " << max_grid_size[i][idim] << std::endl;
amrex::Print() << "blocking_factor is " << blocking_factor[i][idim] << std::endl;
<< " is " << max_grid_size[i][idim] << '\n'
<< "blocking_factor is " << blocking_factor[i][idim] << '\n';
amrex::Error("max_grid_size not divisible by blocking_factor");
}
}
Expand All @@ -1201,7 +1201,7 @@ AmrMesh::checkInput ()
<< " max_grid_size is " << max_grid_size[i][idim]
<< " blocking factor is " << blocking_factor[i][idim] << "\n"
<< "On level " << i+1 << " in direction " << idim
<< " blocking_factor is " << blocking_factor[i+1][idim] << std::endl;
<< " blocking_factor is " << blocking_factor[i+1][idim] << '\n';
amrex::Error("Coarse level blocking factor not a multiple of fine level blocking factor divided by ref ratio");
}
}
Expand Down
8 changes: 4 additions & 4 deletions Src/Base/AMReX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
<< " MPI processes\n";
int provided = -1;
MPI_Query_thread(&provided);
amrex::Print() << "MPI initialized with thread support level " << provided << std::endl;
amrex::Print() << "MPI initialized with thread support level " << provided << '\n';
}
#endif

Expand Down Expand Up @@ -688,7 +688,7 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
#endif

if (system::verbose > 0) {
amrex::Print() << "AMReX (" << amrex::Version() << ") initialized" << std::endl;
amrex::Print() << "AMReX (" << amrex::Version() << ") initialized" << '\n';
}

BL_TINY_PROFILE_INITIALIZE();
Expand Down Expand Up @@ -759,7 +759,7 @@ amrex::Finalize (amrex::AMReX* pamrex)
<< "min used in a thread: " << mp_min << " MB, "
<< "max used in a thread: " << mp_max << " MB, "
#endif
<< "tot used: " << mp_tot << " MB." << std::endl;
<< "tot used: " << mp_tot << " MB." << '\n';
}
} else {
int global_max = mp_tot;
Expand Down Expand Up @@ -838,7 +838,7 @@ amrex::Finalize (amrex::AMReX* pamrex)
#endif

if (amrex::system::verbose > 0 && is_ioproc) {
amrex::OutStream() << "AMReX (" << amrex::Version() << ") finalized" << std::endl;
amrex::OutStream() << "AMReX (" << amrex::Version() << ") finalized" << '\n';
}
}

Expand Down
8 changes: 4 additions & 4 deletions Src/Base/AMReX_BLBackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ BLBackTrace::handler(int s)
fclose(p);
}

amrex::ErrorStream() << "See " << errfilename << " file for details" << std::endl;
amrex::ErrorStream() << "See " << errfilename << " file for details" << '\n';

if (!bt_stack.empty()) {
std::ofstream errfile;
errfile.open(errfilename.c_str(), std::ofstream::out | std::ofstream::app);
if (errfile.is_open()) {
errfile << std::endl;
errfile << '\n';
while (!bt_stack.empty()) {
errfile << "== BACKTRACE == " << bt_stack.top().first
<<", " << bt_stack.top().second << "\n";
bt_stack.pop();
}
errfile << std::endl;
errfile << '\n';
}
}

Expand Down Expand Up @@ -149,7 +149,7 @@ BLBackTrace::print_backtrace_info (const std::string& filename)
{
amrex::Print() << "Warning @ BLBackTrace::print_backtrace_info: "
<< filename << " is not a valid output file."
<< std::endl;
<< '\n';
}
}

Expand Down
42 changes: 21 additions & 21 deletions Src/Base/AMReX_DistributionMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ DistributionMapping::LeastUsedCPUs (int nprocs,
}

if (flag_verbose_mapper) {
Print() << "LeastUsedCPUs:" << std::endl;
Print() << "LeastUsedCPUs:" << '\n';
for (const auto &p : LIpairV) {
Print() << " Rank " << p.second << " contains " << p.first << std::endl;
Print() << " Rank " << p.second << " contains " << p.first << '\n';
}
}
#else
Expand Down Expand Up @@ -368,7 +368,7 @@ DistributionMapping::RoundRobinDoIt (int nboxes,
bool sort)
{
if (flag_verbose_mapper) {
Print() << "DM: RoundRobinDoIt called..." << std::endl;
Print() << "DM: RoundRobinDoIt called..." << '\n';
}

int nprocs = ParallelContext::NProcsSub();
Expand Down Expand Up @@ -426,7 +426,7 @@ DistributionMapping::RoundRobinDoIt (int nboxes,
m_ref->m_pmap[(*LIpairV)[i].second] = ParallelContext::local_to_global_rank(rank);
if (flag_verbose_mapper) {
Print() << " Mapping box " << (*LIpairV)[i].second << " of size "
<< (*LIpairV)[i].first << " to rank " << rank << std::endl;
<< (*LIpairV)[i].first << " to rank " << rank << '\n';
}
}
}
Expand All @@ -439,7 +439,7 @@ DistributionMapping::RoundRobinDoIt (int nboxes,
int rank = tid*nworkers + wrkerord[tid][wid];
m_ref->m_pmap[i] = ParallelContext::local_to_global_rank(rank);
if (flag_verbose_mapper) {
Print() << " Mapping box " << i << " to rank " << rank << std::endl;
Print() << " Mapping box " << i << " to rank " << rank << '\n';
}
}
}
Expand Down Expand Up @@ -723,7 +723,7 @@ DistributionMapping::KnapSackDoIt (const std::vector<Long>& wgts,
bool sort)
{
if (flag_verbose_mapper) {
Print() << "DM: KnapSackDoIt called..." << std::endl;
Print() << "DM: KnapSackDoIt called..." << '\n';
}

BL_PROFILE("DistributionMapping::KnapSackDoIt()");
Expand All @@ -748,9 +748,9 @@ DistributionMapping::KnapSackDoIt (const std::vector<Long>& wgts,

if (flag_verbose_mapper) {
for (int i = 0, ni = static_cast<int>(vec.size()); i < ni; ++i) {
Print() << " Bucket " << i << " contains boxes:" << std::endl;
Print() << " Bucket " << i << " contains boxes:" << '\n';
for (int x : vec[i]) {
Print() << " " << x << std::endl;
Print() << " " << x << '\n';
}
}
}
Expand All @@ -775,7 +775,7 @@ DistributionMapping::KnapSackDoIt (const std::vector<Long>& wgts,

if (flag_verbose_mapper) {
for (const auto &p : LIpairV) {
Print() << " Bucket " << p.second << " total weight: " << p.first << std::endl;
Print() << " Bucket " << p.second << " total weight: " << p.first << '\n';
}
}

Expand Down Expand Up @@ -812,7 +812,7 @@ DistributionMapping::KnapSackDoIt (const std::vector<Long>& wgts,
const int N = static_cast<int>(vi.size());

if (flag_verbose_mapper) {
Print() << " Mapping bucket " << idx << " to rank " << tid << std::endl;
Print() << " Mapping bucket " << idx << " to rank " << tid << '\n';
}

if (nteams == nprocs) {
Expand Down Expand Up @@ -1184,14 +1184,14 @@ Distribute (const std::vector<SFCToken>& tokens,
BL_PROFILE("DistributionMapping::Distribute()");

if (flag_verbose_mapper) {
Print() << "Distribute:" << std::endl;
Print() << " volpercpu: " << volpercpu << std::endl;
Print() << " Sorted SFC Tokens:" << std::endl;
Print() << "Distribute:" << '\n'
<< " volpercpu: " << volpercpu << '\n'
<< " Sorted SFC Tokens:" << '\n';
int idx = 0;
for (const auto &t : tokens) {
Print() << " " << idx++ << ": "
<< t.m_box << ": "
<< t.m_morton << std::endl;
<< t.m_morton << '\n';
}
}

Expand Down Expand Up @@ -1228,22 +1228,22 @@ Distribute (const std::vector<SFCToken>& tokens,
}

if (flag_verbose_mapper) {
Print() << "Distributed SFC Tokens:" << std::endl;
Print() << "Distributed SFC Tokens:" << '\n';
int idx = 0;
for (int i = 0; i < nprocs; ++i) {
Print() << " Rank/Team " << i << ":" << std::endl;
Print() << " Rank/Team " << i << ":" << '\n';
Real rank_vol = 0;
for (const auto &box : v[i]) {
amrex::ignore_unused(box);
const auto &t = tokens[idx];
BL_ASSERT(box == t.m_box);
Print() << " " << idx << ": "
<< t.m_box << ": "
<< t.m_morton << std::endl;
<< t.m_morton << '\n';
rank_vol += static_cast<Real>(wgts[t.m_box]);
idx++;
}
Print() << " Total Rank Vol: " << rank_vol << std::endl;
Print() << " Total Rank Vol: " << rank_vol << '\n';
}
}

Expand All @@ -1265,7 +1265,7 @@ DistributionMapping::SFCProcessorMapDoIt (const BoxArray& boxes,
Real* eff)
{
if (flag_verbose_mapper) {
Print() << "DM: SFCProcessorMapDoIt called..." << std::endl;
Print() << "DM: SFCProcessorMapDoIt called..." << '\n';
}

BL_PROFILE("DistributionMapping::SFCProcessorMapDoIt()");
Expand Down Expand Up @@ -1341,7 +1341,7 @@ DistributionMapping::SFCProcessorMapDoIt (const BoxArray& boxes,

if (flag_verbose_mapper) {
for (const auto &p : LIpairV) {
Print() << " Bucket " << p.second << " contains " << p.first << std::endl;
Print() << " Bucket " << p.second << " contains " << p.first << '\n';
}
}

Expand Down Expand Up @@ -1384,7 +1384,7 @@ DistributionMapping::SFCProcessorMapDoIt (const BoxArray& boxes,
const int Nbx = static_cast<int>(vi.size());// # of boxes assigned to this team

if (flag_verbose_mapper) {
Print() << "Mapping bucket " << LIpairV[i].second << " to rank " << ord[i] << std::endl;
Print() << "Mapping bucket " << LIpairV[i].second << " to rank " << ord[i] << '\n';
}

if (nteams == nprocs) { // In this case, team id is process id.
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_FACopyDescriptor.H
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ FabArrayCopyDescriptor<FAB>::CollectData ()
const int Who = it->procThatHasData;
const auto Cnt = static_cast<int>((it->box.numPts())*(it->nComp));

RcvTags[Who].push_back(it);
RcvTags[Who].emplace_back(it);

Total_Rcvs_Size += Cnt;

Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_FabArrayUtility.H
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ printCell (FabArray<FAB> const& mf, const IntVect& cell, int comp = -1,
}
ss << dp[n-1];
amrex::AllPrint() << " At cell " << cell << " in Box " << bx
<< ": " << ss.str() << std::endl;
<< ": " << ss.str() << '\n';
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ CreateDirectories (std::string const& path, mode_t mode, bool verbose)
amrex::AllPrint()<< "amrex::UtilCreateDirectory:: path errno: "
<< pathError[i].first << " :: "
<< strerror(pathError[i].second)
<< std::endl;
<< '\n';
}
}

Expand Down
Loading
Loading