Skip to content

Commit

Permalink
Remaining clang-tidy@17 updates for draco
Browse files Browse the repository at this point in the history
  • Loading branch information
KineticTheory authored and berselius committed Oct 15, 2024
1 parent 2e579fb commit 73e5605
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 247 deletions.
5 changes: 2 additions & 3 deletions src/FortranChecks/fc_derived_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* \note Copyright (C) 2012-2024 Triad National Security, LLC., All rights reserved. */
//------------------------------------------------------------------------------------------------//

#include "dsxx/config.h"
#include <cmath>
#include <cstdint> // int64_t
#include <iostream>

//! Define the derived type as a C structure
Expand All @@ -27,8 +27,7 @@ extern "C" void rtt_test_derived_type(const my_informative_type &mit, int &error
<< "\nint = " << mit.some_int << "\nlarge_int = " << mit.some_large_int
<< "\n*some_pointer[1] = " << *(mit.some_pointer)
<< "\n*some_pointer[2] = " << *(mit.some_pointer + 1)
<< "\nsome_enum = " << mit.some_enum << "\n"
<< std::endl;
<< "\nsome_enum = " << mit.some_enum << "\n\n";

error_code = 0;

Expand Down
6 changes: 4 additions & 2 deletions src/FortranChecks/test/cppmain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "dsxx/Release.hh"
#include "dsxx/ScalarUnitTest.hh"
#include "dsxx/UnitTest.hh"
#include <cstddef>
#include <iostream>

//------------------------------------------------------------------------------------------------//
Expand All @@ -17,14 +19,14 @@ extern "C" void sub1(double alpha, size_t *numPass, size_t *numFail);

//------------------------------------------------------------------------------------------------//
void test_isocbinding_sub1(rtt_dsxx::UnitTest &ut) {
double alpha = 1.0;
double const alpha = 1.0;
size_t np(ut.numPasses);
size_t nf(ut.numFails);
// Call fortran subroutine
sub1(alpha, &np, &nf);
ut.numPasses = static_cast<unsigned>(np);
ut.numFails = static_cast<unsigned>(nf);
std::cout << ut.numPasses << " " << ut.numFails << std::endl;
std::cout << ut.numPasses << " " << ut.numFails << '\n';
return;
}

Expand Down
19 changes: 10 additions & 9 deletions src/VendorChecks/test/tstMetis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@

#include "dsxx/Release.hh"
#include "dsxx/ScalarUnitTest.hh"
#include "dsxx/UnitTest.hh"
#include <array>
#include <cstdint> // int32_t
#include <iostream>
#include <vector>

// Original provided by Erik Zenker, https://gist.github.com/erikzenker/c4dc42c8d5a8c1cd3e5a
Expand Down Expand Up @@ -49,19 +52,17 @@ void test_metis(rtt_dsxx::UnitTest &ut) {
// index: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13, 14,15,16,17
std::array<idx_t, 18> adjncy = {4, 4, 4, 4, 0, 1, 2, 3, 5, 4, 6, 7, 8, 9, 5, 5, 5, 5};

// Weights of vertices: if all weights are equal then can be set to NULL
std::vector<idx_t> vwgt(nVertices * nWeights, 0);

// Partition a graph into k parts using either multilevel recursive bisection or multilevel k-way
// partitioning.
int ret = METIS_PartGraphKway(&nVertices, &nWeights, xadj.data(), adjncy.data(), nullptr, nullptr,
nullptr, &nParts, nullptr, nullptr, nullptr, &objval, &part[0]);
int const ret =
METIS_PartGraphKway(&nVertices, &nWeights, xadj.data(), adjncy.data(), nullptr, nullptr,
nullptr, &nParts, nullptr, nullptr, nullptr, &objval, &part[0]);

std::cout << "partition: ";
for (int32_t i = 0; i < nVertices; ++i) {
std::cout << part[i] << " ";
}
std::cout << std::endl;
std::cout << '\n';

if (ret == METIS_OK)
PASSMSG("Successfully called METIS_PartGraphKway().");
Expand All @@ -70,9 +71,9 @@ void test_metis(rtt_dsxx::UnitTest &ut) {

std::array<int, 10> expectedResult = {1, 1, 1, 1, 1, 0, 0, 0, 0, 0};
std::array<int, 10> mirrorExpectedResult = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1};
std::vector<idx_t> vExpectedResult(expectedResult.begin(), expectedResult.end());
std::vector<idx_t> vMirrorExpectedResult(mirrorExpectedResult.begin(),
mirrorExpectedResult.end());
std::vector<idx_t> const vExpectedResult(expectedResult.begin(), expectedResult.end());
std::vector<idx_t> const vMirrorExpectedResult(mirrorExpectedResult.begin(),
mirrorExpectedResult.end());
if (part == vExpectedResult || part == vMirrorExpectedResult)
PASSMSG("Metis returned the expected result.");
else
Expand Down
24 changes: 18 additions & 6 deletions src/VendorChecks/test/tstParmetis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
* \note Copyright (C) 2016-2024 Triad National Security, LLC., All rights reserved. */
//------------------------------------------------------------------------------------------------//

#include "dsxx/Assert.hh"
#include "dsxx/Release.hh"
#include "dsxx/UnitTest.hh"
#include "c4/C4_Functions.hh"
#include "c4/ParallelUnitTest.hh"
#include <climits>
#include <cstddef>
#include <iostream>
#include <parmetis.h>
#include <sstream>
#include <vector>
Expand All @@ -16,7 +22,11 @@

void test_parmetis(rtt_c4::ParallelUnitTest &ut) {
using std::cout;
using std::endl;

// Don't warn about missing MPI and Parmetis headers that define some macros and variables used
// here.

// NOLINTBEGIN(misc-include-cleaner)

Insist(rtt_c4::nodes() == 3, "test_parmetis must be called with 3 MPI ranks exactly.");

Expand Down Expand Up @@ -94,9 +104,9 @@ void test_parmetis(rtt_c4::ParallelUnitTest &ut) {
if (MPI_PROC_ID == 0)
cout << "parmetis initialized." << '\n';

int result = ParMETIS_V3_PartKway(&vtxdist[0], &xadj[0], &adjncy[0], vwgt, adjwgt, &wgtflag,
&numflag, &ncon, &nparts, &tpwgts[0], &ubvec, &options[0],
&edgecut, &part[0], &rtt_c4::communicator);
int const result = ParMETIS_V3_PartKway(&vtxdist[0], &xadj[0], &adjncy[0], vwgt, adjwgt, &wgtflag,
&numflag, &ncon, &nparts, &tpwgts[0], &ubvec, &options[0],
&edgecut, &part[0], &rtt_c4::communicator);

if (result == METIS_OK) {
std::ostringstream msg;
Expand All @@ -109,15 +119,17 @@ void test_parmetis(rtt_c4::ParallelUnitTest &ut) {
}

if (MPI_PROC_ID == 0)
cout << "parmetis finalized." << endl;
cout << "parmetis finalized.\n";

for (size_t pid = 0; pid < MPI_PROC_TOTAL_NUM; ++pid) {
rtt_c4::global_barrier();
cout << MPI_PROC_ID << " edgecut " << edgecut << '\n';
for (int i = 0; i < 5; i++)
cout << "[" << MPI_PROC_ID << "] " << part[i] << endl;
cout << "[" << MPI_PROC_ID << "] " << part[i] << '\n';
}

// NOLINTEND(misc-include-cleaner)

return;
}

Expand Down
41 changes: 16 additions & 25 deletions src/cdi_analytic/test/tstPseudo_Line_Analytic_MultigroupOpacity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,17 @@ using namespace std;
using namespace rtt_dsxx;
using namespace rtt_cdi_analytic;
using namespace rtt_parser;
using PLAMO = Pseudo_Line_Analytic_MultigroupOpacity;

//------------------------------------------------------------------------------------------------//
// TESTS
//------------------------------------------------------------------------------------------------//

Pseudo_Line_Analytic_MultigroupOpacity::Averaging const NONE =
Pseudo_Line_Analytic_MultigroupOpacity::NONE;
PLAMO::Averaging const NONE = PLAMO::NONE;
PLAMO::Averaging const ROSSELAND = PLAMO::ROSSELAND;
PLAMO::Averaging const PLANCK = PLAMO::PLANCK;

Pseudo_Line_Analytic_MultigroupOpacity::Averaging const ROSSELAND =
Pseudo_Line_Analytic_MultigroupOpacity::ROSSELAND;

Pseudo_Line_Analytic_MultigroupOpacity::Averaging const PLANCK =
Pseudo_Line_Analytic_MultigroupOpacity::PLANCK;

void tstPseudo_Line_Analytic_MultigroupOpacity(UnitTest &ut) {
void tstPLAMO(UnitTest &ut) {
unsigned const NG = 12288; // 10;
int const number_of_lines = 20;
int const number_of_edges = 10;
Expand Down Expand Up @@ -68,9 +64,8 @@ void tstPseudo_Line_Analytic_MultigroupOpacity(UnitTest &ut) {
}

{
Pseudo_Line_Analytic_MultigroupOpacity const model(
group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width, number_of_edges,
edge_ratio, Tref, Tpow, emin, emax, NONE, 0, seed);
PLAMO const model(group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width,
number_of_edges, edge_ratio, Tref, Tpow, emin, emax, NONE, 0, seed);

PASSMSG("Created Pseudo_Line_Analytic_MultigroupOpacity");

Expand All @@ -85,9 +80,8 @@ void tstPseudo_Line_Analytic_MultigroupOpacity(UnitTest &ut) {
}

{
Pseudo_Line_Analytic_MultigroupOpacity const model(
group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width, number_of_edges,
edge_ratio, Tref, Tpow, emin, emax, ROSSELAND, 0, seed);
PLAMO const model(group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width,
number_of_edges, edge_ratio, Tref, Tpow, emin, emax, ROSSELAND, 0, seed);

PASSMSG("Created Pseudo_Line_Analytic_MultigroupOpacity");

Expand All @@ -102,9 +96,8 @@ void tstPseudo_Line_Analytic_MultigroupOpacity(UnitTest &ut) {
}

{
Pseudo_Line_Analytic_MultigroupOpacity const model(
group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width, number_of_edges,
edge_ratio, Tref, Tpow, emin, emax, PLANCK, 0, seed);
PLAMO const model(group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width,
number_of_edges, edge_ratio, Tref, Tpow, emin, emax, PLANCK, 0, seed);

PASSMSG("Created Pseudo_Line_Analytic_MultigroupOpacity");

Expand All @@ -119,9 +112,8 @@ void tstPseudo_Line_Analytic_MultigroupOpacity(UnitTest &ut) {
}

{
Pseudo_Line_Analytic_MultigroupOpacity const model(
group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width, number_of_edges,
edge_ratio, Tref, Tpow, emin, emax, ROSSELAND, 1, seed);
PLAMO const model(group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width,
number_of_edges, edge_ratio, Tref, Tpow, emin, emax, ROSSELAND, 1, seed);

PASSMSG("Created Pseudo_Line_Analytic_MultigroupOpacity");

Expand All @@ -136,9 +128,8 @@ void tstPseudo_Line_Analytic_MultigroupOpacity(UnitTest &ut) {
}

{
Pseudo_Line_Analytic_MultigroupOpacity const model(
group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width, number_of_edges,
edge_ratio, Tref, Tpow, emin, emax, PLANCK, 1, seed);
PLAMO const model(group_bounds, rtt_cdi::ABSORPTION, continuum, number_of_lines, peak, width,
number_of_edges, edge_ratio, Tref, Tpow, emin, emax, PLANCK, 1, seed);

PASSMSG("Created Pseudo_Line_Analytic_MultigroupOpacity");

Expand All @@ -157,7 +148,7 @@ void tstPseudo_Line_Analytic_MultigroupOpacity(UnitTest &ut) {
int main(int argc, char *argv[]) {
rtt_c4::ParallelUnitTest ut(argc, argv, release);
try {
tstPseudo_Line_Analytic_MultigroupOpacity(ut);
tstPLAMO(ut);
}
UT_EPILOG(ut);
}
Expand Down
11 changes: 9 additions & 2 deletions src/experimental/test/tst_mdspan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
* \note Copyright (C) 2019-2024 Triad National Security, LLC., All rights reserved. */
//------------------------------------------------------------------------------------------------//

// NOLINTBEGIN(misc-include-cleaner)

#include "dsxx/Release.hh"
#include "dsxx/ScalarUnitTest.hh"
#include "dsxx/UnitTest.hh"
#include "experimental/mdspan"
#include <array>
#include <iostream>

//------------------------------------------------------------------------------------------------//
// Helper Classes.
Expand Down Expand Up @@ -71,7 +76,7 @@ void t1(rtt_dsxx::UnitTest &ut) {
fill_in_order(b);

FAIL_IF_NOT(dot_product(a, b) == 204);
std::cout << "dot product = " << dot_product(a, b) << std::endl;
std::cout << "dot product = " << dot_product(a, b) << '\n';
if (ut.numFails == 0)
PASSMSG("done with t1");
return;
Expand All @@ -97,7 +102,7 @@ void t2(rtt_dsxx::UnitTest &ut) {
fill_in_order(b);

FAIL_IF_NOT(dot_product(a, b) == 204);
std::cout << "dot product = " << dot_product(a, b) << std::endl;
std::cout << "dot product = " << dot_product(a, b) << '\n';
if (ut.numFails == 0)
PASSMSG("done with t2");
return;
Expand All @@ -113,6 +118,8 @@ int main(int argc, char *argv[]) {
UT_EPILOG(ut);
}

// NOLINTEND(misc-include-cleaner)

//------------------------------------------------------------------------------------------------//
// end of tst_mdspan.cc
//------------------------------------------------------------------------------------------------//
28 changes: 18 additions & 10 deletions src/memory/memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
* \note Copyright (C) 2013-2024 Triad National Security, LLC., All rights reserved. */
//------------------------------------------------------------------------------------------------//

#include "memory/memory.hh"
#include "dsxx/Assert.hh"
#include "memory.hh"
#include "dsxx/StackTrace.hh"
#include "dsxx/config.h"
#include <cstdint> // uint64_t
#include <iostream>
#include <limits>
#include <new> // std::set_new_handler

#if DRACO_DIAGNOSTICS & 2
#include <map>
#endif

#ifdef __clang__
#pragma clang diagnostic push
Expand All @@ -32,9 +36,11 @@
namespace rtt_memory {
using namespace std;

static uint64_t total;
static uint64_t peak;
static uint64_t largest;
namespace {
uint64_t total;
uint64_t peak;
uint64_t largest;
} // namespace

#if DRACO_DIAGNOSTICS & 2

Expand All @@ -57,7 +63,9 @@ static uint64_t report_threshold = numeric_limits<uint64_t>::max();

#endif

static bool is_active = false;
namespace {
bool is_active = false;
} // namespace

#if DRACO_DIAGNOSTICS & 2

Expand Down Expand Up @@ -98,7 +106,7 @@ struct memory_diagnostics {

//------------------------------------------------------------------------------------------------//
bool set_memory_checking(bool new_status) {
bool Result = is_active;
bool const Result = is_active;

#if DRACO_DIAGNOSTICS & 2
total = 0;
Expand Down Expand Up @@ -142,11 +150,11 @@ void report_leaks(ostream &out) {
map<void *, alloc_t>::const_iterator i;
for (i = st.alloc_map.begin(); i != st.alloc_map.end(); ++i) {
out << i->second.size << " bytes allocated at address " << i->first << " as allocation "
<< i->second.count << " of this size" << endl;
<< i->second.count << " of this size\n";
}
}
#else
out << "No leak report available." << endl;
out << "No leak report available.\n";
#endif
}
}
Expand Down
Loading

0 comments on commit 73e5605

Please sign in to comment.