From 3d39eb191581798b3bc35201cd7d6367190ee549 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 29 May 2020 16:35:50 +0100 Subject: [PATCH 1/7] Fix use of deprecated region enums --- examples/performance/ddx/ddx.cxx | 10 +++++----- examples/performance/ddy/ddy.cxx | 10 +++++----- examples/performance/ddz/ddz.cxx | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/performance/ddx/ddx.cxx b/examples/performance/ddx/ddx.cxx index 18ced539a0..ca21fe5bc7 100644 --- a/examples/performance/ddx/ddx.cxx +++ b/examples/performance/ddx/ddx.cxx @@ -72,27 +72,27 @@ int main(int argc, char **argv) { ITERATOR_TEST_BLOCK( "DDX C2", - result = DDX(a, CELL_DEFAULT, DIFF_C2); + result = DDX(a, CELL_DEFAULT, "DIFF_C2"); ); ITERATOR_TEST_BLOCK( "DDX C4", - result = DDX(a, CELL_DEFAULT, DIFF_C4); + result = DDX(a, CELL_DEFAULT, "DIFF_C4"); ); ITERATOR_TEST_BLOCK( "DDX S2", - result = DDX(a, CELL_DEFAULT, DIFF_S2); + result = DDX(a, CELL_DEFAULT, "DIFF_S2"); ); ITERATOR_TEST_BLOCK( "DDX W2", - result = DDX(a, CELL_DEFAULT, DIFF_W2); + result = DDX(a, CELL_DEFAULT, "DIFF_W2"); ); ITERATOR_TEST_BLOCK( "DDX W3", - result = DDX(a, CELL_DEFAULT, DIFF_W3); + result = DDX(a, CELL_DEFAULT, "DIFF_W3"); ); if (profileMode) { diff --git a/examples/performance/ddy/ddy.cxx b/examples/performance/ddy/ddy.cxx index eb4436b0b6..a1da0a04b5 100644 --- a/examples/performance/ddy/ddy.cxx +++ b/examples/performance/ddy/ddy.cxx @@ -72,27 +72,27 @@ int main(int argc, char **argv) { ITERATOR_TEST_BLOCK( "DDY C2", - result = DDY(a, CELL_DEFAULT, DIFF_C2); + result = DDY(a, CELL_DEFAULT, "DIFF_C2"); ); ITERATOR_TEST_BLOCK( "DDY C4", - result = DDY(a, CELL_DEFAULT, DIFF_C4); + result = DDY(a, CELL_DEFAULT, "DIFF_C4"); ); ITERATOR_TEST_BLOCK( "DDY S2", - result = DDY(a, CELL_DEFAULT, DIFF_S2); + result = DDY(a, CELL_DEFAULT, "DIFF_S2"); ); ITERATOR_TEST_BLOCK( "DDY W2", - result = DDY(a, CELL_DEFAULT, DIFF_W2); + result = DDY(a, CELL_DEFAULT, "DIFF_W2"); ); ITERATOR_TEST_BLOCK( "DDY W3", - result = DDY(a, CELL_DEFAULT, DIFF_W3); + result = DDY(a, CELL_DEFAULT, "DIFF_W3"); ); if (profileMode) { diff --git a/examples/performance/ddz/ddz.cxx b/examples/performance/ddz/ddz.cxx index 7b2a882001..6db9e1a38e 100644 --- a/examples/performance/ddz/ddz.cxx +++ b/examples/performance/ddz/ddz.cxx @@ -72,32 +72,32 @@ int main(int argc, char **argv) { ITERATOR_TEST_BLOCK( "DDZ C2", - result = DDZ(a, CELL_DEFAULT, DIFF_C2); + result = DDZ(a, CELL_DEFAULT, "DIFF_C2"); ); ITERATOR_TEST_BLOCK( "DDZ C4", - result = DDZ(a, CELL_DEFAULT, DIFF_C4); + result = DDZ(a, CELL_DEFAULT, "DIFF_C4"); ); ITERATOR_TEST_BLOCK( "DDZ S2", - result = DDZ(a, CELL_DEFAULT, DIFF_S2); + result = DDZ(a, CELL_DEFAULT, "DIFF_S2"); ); ITERATOR_TEST_BLOCK( "DDZ W2", - result = DDZ(a, CELL_DEFAULT, DIFF_W2); + result = DDZ(a, CELL_DEFAULT, "DIFF_W2"); ); ITERATOR_TEST_BLOCK( "DDZ W3", - result = DDZ(a, CELL_DEFAULT, DIFF_W3); + result = DDZ(a, CELL_DEFAULT, "DIFF_W3"); ); ITERATOR_TEST_BLOCK( "DDZ FFT", - result = DDZ(a, CELL_DEFAULT, DIFF_FFT); + result = DDZ(a, CELL_DEFAULT, "DIFF_FFT"); ); if (profileMode) { From 5c3e57e417923c868d7b4068a21cdef2bd3ec410 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 29 May 2020 16:39:32 +0100 Subject: [PATCH 2/7] Remove some unused variables/parameters from examples --- examples/boundary-conditions/advection/advection.cxx | 4 ++-- examples/constraints/alfven-wave/alfven.cxx | 5 ++--- examples/performance/arithmetic/arithmetic.cxx | 2 +- examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx | 2 +- .../tuning_regionblocksize/tuning_regionblocksize.cxx | 1 - 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/boundary-conditions/advection/advection.cxx b/examples/boundary-conditions/advection/advection.cxx index ff66bf3260..7448d7f4d6 100644 --- a/examples/boundary-conditions/advection/advection.cxx +++ b/examples/boundary-conditions/advection/advection.cxx @@ -11,7 +11,7 @@ class Advection : public PhysicsModel { protected: /// Initialise, specify evolving variables - int init(bool restarting) { + int init(bool) { // Solve for a single variable (f) SOLVE_FOR(f); return 0; @@ -23,7 +23,7 @@ class Advection : public PhysicsModel { /// /// Implemented using Vpar_Grad_par so /// the method can be changed in the input - int rhs(BoutReal t) { + int rhs(BoutReal) { mesh->communicate(f); ddt(f) = -Vpar_Grad_par(Field2D(1.0), f); diff --git a/examples/constraints/alfven-wave/alfven.cxx b/examples/constraints/alfven-wave/alfven.cxx index daa7d81e60..89a6cb16eb 100644 --- a/examples/constraints/alfven-wave/alfven.cxx +++ b/examples/constraints/alfven-wave/alfven.cxx @@ -32,8 +32,7 @@ class Alfven : public PhysicsModel { std::unique_ptr newSolver{nullptr}; // New Laplacian in X-Z protected: - int init(bool restarting) { - + int init(bool) { // Normalisation auto opt = Options::root()["alfven"]; Tnorm = opt["Tnorm"].withDefault(100); // Reference temperature [eV] @@ -151,7 +150,7 @@ class Alfven : public PhysicsModel { * * ddt(f) = Result of the inversion */ - int precon(BoutReal t, BoutReal gamma, BoutReal delta) { + int precon(BoutReal, BoutReal, BoutReal) { if(newXZsolver) { ddt(phi) = newSolver->solve(ddt(phi) - ddt(Vort), 0.0); }else { diff --git a/examples/performance/arithmetic/arithmetic.cxx b/examples/performance/arithmetic/arithmetic.cxx index d2b0e9c633..0ccfaea869 100644 --- a/examples/performance/arithmetic/arithmetic.cxx +++ b/examples/performance/arithmetic/arithmetic.cxx @@ -35,7 +35,7 @@ struct Durations { class Arithmetic : public PhysicsModel { protected: - int init(bool restarting) { + int init(bool) { Field3D a = 1.0; Field3D b = 2.0; diff --git a/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx b/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx index 4aae7f053d..cfb70ba657 100644 --- a/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx +++ b/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx @@ -39,7 +39,7 @@ class Arithmetic : public PhysicsModel { protected: std::map elapsedMap; - int init(bool restarting) { + int init(bool) { Field3D a = 1.0; Field3D b = 2.0; Field2D c = 3.0; diff --git a/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx b/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx index 108ef792bc..e8523db526 100644 --- a/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx +++ b/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx @@ -53,7 +53,6 @@ int main(int argc, char **argv) { Field3D result; result.allocate(); - const int len = mesh->LocalNx * mesh->LocalNy * mesh->LocalNz; int blocksize = 1; // Time simple task with different blocksizes From fc43a1ef7f69872fd8699b2955dacbe5b4cdd586 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 29 May 2020 17:05:24 +0100 Subject: [PATCH 3/7] Fix sign-comparison warnings in examples --- examples/performance/bracket/bracket.cxx | 10 +++--- examples/performance/iterator/iterator.cxx | 18 +++++----- examples/performance/laplace/laplace.cxx | 36 +++++++++++-------- .../tuning_regionblocksize.cxx | 14 ++++---- 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/examples/performance/bracket/bracket.cxx b/examples/performance/bracket/bracket.cxx index 162c76f836..dec093029a 100644 --- a/examples/performance/bracket/bracket.cxx +++ b/examples/performance/bracket/bracket.cxx @@ -110,7 +110,7 @@ int main(int argc, char **argv) { time_output << "Case legend"; time_output << "\n------------------------------------------------\n"; - for (int i = 0; i < names.size(); i++) { + for (std::size_t i = 0; i < names.size(); i++) { time_output << std::setw(width) << "Case " << i << ".\t" << names[i] << "\n"; } time_output << "\n"; @@ -128,7 +128,7 @@ int main(int argc, char **argv) { << "\t"; time_output << std::setw(width) << "Nz (global)" << "\t"; - for (int i = 0; i < names.size(); i++) { + for (std::size_t i = 0; i < names.size(); i++) { time_output << std::setw(width) << "Case " << i << "\t"; } time_output << "\n"; @@ -141,12 +141,12 @@ int main(int argc, char **argv) { time_output << std::setw(width) << mesh->GlobalNx << "\t"; time_output << std::setw(width) << mesh->GlobalNy << "\t"; time_output << std::setw(width) << mesh->GlobalNz << "\t"; - for (int i = 0; i < names.size(); i++) { + for (std::size_t i = 0; i < names.size(); i++) { time_output << std::setw(width) << times[i].count() / NUM_LOOPS << "\t"; } time_output << "\n"; } else { - int width = 0; + std::size_t width = 0; for (const auto i : names) { width = i.size() > width ? i.size() : width; }; @@ -155,7 +155,7 @@ int main(int argc, char **argv) { << "\t" << "Time per iteration (s)" << "\n"; - for (int i = 0; i < names.size(); i++) { + for (std::size_t i = 0; i < names.size(); i++) { time_output << std::setw(width) << names[i] << "\t" << times[i].count() / NUM_LOOPS << "\n"; } diff --git a/examples/performance/iterator/iterator.cxx b/examples/performance/iterator/iterator.cxx index f1d9628870..b10e7f959d 100644 --- a/examples/performance/iterator/iterator.cxx +++ b/examples/performance/iterator/iterator.cxx @@ -129,14 +129,14 @@ int main(int argc, char **argv) { nthreads = omp_get_max_threads(); #endif - int width = 12; + constexpr int width = 12; if(includeHeader){ time_output << "\n------------------------------------------------\n"; time_output << "Case legend"; time_output <<"\n------------------------------------------------\n"; - - for (int i = 0 ; i < names.size(); i++){ - time_output << std::setw(width) << "Case " << i << ".\t" << names[i] << "\n"; + + for (std::size_t i = 0; i < names.size(); i++) { + time_output << std::setw(width) << "Case " << i << ".\t" << names[i] << "\n"; } time_output << "\n"; time_output << std::setw(width) << "Nprocs" << "\t"; @@ -146,8 +146,8 @@ int main(int argc, char **argv) { time_output << std::setw(width) << "Nx (global)" << "\t"; time_output << std::setw(width) << "Ny (global)" << "\t"; time_output << std::setw(width) << "Nz (global)" << "\t"; - for (int i = 0 ; i < names.size(); i++){ - time_output << std::setw(width) << "Case " << i << "\t"; + for (std::size_t i = 0; i < names.size(); i++) { + time_output << std::setw(width) << "Case " << i << "\t"; } time_output << "\n"; } @@ -159,16 +159,16 @@ int main(int argc, char **argv) { time_output << std::setw(width) << mesh->GlobalNx << "\t"; time_output << std::setw(width) << mesh->GlobalNy << "\t"; time_output << std::setw(width) << mesh->GlobalNz << "\t"; - for (int i = 0 ; i < names.size(); i++){ + for (std::size_t i = 0; i < names.size(); i++) { time_output << std::setw(width) << times[i].count()/NUM_LOOPS << "\t"; } time_output << "\n"; }else{ - int width = 0; + std::size_t width = 0; for (const auto i: names){ width = i.size() > width ? i.size() : width;}; width = width + 5; time_output << std::setw(width) << "Case name" << "\t" << "Time per iteration (s)" << "\n"; - for(int i = 0 ; i < names.size(); i++){ + for (std::size_t i = 0; i < names.size(); i++) { time_output << std::setw(width) << names[i] << "\t" << times[i].count()/NUM_LOOPS << "\n"; } }; diff --git a/examples/performance/laplace/laplace.cxx b/examples/performance/laplace/laplace.cxx index 57114a9bf7..b4f4008cf1 100644 --- a/examples/performance/laplace/laplace.cxx +++ b/examples/performance/laplace/laplace.cxx @@ -6,13 +6,17 @@ #include #include #include + +#include #include #include #include #include +#include #include #include + using SteadyClock = std::chrono::time_point; using Duration = std::chrono::duration; using namespace std::chrono; @@ -173,28 +177,30 @@ int main(int argc, char **argv) { MPI_Barrier(BoutComm::get()); // Wait for all processors to write data // Report - int width = 0; - for (const auto i : names) { - width = i.size() > width ? i.size() : width; - }; - width = width + 5; + constexpr auto min_width = 5; + const auto width = + min_width + + std::max_element(begin(names), end(names), [](const auto& a, const auto& b) { + return a.size() < b.size(); + })->size(); time_output << std::setw(width) << "Case name" << "\t" << "Time (s)" << "\t" << "Time per iteration (s)" << "\n"; - for (int i = 0; i < names.size(); i++) { - time_output << std::setw(width) << names[i] << "\t" << times[i].count() << "\t\t" << times[i].count() / NUM_LOOPS - << "\n"; - } - double sum_of_times = 0.0; - for (auto t : times) { - sum_of_times += t.count(); + for (std::size_t i = 0; i < names.size(); i++) { + time_output << std::setw(width) << names[i] << "\t" << times[i].count() << "\t\t" + << times[i].count() / NUM_LOOPS << "\n"; } - time_output << std::setw(width) << "Total" << "\t" << sum_of_times << "\n"; - time_output << std::setw(width) << "Average" << "\t" << sum_of_times / times.size() << "\t\t" << sum_of_times / NUM_LOOPS / times.size() - << "\n"; + const auto sum_of_times = + std::accumulate(begin(times), end(times), 0.0, + [](const auto& sum, const auto& t) { return sum + t.count(); }); + time_output << std::setw(width) << "Total" + << "\t" << sum_of_times << "\n"; + time_output << std::setw(width) << "Average" + << "\t" << sum_of_times / times.size() << "\t\t" + << sum_of_times / NUM_LOOPS / times.size() << "\n"; BoutFinalise(); return 0; diff --git a/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx b/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx index e8523db526..c4c0faf82d 100644 --- a/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx +++ b/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -67,16 +68,17 @@ int main(int argc, char **argv) { } // Report - int width = 0; - for (const auto i : names) { - width = i.size() > width ? i.size() : width; - }; - width = width + 5; + constexpr auto min_width = 5; + const auto width = + min_width + + std::max_element(begin(names), end(names), [](const auto& a, const auto& b) { + return a.size() < b.size(); + })->size(); time_output << std::setw(width) << "Case name" << "\t" << "Time per iteration (s)" << "\n"; - for (int i = 0; i < names.size(); i++) { + for (std::size_t i = 0; i < names.size(); i++) { time_output << std::setw(width) << names[i] << "\t" << times[i].count() / NUM_LOOPS << "\n"; } From 472ffa10c8667228bdcafc9336d76d912dc607bd Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 29 May 2020 17:08:00 +0100 Subject: [PATCH 4/7] Fix reorder warning in examples --- examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx b/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx index cfb70ba657..cf8b1096b8 100644 --- a/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx +++ b/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx @@ -32,13 +32,14 @@ struct Durations { Duration min; Duration avg; int count; - Durations(): min(Duration::max()), max(Duration::min()), avg(Duration::zero()), count(0) {}; + Durations() + : max(Duration::min()), min(Duration::max()), avg(Duration::zero()), count(0){}; }; class Arithmetic : public PhysicsModel { protected: std::map elapsedMap; - + int init(bool) { Field3D a = 1.0; Field3D b = 2.0; From 5f3d96ce54c4d16063c292a96e0daf35179cce7c Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 29 May 2020 17:09:43 +0100 Subject: [PATCH 5/7] Reduce scope of some local variables in examples --- .../performance/arithmetic_3d2d/arithmetic_3d2d.cxx | 2 +- .../tuning_regionblocksize.cxx | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx b/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx index cf8b1096b8..0fbe6f8786 100644 --- a/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx +++ b/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx @@ -82,7 +82,7 @@ class Arithmetic : public PhysicsModel { } output.enable(); - int width = 15; + constexpr int width = 15; output<(0, mesh->LocalNx - 1, 0, mesh->LocalNy - 1, 0, mesh->LocalNz - 1, mesh->LocalNy, mesh->LocalNz, blocksize); - ITERATOR_TEST_BLOCK(name, BOUT_FOR(i, region) { result[i] = a[i] + b[i]; }); - blocksize *= 2; + ITERATOR_TEST_BLOCK( + name, BOUT_FOR(i, region) { result[i] = a[i] + b[i]; }); } // Report From 63e2b43a81d3ffde79feee95828e9992a0ffb993 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 29 May 2020 17:10:02 +0100 Subject: [PATCH 6/7] Clang-format example fixes --- .../advection/advection.cxx | 2 +- examples/constraints/alfven-wave/alfven.cxx | 1 - .../performance/arithmetic/arithmetic.cxx | 2 +- .../arithmetic_3d2d/arithmetic_3d2d.cxx | 25 +++---- examples/performance/ddx/ddx.cxx | 29 ++------ examples/performance/ddy/ddy.cxx | 29 ++------ examples/performance/ddz/ddz.cxx | 34 +++------- examples/performance/laplace/laplace.cxx | 67 +++++-------------- .../tuning_regionblocksize.cxx | 2 +- 9 files changed, 55 insertions(+), 136 deletions(-) diff --git a/examples/boundary-conditions/advection/advection.cxx b/examples/boundary-conditions/advection/advection.cxx index 7448d7f4d6..93dc3e2c63 100644 --- a/examples/boundary-conditions/advection/advection.cxx +++ b/examples/boundary-conditions/advection/advection.cxx @@ -16,7 +16,7 @@ class Advection : public PhysicsModel { SOLVE_FOR(f); return 0; } - + /// Calculate time derivatives /// /// df/dt = 1 * df/dy diff --git a/examples/constraints/alfven-wave/alfven.cxx b/examples/constraints/alfven-wave/alfven.cxx index 89a6cb16eb..6b38f7b8ca 100644 --- a/examples/constraints/alfven-wave/alfven.cxx +++ b/examples/constraints/alfven-wave/alfven.cxx @@ -31,7 +31,6 @@ class Alfven : public PhysicsModel { std::unique_ptr phiSolver{nullptr}; // Old Laplacian in X-Z std::unique_ptr newSolver{nullptr}; // New Laplacian in X-Z protected: - int init(bool) { // Normalisation auto opt = Options::root()["alfven"]; diff --git a/examples/performance/arithmetic/arithmetic.cxx b/examples/performance/arithmetic/arithmetic.cxx index 0ccfaea869..30d2a72893 100644 --- a/examples/performance/arithmetic/arithmetic.cxx +++ b/examples/performance/arithmetic/arithmetic.cxx @@ -92,7 +92,7 @@ class Arithmetic : public PhysicsModel { SOLVE_FOR(n); return 0; } - + int rhs(BoutReal) { ddt(n) = 0; return 0; diff --git a/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx b/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx index 0fbe6f8786..6743f46b0b 100644 --- a/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx +++ b/examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx @@ -7,6 +7,7 @@ #include +#include #include #include @@ -14,17 +15,17 @@ using SteadyClock = std::chrono::time_point; using Duration = std::chrono::duration; using namespace std::chrono; -#define TIMEIT(NAME, ...) \ - { \ - SteadyClock start = steady_clock::now(); \ - __VA_ARGS__ \ - Duration diff = steady_clock::now() - start; \ - auto elapsed = elapsedMap[NAME];\ - elapsed.min = diff > elapsed.min ? elapsed.min : diff; \ - elapsed.max = diff < elapsed.max ? elapsed.max : diff; \ - elapsed.count++; \ - elapsed.avg = elapsed.avg * (1 - 1. / elapsed.count) + diff / elapsed.count; \ - elapsedMap[NAME] = elapsed; \ +#define TIMEIT(NAME, ...) \ + { \ + SteadyClock start = steady_clock::now(); \ + __VA_ARGS__ \ + Duration diff = steady_clock::now() - start; \ + auto elapsed = elapsedMap[NAME]; \ + elapsed.min = std::min(diff, elapsed.min); \ + elapsed.max = std::max(diff, elapsed.max); \ + elapsed.count++; \ + elapsed.avg = elapsed.avg * (1 - 1. / elapsed.count) + diff / elapsed.count; \ + elapsedMap[NAME] = elapsed; \ } struct Durations { @@ -102,7 +103,7 @@ class Arithmetic : public PhysicsModel { SOLVE_FOR(n); return 0; } - + int rhs(BoutReal) { ddt(n) = 0; return 0; diff --git a/examples/performance/ddx/ddx.cxx b/examples/performance/ddx/ddx.cxx index ca21fe5bc7..6fe8b2a2fd 100644 --- a/examples/performance/ddx/ddx.cxx +++ b/examples/performance/ddx/ddx.cxx @@ -70,31 +70,16 @@ int main(int argc, char **argv) { result = DDX(a); ); - ITERATOR_TEST_BLOCK( - "DDX C2", - result = DDX(a, CELL_DEFAULT, "DIFF_C2"); - ); + ITERATOR_TEST_BLOCK("DDX C2", result = DDX(a, CELL_DEFAULT, "DIFF_C2");); - ITERATOR_TEST_BLOCK( - "DDX C4", - result = DDX(a, CELL_DEFAULT, "DIFF_C4"); - ); - - ITERATOR_TEST_BLOCK( - "DDX S2", - result = DDX(a, CELL_DEFAULT, "DIFF_S2"); - ); + ITERATOR_TEST_BLOCK("DDX C4", result = DDX(a, CELL_DEFAULT, "DIFF_C4");); - ITERATOR_TEST_BLOCK( - "DDX W2", - result = DDX(a, CELL_DEFAULT, "DIFF_W2"); - ); + ITERATOR_TEST_BLOCK("DDX S2", result = DDX(a, CELL_DEFAULT, "DIFF_S2");); + + ITERATOR_TEST_BLOCK("DDX W2", result = DDX(a, CELL_DEFAULT, "DIFF_W2");); + + ITERATOR_TEST_BLOCK("DDX W3", result = DDX(a, CELL_DEFAULT, "DIFF_W3");); - ITERATOR_TEST_BLOCK( - "DDX W3", - result = DDX(a, CELL_DEFAULT, "DIFF_W3"); - ); - if (profileMode) { int nthreads = 0; #ifdef _OPENMP diff --git a/examples/performance/ddy/ddy.cxx b/examples/performance/ddy/ddy.cxx index a1da0a04b5..9c4b2fa8f7 100644 --- a/examples/performance/ddy/ddy.cxx +++ b/examples/performance/ddy/ddy.cxx @@ -70,31 +70,16 @@ int main(int argc, char **argv) { result = DDY(a); ); - ITERATOR_TEST_BLOCK( - "DDY C2", - result = DDY(a, CELL_DEFAULT, "DIFF_C2"); - ); + ITERATOR_TEST_BLOCK("DDY C2", result = DDY(a, CELL_DEFAULT, "DIFF_C2");); - ITERATOR_TEST_BLOCK( - "DDY C4", - result = DDY(a, CELL_DEFAULT, "DIFF_C4"); - ); - - ITERATOR_TEST_BLOCK( - "DDY S2", - result = DDY(a, CELL_DEFAULT, "DIFF_S2"); - ); + ITERATOR_TEST_BLOCK("DDY C4", result = DDY(a, CELL_DEFAULT, "DIFF_C4");); - ITERATOR_TEST_BLOCK( - "DDY W2", - result = DDY(a, CELL_DEFAULT, "DIFF_W2"); - ); + ITERATOR_TEST_BLOCK("DDY S2", result = DDY(a, CELL_DEFAULT, "DIFF_S2");); + + ITERATOR_TEST_BLOCK("DDY W2", result = DDY(a, CELL_DEFAULT, "DIFF_W2");); + + ITERATOR_TEST_BLOCK("DDY W3", result = DDY(a, CELL_DEFAULT, "DIFF_W3");); - ITERATOR_TEST_BLOCK( - "DDY W3", - result = DDY(a, CELL_DEFAULT, "DIFF_W3"); - ); - if (profileMode) { int nthreads = 0; #ifdef _OPENMP diff --git a/examples/performance/ddz/ddz.cxx b/examples/performance/ddz/ddz.cxx index 6db9e1a38e..7fe7c8853e 100644 --- a/examples/performance/ddz/ddz.cxx +++ b/examples/performance/ddz/ddz.cxx @@ -70,36 +70,18 @@ int main(int argc, char **argv) { result = DDZ(a); ); - ITERATOR_TEST_BLOCK( - "DDZ C2", - result = DDZ(a, CELL_DEFAULT, "DIFF_C2"); - ); + ITERATOR_TEST_BLOCK("DDZ C2", result = DDZ(a, CELL_DEFAULT, "DIFF_C2");); - ITERATOR_TEST_BLOCK( - "DDZ C4", - result = DDZ(a, CELL_DEFAULT, "DIFF_C4"); - ); - - ITERATOR_TEST_BLOCK( - "DDZ S2", - result = DDZ(a, CELL_DEFAULT, "DIFF_S2"); - ); + ITERATOR_TEST_BLOCK("DDZ C4", result = DDZ(a, CELL_DEFAULT, "DIFF_C4");); - ITERATOR_TEST_BLOCK( - "DDZ W2", - result = DDZ(a, CELL_DEFAULT, "DIFF_W2"); - ); + ITERATOR_TEST_BLOCK("DDZ S2", result = DDZ(a, CELL_DEFAULT, "DIFF_S2");); - ITERATOR_TEST_BLOCK( - "DDZ W3", - result = DDZ(a, CELL_DEFAULT, "DIFF_W3"); - ); + ITERATOR_TEST_BLOCK("DDZ W2", result = DDZ(a, CELL_DEFAULT, "DIFF_W2");); + + ITERATOR_TEST_BLOCK("DDZ W3", result = DDZ(a, CELL_DEFAULT, "DIFF_W3");); + + ITERATOR_TEST_BLOCK("DDZ FFT", result = DDZ(a, CELL_DEFAULT, "DIFF_FFT");); - ITERATOR_TEST_BLOCK( - "DDZ FFT", - result = DDZ(a, CELL_DEFAULT, "DIFF_FFT"); - ); - if (profileMode) { int nthreads = 0; #ifdef _OPENMP diff --git a/examples/performance/laplace/laplace.cxx b/examples/performance/laplace/laplace.cxx index b4f4008cf1..39e1b840aa 100644 --- a/examples/performance/laplace/laplace.cxx +++ b/examples/performance/laplace/laplace.cxx @@ -16,7 +16,6 @@ #include #include - using SteadyClock = std::chrono::time_point; using Duration = std::chrono::duration; using namespace std::chrono; @@ -32,7 +31,7 @@ using namespace std::chrono; times.push_back(steady_clock::now() - start); \ } -int main(int argc, char **argv) { +int main(int argc, char** argv) { // Initialise BOUT++, setting up mesh BoutInitialise(argc, argv); @@ -60,51 +59,35 @@ int main(int argc, char **argv) { lap->setCoefC(1.0); lap->setCoefD(1.0); Field3D flag0; - TEST_BLOCK("flag0", - flag0 = lap->solve(input); - ); + TEST_BLOCK("flag0", flag0 = lap->solve(input);); lap->setInnerBoundaryFlags(INVERT_DC_GRAD + INVERT_AC_GRAD); Field3D flag3; - TEST_BLOCK("flag3", - flag3 = lap->solve(input); - ); + TEST_BLOCK("flag3", flag3 = lap->solve(input);); lap->setCoefA(a); lap->setInnerBoundaryFlags(0); Field3D flag0a; - TEST_BLOCK("flag0a", - flag0a = lap->solve(input); - ); + TEST_BLOCK("flag0a", flag0a = lap->solve(input);); lap->setInnerBoundaryFlags(INVERT_DC_GRAD + INVERT_AC_GRAD); Field3D flag3a = lap->solve(input); - TEST_BLOCK("flag3a", - flag3a = lap->solve(input); - ); + TEST_BLOCK("flag3a", flag3a = lap->solve(input);); lap->setCoefC(c); lap->setInnerBoundaryFlags(0); Field3D flag0ac; - TEST_BLOCK("flag0ac", - flag0ac = lap->solve(input); - ); + TEST_BLOCK("flag0ac", flag0ac = lap->solve(input);); lap->setInnerBoundaryFlags(INVERT_DC_GRAD + INVERT_AC_GRAD); Field3D flag3ac; - TEST_BLOCK("flag3ac", - flag3ac = lap->solve(input); - ); + TEST_BLOCK("flag3ac", flag3ac = lap->solve(input);); lap->setCoefC(1.0); lap->setCoefD(d); lap->setInnerBoundaryFlags(0); Field3D flag0ad; - TEST_BLOCK("flag0ad", - flag0ad = lap->solve(input); - ); + TEST_BLOCK("flag0ad", flag0ad = lap->solve(input);); lap->setInnerBoundaryFlags(INVERT_DC_GRAD + INVERT_AC_GRAD); Field3D flag3ad; - TEST_BLOCK("flag3ad", - flag3ad = lap->solve(input); - ); + TEST_BLOCK("flag3ad", flag3ad = lap->solve(input);); /// Test new interface and INVERT_IN/OUT_SET flags @@ -116,59 +99,43 @@ int main(int argc, char **argv) { lap->setInnerBoundaryFlags(INVERT_SET); Field3D flagis; - TEST_BLOCK("flagis", - flagis = lap->solve(input, set_to); - ); + TEST_BLOCK("flagis", flagis = lap->solve(input, set_to);); lap->setInnerBoundaryFlags(0); lap->setOuterBoundaryFlags(INVERT_SET); Field3D flagos; - TEST_BLOCK("flagos", - flagos = lap->solve(input, set_to); - ); + TEST_BLOCK("flagos", flagos = lap->solve(input, set_to);); lap->setCoefA(a); lap->setInnerBoundaryFlags(INVERT_SET); lap->setOuterBoundaryFlags(0); lap->setOuterBoundaryFlags(0); Field3D flagisa; - TEST_BLOCK("flagisa", - flagisa = lap->solve(input, set_to); - ); + TEST_BLOCK("flagisa", flagisa = lap->solve(input, set_to);); lap->setInnerBoundaryFlags(0); lap->setOuterBoundaryFlags(INVERT_SET); Field3D flagosa; - TEST_BLOCK("flagosa", - flagosa = lap->solve(input, set_to); - ); + TEST_BLOCK("flagosa", flagosa = lap->solve(input, set_to);); lap->setCoefC(c); lap->setInnerBoundaryFlags(INVERT_SET); lap->setOuterBoundaryFlags(0); Field3D flagisac; - TEST_BLOCK("flagisac", - flagisac = lap->solve(input, set_to); - ); + TEST_BLOCK("flagisac", flagisac = lap->solve(input, set_to);); lap->setInnerBoundaryFlags(0); lap->setOuterBoundaryFlags(INVERT_SET); Field3D flagosac; - TEST_BLOCK("flagosac", - flagosac = lap->solve(input, set_to); - ); + TEST_BLOCK("flagosac", flagosac = lap->solve(input, set_to);); lap->setCoefC(1.0); lap->setCoefD(d); lap->setInnerBoundaryFlags(INVERT_SET); lap->setOuterBoundaryFlags(0); Field3D flagisad; - TEST_BLOCK("flagisad", - flagisad = lap->solve(input, set_to); - ); + TEST_BLOCK("flagisad", flagisad = lap->solve(input, set_to);); lap->setInnerBoundaryFlags(0); lap->setOuterBoundaryFlags(INVERT_SET); Field3D flagosad; - TEST_BLOCK("flagosad", - flagosad = lap->solve(input, set_to); - ); + TEST_BLOCK("flagosad", flagosad = lap->solve(input, set_to);); // Write and close the output file bout::globals::dump.write(); diff --git a/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx b/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx index fb694313f1..9335d428d1 100644 --- a/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx +++ b/examples/performance/tuning_regionblocksize/tuning_regionblocksize.cxx @@ -33,7 +33,7 @@ using namespace bout::globals; times.push_back(steady_clock::now() - start); \ } -int main(int argc, char **argv) { +int main(int argc, char** argv) { BoutInitialise(argc, argv); std::vector names; std::vector times; From 4f3f78f4c52dd3cbbf62d5d5ef6dda50e89cb593 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 18 May 2020 10:06:17 +0100 Subject: [PATCH 7/7] Use `std::abs` to get correct overload --- tests/integrated/test-cyclic/test_cyclic.cxx | 2 +- tests/integrated/test-invpar/test_invpar.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integrated/test-cyclic/test_cyclic.cxx b/tests/integrated/test-cyclic/test_cyclic.cxx index abacf115a7..f90147d900 100644 --- a/tests/integrated/test-cyclic/test_cyclic.cxx +++ b/tests/integrated/test-cyclic/test_cyclic.cxx @@ -98,7 +98,7 @@ int main(int argc, char **argv) { for(int i=0;i tol) + if (std::abs(input(2, y, z) - deriv(2, y, z)) > tol) passed = 0; } }