diff --git a/data_structures/exec_includes.hpp b/data_structures/exec_includes.hpp index ee6a113..bf2203c 100644 --- a/data_structures/exec_includes.hpp +++ b/data_structures/exec_includes.hpp @@ -25,7 +25,6 @@ #ifdef MADG_USE_GPU #ifdef __NVCC__ -#include "cublas_v2.h" #define MADG_CUDA_BLOCK_SIZE 256 using device_exec_policy = RAJA::cuda_exec; diff --git a/data_structures/managed_array_2d.hpp b/data_structures/managed_array_2d.hpp index 5483ef1..694e560 100644 --- a/data_structures/managed_array_2d.hpp +++ b/data_structures/managed_array_2d.hpp @@ -20,10 +20,6 @@ class ManagedArray2DAccessor { { } - // MADG_HOST_DEVICE inline int idx1d(int i, int j) const { return (i + nhalo_layers_) * njhalo_ + nhalo_layers_ + j; - // } - MADG_HOST_DEVICE inline int idx1d(int i, int j) const { return get1Dindex(i, j, nhalo_layers_, njhalo_); } - MADG_HOST_DEVICE inline T& operator()(int i, int j) const { return data_[idx1d(i, j)]; } MADG_HOST_DEVICE inline void getIJ(int idx, int& i, int& j) const @@ -37,6 +33,8 @@ class ManagedArray2DAccessor { const int nhalo_layers_; const int nihalo_; const int njhalo_; + + MADG_HOST_DEVICE inline int idx1d(int i, int j) const { return get1Dindex(i, j, nhalo_layers_, njhalo_); } }; diff --git a/initialization/puppeteer.cpp b/initialization/puppeteer.cpp index 3fb729b..4525f24 100644 --- a/initialization/puppeteer.cpp +++ b/initialization/puppeteer.cpp @@ -52,6 +52,8 @@ Puppeteer::run() if (Options::get().interactive_plots()) { plotSolution(time_integrator_->getCurrentSolutionState()); } + + Logger::get().InfoMessage(Profiler::get().finalize()); } void diff --git a/logger/logger.cpp b/logger/logger.cpp index e7e1ca7..3d19c36 100644 --- a/logger/logger.cpp +++ b/logger/logger.cpp @@ -2,6 +2,7 @@ #include "git_info.hpp" #include "parallel/machine.hpp" +#include "profiler.hpp" #include #include diff --git a/logger/logger.hpp b/logger/logger.hpp index 010ed5c..49bdc47 100644 --- a/logger/logger.hpp +++ b/logger/logger.hpp @@ -77,6 +77,7 @@ class Logger { private: Logger(); + ~Logger() = default; static std::string makeBanner(); const std::string banner_; diff --git a/logger/profiler.cpp b/logger/profiler.cpp index 5535d9d..9daa319 100644 --- a/logger/profiler.cpp +++ b/logger/profiler.cpp @@ -9,7 +9,7 @@ #include "logger.hpp" -Profiler::~Profiler() +std::string Profiler::finalize() { tabulate::Table table; table.add_row({"Function", "# calls", "Time (s)", "Percentage"}); @@ -61,16 +61,11 @@ Profiler::~Profiler() } table.column(0).format().width(70); -// table.row(0).format().padding_top(1).padding_bottom(1); table.column(3).format().font_align(tabulate::FontAlign::right); -// table[0][0].format().font_align(tabulate::FontAlign::center); -// table.row(0).format().padding_top(1); - -// table.format().hide_border(); std::stringstream ss; ss << table << std::endl; - Logger::get().InfoMessage(ss.str()); + return ss.str(); } diff --git a/logger/profiler.hpp b/logger/profiler.hpp index dc7b728..fb56da8 100644 --- a/logger/profiler.hpp +++ b/logger/profiler.hpp @@ -40,9 +40,11 @@ class Profiler const std::string function_name_; }; + std::string finalize(); + private: - Profiler() {} - ~Profiler(); + Profiler() = default; + ~Profiler() = default; void tic(const std::string& function_name); diff --git a/spatial_discretization/discretization_2d_cart.cpp b/spatial_discretization/discretization_2d_cart.cpp index 9f58b16..66c382d 100644 --- a/spatial_discretization/discretization_2d_cart.cpp +++ b/spatial_discretization/discretization_2d_cart.cpp @@ -87,27 +87,13 @@ void Discretization2DCart::printState(const ManagedArray2D& state_in) const { auto state = read_access_host(state_in); -// std::cout << "njhalo_-1 " << njhalo_ - 1 << " -nhalo" << -nhalo_ << "\n"; -// std::cout << "-nhalo_ " << -nhalo_ << " nihalo_ " << nihalo_ << "\n"; + for (int j = ni_ + nhalo_ - 1; j >= -nhalo_; --j) { for (int i = -nhalo_; i < ni_ + nhalo_; ++i) { std::cout << std::scientific << state(i, j) << " "; } std::cout << std::endl; } - - - // auto state = read_access_host(state_in.asArray()); - // maDGForAllHost(i, 0, state.size(), { - // std::cout << state[i] << "\n"; - // }) - // - // for (int j = njhalo_-1; j >= -nhalo_; --j){ - // for (int i = -nhalo_; i < nihalo_; ++i){ - // std::cout << std::scientific << state(i,j) << " "; - // } - // std::cout << std::endl; - // } } void diff --git a/testing/unit_tests/governing_equations/cahn_hilliard_2d_fd_test.cpp b/testing/unit_tests/governing_equations/cahn_hilliard_2d_fd_test.cpp index 3246df6..f6a7825 100644 --- a/testing/unit_tests/governing_equations/cahn_hilliard_2d_fd_test.cpp +++ b/testing/unit_tests/governing_equations/cahn_hilliard_2d_fd_test.cpp @@ -46,11 +46,11 @@ TEST(CahnHilliard, RHSEvaluation) maDGForAllHost(ii, 0, idx.size(), { int i; int j; - f.idx1d(i, j); + f.getIJ(idx[ii], i, j); const real_wp sinx = sin(x(i, j)); const real_wp siny = sin(y(i, j)); - const real_wp cosx = cos(y(i, j)); + const real_wp cosx = cos(x(i, j)); const real_wp cosy = cos(y(i, j)); // laplacian (c^3 -c) @@ -74,5 +74,5 @@ TEST(CahnHilliard, RHSEvaluation) } std::cout << "cartesian finite difference Cahn-Hilliard error:\n" << accuracy_chrhs << "\n"; - EXPECT_NEAR(accuracy_chrhs.getConvergenceRate().at(expected_order).back(), expected_order + 1, 0.01); + EXPECT_NEAR(accuracy_chrhs.getConvergenceRate().at(expected_order).back(), expected_order, 0.01); } diff --git a/testing/unit_tests/spatial_discretization/discretization_2d_cart_test.cpp b/testing/unit_tests/spatial_discretization/discretization_2d_cart_test.cpp index 4a6ab23..8004cd6 100644 --- a/testing/unit_tests/spatial_discretization/discretization_2d_cart_test.cpp +++ b/testing/unit_tests/spatial_discretization/discretization_2d_cart_test.cpp @@ -39,7 +39,7 @@ TEST(Discretization2DCart, Laplacian) maDGForAllHost(ii, 0, idx.size(), { int i; int j; - f.idx1d(i, j); + f.getIJ(idx[ii], i, j); const real_wp expected = -2.0 * sin(x(i, j)) * cos(y(i, j)); squared_norm += pow(expected - laplacian(i, j), 2.0); }); @@ -50,7 +50,7 @@ TEST(Discretization2DCart, Laplacian) } std::cout << "cartesian finite difference laplacian error:\n" << accuracy_laplacian << "\n"; - EXPECT_NEAR(accuracy_laplacian.getConvergenceRate().at(expected_order).back(), expected_order + 1, 0.01); + EXPECT_NEAR(accuracy_laplacian.getConvergenceRate().at(expected_order).back(), expected_order, 0.01); }