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;