Skip to content

Commit

Permalink
Clang-format example fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedThree committed May 29, 2020
1 parent 5f3d96c commit 63e2b43
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 136 deletions.
2 changes: 1 addition & 1 deletion examples/boundary-conditions/advection/advection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Advection : public PhysicsModel {
SOLVE_FOR(f);
return 0;
}

/// Calculate time derivatives
///
/// df/dt = 1 * df/dy
Expand Down
1 change: 0 additions & 1 deletion examples/constraints/alfven-wave/alfven.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Alfven : public PhysicsModel {
std::unique_ptr<Laplacian> phiSolver{nullptr}; // Old Laplacian in X-Z
std::unique_ptr<LaplaceXZ> newSolver{nullptr}; // New Laplacian in X-Z
protected:

int init(bool) {
// Normalisation
auto opt = Options::root()["alfven"];
Expand Down
2 changes: 1 addition & 1 deletion examples/performance/arithmetic/arithmetic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Arithmetic : public PhysicsModel {
SOLVE_FOR(n);
return 0;
}

int rhs(BoutReal) {
ddt(n) = 0;
return 0;
Expand Down
25 changes: 13 additions & 12 deletions examples/performance/arithmetic_3d2d/arithmetic_3d2d.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@

#include <bout/expr.hxx>

#include <algorithm>
#include <chrono>
#include <iomanip>

using SteadyClock = std::chrono::time_point<std::chrono::steady_clock>;
using Duration = std::chrono::duration<double>;
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 {
Expand Down Expand Up @@ -102,7 +103,7 @@ class Arithmetic : public PhysicsModel {
SOLVE_FOR(n);
return 0;
}

int rhs(BoutReal) {
ddt(n) = 0;
return 0;
Expand Down
29 changes: 7 additions & 22 deletions examples/performance/ddx/ddx.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 7 additions & 22 deletions examples/performance/ddy/ddy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 8 additions & 26 deletions examples/performance/ddz/ddz.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
67 changes: 17 additions & 50 deletions examples/performance/laplace/laplace.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <time.h>
#include <vector>


using SteadyClock = std::chrono::time_point<std::chrono::steady_clock>;
using Duration = std::chrono::duration<double>;
using namespace std::chrono;
Expand All @@ -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);
Expand Down Expand Up @@ -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

Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> names;
std::vector<Duration> times;
Expand Down

0 comments on commit 63e2b43

Please sign in to comment.