Skip to content

Commit

Permalink
bugfix closing #2
Browse files Browse the repository at this point in the history
  • Loading branch information
mlohry authored and adegenna committed Dec 17, 2021
1 parent ade441f commit a4b53e1
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 34 deletions.
1 change: 0 additions & 1 deletion data_structures/exec_includes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MADG_CUDA_BLOCK_SIZE>;

Expand Down
6 changes: 2 additions & 4 deletions data_structures/managed_array_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_); }
};


Expand Down
2 changes: 2 additions & 0 deletions initialization/puppeteer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Puppeteer::run()
if (Options::get().interactive_plots()) {
plotSolution(time_integrator_->getCurrentSolutionState());
}

Logger::get().InfoMessage(Profiler::get().finalize());
}

void
Expand Down
1 change: 1 addition & 0 deletions logger/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "git_info.hpp"

#include "parallel/machine.hpp"
#include "profiler.hpp"

#include <boost/date_time.hpp>
#include <boost/filesystem.hpp>
Expand Down
1 change: 1 addition & 0 deletions logger/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Logger {

private:
Logger();
~Logger() = default;
static std::string makeBanner();

const std::string banner_;
Expand Down
9 changes: 2 additions & 7 deletions logger/profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "logger.hpp"


Profiler::~Profiler()
std::string Profiler::finalize()
{
tabulate::Table table;
table.add_row({"Function", "# calls", "Time (s)", "Percentage"});
Expand Down Expand Up @@ -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();
}


Expand Down
6 changes: 4 additions & 2 deletions logger/profiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 1 addition & 15 deletions spatial_discretization/discretization_2d_cart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,13 @@ void
Discretization2DCart::printState(const ManagedArray2D<real_wp>& 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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);
}


Expand Down

0 comments on commit a4b53e1

Please sign in to comment.