Skip to content

Commit

Permalink
Merge pull request #524 from dash-project/feat-halo
Browse files Browse the repository at this point in the history
Feat halo
  • Loading branch information
devreal authored Apr 24, 2018
2 parents 81c4cc1 + 6c178e4 commit 85599a8
Show file tree
Hide file tree
Showing 9 changed files with 1,771 additions and 1,021 deletions.
25 changes: 11 additions & 14 deletions dash/examples/ex.02.matrix.halo.heat_equation/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ using matrix_t = dash::Matrix<
double, 2,
typename pattern_t::index_type,
pattern_t>;
using StencilT = dash::StencilPoint<2>;
using StencilSpecT = dash::StencilSpec<StencilT,4>;
using GlobBoundSpecT = dash::GlobalBoundarySpec<2>;
using HaloMatrixWrapperT = dash::HaloMatrixWrapper<matrix_t>;
using StencilT = dash::halo::StencilPoint<2>;
using StencilSpecT = dash::halo::StencilSpec<StencilT,4>;
using GlobBoundSpecT = dash::halo::GlobalBoundarySpec<2>;
using HaloMatrixWrapperT = dash::halo::HaloMatrixWrapper<matrix_t>;

using array_t = dash::Array<double>;

Expand Down Expand Up @@ -48,9 +48,6 @@ int main(int argc, char *argv[])
cerr << "Not enough arguments ./<prog> matrix_ext iterations" << endl;
return 1;
}
using HaloBlockT = dash::HaloBlock<double,pattern_t>;
using HaloMemT = dash::HaloMemory<HaloBlockT>;

auto matrix_ext = std::atoi(argv[1]);
auto iterations = std::atoi(argv[2]);

Expand Down Expand Up @@ -87,16 +84,16 @@ int main(int argc, char *argv[])

StencilSpecT stencil_spec( StencilT(-1, 0), StencilT(1, 0), StencilT( 0, -1), StencilT(0, 1));

GlobBoundSpecT bound_spec(dash::BoundaryProp::CYCLIC, dash::BoundaryProp::CYCLIC);
GlobBoundSpecT bound_spec(dash::halo::BoundaryProp::CYCLIC, dash::halo::BoundaryProp::CYCLIC);

HaloMatrixWrapperT halomat(matrix, bound_spec, stencil_spec);
HaloMatrixWrapperT halomat2(matrix2, bound_spec, stencil_spec);

auto stencil_op = halomat.stencil_operator(stencil_spec);
auto stencil_op2 = halomat2.stencil_operator(stencil_spec);

decltype(stencil_op)* current_op = &stencil_op;
decltype(stencil_op2)* new_op = &stencil_op2;
auto* current_op = &stencil_op;
auto* new_op = &stencil_op2;

HaloMatrixWrapperT* current_halo = &halomat;
HaloMatrixWrapperT* new_halo = &halomat2;
Expand Down Expand Up @@ -146,8 +143,8 @@ int main(int argc, char *argv[])
}
#endif
// slow version
auto it_end = current_op->iend();
for(auto it = current_op->ibegin(); it != it_end; ++it)
auto it_end = current_op->inner.end();
for(auto it = current_op->inner.begin(); it != it_end; ++it)
{
auto core = *it;
auto dtheta = (it.value_at(0) + it.value_at(1) - 2 * core) / (dx * dx) +
Expand All @@ -159,8 +156,8 @@ int main(int argc, char *argv[])
current_halo->wait();

// Calculation of boundary Halo elements
auto it_bend = current_op->bend();
for (auto it = current_op->bbegin(); it != it_bend; ++it) {
auto it_bend = current_op->boundary.end();
for (auto it = current_op->boundary.begin(); it != it_bend; ++it) {
auto core = *it;
double dtheta =
(it.value_at(0) + it.value_at(1) - 2 * core) / (dx * dx) +
Expand Down
10 changes: 5 additions & 5 deletions dash/examples/ex.11.halo-stencil/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ using element_t = unsigned char;
using Pattern_t = dash::Pattern<2>;
using index_t = typename Pattern_t::index_type;
using Array_t = dash::NArray<element_t, 2, index_t, Pattern_t>;
using StencilP_t = dash::StencilPoint<2>;
using StencilSpec_t = dash::StencilSpec<StencilP_t,4>;
using HaloWrapper_t = dash::HaloMatrixWrapper<Array_t>;
using StencilP_t = dash::halo::StencilPoint<2>;
using StencilSpec_t = dash::halo::StencilSpec<StencilP_t,4>;
using HaloWrapper_t = dash::halo::HaloMatrixWrapper<Array_t>;

void write_pgm(const std::string & filename, const Array_t & data){
if(dash::myid() == 0){
Expand Down Expand Up @@ -151,8 +151,8 @@ void smooth(HaloWrapper_t & halo_old, HaloWrapper_t & halo_new,
halo_old.wait();

// Calculation of boundary Halo elements
auto bend = op_old.bend();
for(auto it = op_old.bbegin(); it != bend; ++it)
auto bend = op_old.boundary.end();
for(auto it = op_old.boundary.begin(); it != bend; ++it)
{
auto core = *it;
*(nlptr+it.lpos()) = (0.40 * core) +
Expand Down
Loading

0 comments on commit 85599a8

Please sign in to comment.