Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
change to a floating point number
remove unused variables
  • Loading branch information
haichangsi committed Nov 13, 2023
1 parent 60d1060 commit 7061962
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ jobs:
mpirun -n 3 ./build/src/example1
mpirun -n 3 ./build/src/example2
mpirun -n 3 ./build/src/example3
mpirun -n 3 ./build/src/example4
mpirun -n 3 ./build/src/example5
1 change: 1 addition & 0 deletions scripts/build_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ cmake --build build -j
mpirun -n 2 ./build/src/example1
mpirun -n 2 ./build/src/example2
mpirun -n 2 ./build/src/example3
mpirun -n 2 ./build/src/example4
mpirun -n 2 ./build/src/example5
12 changes: 4 additions & 8 deletions src/example5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@

namespace mhp = dr::mhp;

using T = uint16_t;
using T = float;
using MDA = dr::mhp::distributed_mdarray<T, 2>;

/* 2d stencil - simple operation on multi-dimensional array */
int main() {
#ifdef SYCL_LANGUAGE_VERSION
mhp::init(sycl::default_selector_v);
#else
mhp::init();
#endif

std::size_t arr_size = 4;
std::size_t radius = 1;
std::array slice_starts{radius, radius};
Expand All @@ -29,15 +27,13 @@ int main() {

auto in = dr::mhp::views::submdspan(a.view(), slice_starts, slice_ends);
auto out = dr::mhp::views::submdspan(b.view(), slice_starts, slice_ends);
auto in_array = &a;
auto out_array = &b;

auto mdspan_stencil_op = [](auto &&v) {
auto [in, out] = v;
out(0, 0) = (in(-1, 0) + in(0, -1) + in(0, 0) + in(0, 1) + in(1, 0)) / 4;
};

mhp::halo(*in_array).exchange();
mhp::halo(a).exchange();
mhp::stencil_for_each(mdspan_stencil_op, in, out);

if (mhp::rank() == 0) {
Expand Down

0 comments on commit 7061962

Please sign in to comment.