Skip to content

Commit 83b7044

Browse files
committed
update namespaces
1 parent a4dfc27 commit 83b7044

File tree

7 files changed

+68
-76
lines changed

7 files changed

+68
-76
lines changed

Diff for: .github/workflows/docker_workflow.yml

+9-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Check out
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2323
- name: Setup Python
24-
uses: actions/setup-python@v4
24+
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
2525
with:
26-
python-version: '3.10'
26+
python-version: '3.11'
2727
cache: 'pip'
28-
- name: Run pre-commit
29-
uses: pre-commit/[email protected]
28+
- name: Run checkers
29+
run: |
30+
pip install pre-commit
31+
pre-commit run --all
32+
3033
run_examples:
3134
name: Build and run examples
3235
runs-on: ubuntu-latest
@@ -39,9 +42,7 @@ jobs:
3942
- ${{ github.workspace }}:/src
4043
steps:
4144
- name: Check out
42-
uses: actions/checkout@v3
43-
- name: Setup cmake
44-
uses: jwlawson/[email protected]
45+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
4546
- name: Build examples
4647
run: |
4748
cmake -B build

Diff for: src/example1.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,29 @@
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

5-
#include <dr/mhp.hpp>
5+
#include <dr/mp.hpp>
66
#include <fmt/core.h>
77

8-
namespace mhp = dr::mhp;
9-
108
int main(int argc, char **argv) {
119

12-
mhp::init(sycl::default_selector_v);
10+
dr::mp::init(sycl::default_selector_v);
1311

14-
mhp::distributed_vector<char> dv(81);
12+
dr::mp::distributed_vector<char> dv(81);
1513
std::string decoded_string(80, 0);
1614

17-
mhp::copy(
15+
dr::mp::copy(
1816
0,
1917
std::string("Mjqqt%|twqi&%Ymnx%nx%ywfsxrnxnts%kwtr%ymj%tsj%fsi%tsq~%"
2018
"Inxywngzyji%Wfsljx%wjfqr&"),
2119
dv.begin());
2220

23-
mhp::for_each(dv, [](char &val) { val -= 5; });
24-
mhp::copy(0, dv, decoded_string.begin());
21+
dr::mp::for_each(dv, [](char &val) { val -= 5; });
22+
dr::mp::copy(0, dv, decoded_string.begin());
2523

26-
if (mhp::rank() == 0)
24+
if (dr::mp::rank() == 0)
2725
fmt::print("{}\n", decoded_string);
2826

29-
mhp::finalize();
27+
dr::mp::finalize();
3028

3129
return 0;
3230
}

Diff for: src/example2.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,33 @@
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

5-
#include <dr/mhp.hpp>
5+
#include <dr/mp.hpp>
66
#include <fmt/core.h>
77

8-
namespace mhp = dr::mhp;
9-
108
int main(int argc, char **argv) {
119

12-
mhp::init(sycl::default_selector_v);
10+
dr::mp::init(sycl::default_selector_v);
1311

1412
fmt::print(
1513
"Hello, World! Distributed ranges process is running on rank {} / {} on "
1614
"host {}\n",
17-
mhp::rank(), mhp::nprocs(), mhp::hostname());
15+
dr::mp::rank(), dr::mp::nprocs(), dr::mp::hostname());
1816

1917
std::size_t n = 100;
2018

21-
mhp::distributed_vector<int> v(n);
22-
mhp::iota(v, 1);
19+
dr::mp::distributed_vector<int> v(n);
20+
dr::mp::iota(v, 1);
2321

24-
if (mhp::rank() == 0) {
22+
if (dr::mp::rank() == 0) {
2523
auto &&segments = v.segments();
2624
fmt::print("Created distributed vector of size {} with {} segments.\n",
2725
v.size(), segments.size());
2826
}
2927

30-
fmt::print("Rank {} owns segment of size {} and content {}\n", mhp::rank(),
31-
mhp::local_segment(v).size(), mhp::local_segment(v));
28+
fmt::print("Rank {} owns segment of size {} and content {}\n", dr::mp::rank(),
29+
dr::mp::local_segment(v).size(), dr::mp::local_segment(v));
3230

33-
mhp::finalize();
31+
dr::mp::finalize();
3432

3533
return 0;
3634
}

Diff for: src/example3.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

5-
#include <dr/mhp.hpp>
5+
#include <dr/mp.hpp>
66
#include <fmt/core.h>
77

88
namespace mhp = dr::mhp;
@@ -27,10 +27,10 @@ auto newvalue = [](auto &&p) {
2727

2828
int main(int argc, char **argv) {
2929

30-
mhp::init(sycl::default_selector_v);
30+
dr::mp::init(sycl::default_selector_v);
3131

32-
auto dist = dr::mhp::distribution().halo(1);
33-
mhp::distributed_vector<uint8_t> a1(asize + 2, 0, dist),
32+
auto dist = dr::mp::distribution().halo(1);
33+
dr::mp::distributed_vector<uint8_t> a1(asize + 2, 0, dist),
3434
a2(asize + 2, 0, dist);
3535

3636
auto in = rng::subrange(a1.begin() + 1, a1.end() - 1);
@@ -39,23 +39,23 @@ int main(int argc, char **argv) {
3939
/* initial value of the automaton - customize it if you want to */
4040
in[0] = 1;
4141

42-
if (mhp::rank() == 0)
42+
if (dr::mp::rank() == 0)
4343
fmt::print("{}\n", in);
4444

4545
for (std::size_t s = 0; s < steps; s++) {
46-
dr::mhp::halo(in).exchange();
46+
dr::mp::halo(in).exchange();
4747

48-
mhp::transform(in, out.begin(), newvalue);
48+
dr::mp::transform(in, out.begin(), newvalue);
4949

5050
std::swap(in, out);
5151

5252
/* fmt::print() is rather slow here, as it gets element by element from
5353
* remote nodes. Use with care. */
54-
if (mhp::rank() == 0)
54+
if (dr::mp::rank() == 0)
5555
fmt::print("{}\n", in);
5656
}
5757

58-
mhp::finalize();
58+
dr::mp::finalize();
5959

6060
return 0;
6161
}

Diff for: src/example4.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,40 @@
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

5-
#include <dr/mhp.hpp>
5+
#include <dr/mp.hpp>
66
#include <fmt/core.h>
77

8-
namespace mhp = dr::mhp;
98
using T = int;
109

1110
int main(int argc, char **argv) {
1211

13-
mhp::init(sycl::default_selector_v);
12+
dr::mp::init(sycl::default_selector_v);
1413
std::size_t xdim = 9, ydim = 5;
1514

1615
std::array<std::size_t, 2> extents2d = {xdim, ydim};
1716

1817
// any array with corresponding dimensions can be used
19-
mhp::distributed_mdarray<T, 2> a(extents2d);
20-
mhp::distributed_mdarray<T, 2> b(extents2d);
21-
mhp::distributed_mdarray<T, 2> c(extents2d);
18+
dr::mp::distributed_mdarray<T, 2> a(extents2d);
19+
dr::mp::distributed_mdarray<T, 2> b(extents2d);
20+
dr::mp::distributed_mdarray<T, 2> c(extents2d);
2221

2322
// try populating the arrays with any data
24-
mhp::iota(a, 100);
25-
mhp::iota(b, 200);
23+
dr::mp::iota(a, 100);
24+
dr::mp::iota(b, 200);
2625

2726
auto sum_op = [](auto v) {
2827
auto [in1, in2, out] = v;
2928
out = in1 + in2;
3029
};
31-
mhp::for_each(sum_op, a, b, c);
30+
dr::mp::for_each(sum_op, a, b, c);
3231

33-
if (mhp::rank() == 0) {
32+
if (dr::mp::rank() == 0) {
3433
fmt::print("A:\n{}\n", a.mdspan());
3534
fmt::print("B:\n{}\n", b.mdspan());
3635
fmt::print("C:\n{}\n", c.mdspan());
3736
}
3837

39-
mhp::finalize();
38+
dr::mp::finalize();
4039

4140
return 0;
4241
}

Diff for: src/example5.cpp

+11-13
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,46 @@
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

5-
#include <dr/mhp.hpp>
5+
#include <dr/mp.hpp>
66
#include <fmt/core.h>
77

8-
namespace mhp = dr::mhp;
9-
108
using T = float;
119
using MDA = dr::mhp::distributed_mdarray<T, 2>;
1210

1311
/* 2d stencil - simple operation on multi-dimensional array */
1412
int main() {
15-
mhp::init(sycl::default_selector_v);
13+
dr::mp::init(sycl::default_selector_v);
1614

1715
std::size_t arr_size = 4;
1816
std::size_t radius = 1;
1917
std::array slice_starts{radius, radius};
2018
std::array slice_ends{arr_size - radius, arr_size - radius};
2119

22-
auto dist = mhp::distribution().halo(radius);
20+
auto dist = dr::mp::distribution().halo(radius);
2321
MDA a({arr_size, arr_size}, dist);
2422
MDA b({arr_size, arr_size}, dist);
25-
mhp::iota(a, 1);
26-
mhp::iota(b, 1);
23+
dr::mp::iota(a, 1);
24+
dr::mp::iota(b, 1);
2725

28-
auto in = mhp::views::submdspan(a.view(), slice_starts, slice_ends);
29-
auto out = mhp::views::submdspan(b.view(), slice_starts, slice_ends);
26+
auto in = dr::mp::views::submdspan(a.view(), slice_starts, slice_ends);
27+
auto out = dr::mp::views::submdspan(b.view(), slice_starts, slice_ends);
3028

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

36-
mhp::halo(a).exchange();
37-
mhp::stencil_for_each(mdspan_stencil_op, in, out);
34+
dr::mp::halo(a).exchange();
35+
dr::mp::stencil_for_each(mdspan_stencil_op, in, out);
3836

39-
if (mhp::rank() == 0) {
37+
if (dr::mp::rank() == 0) {
4038
fmt::print("a: \n{} \n", a.mdspan());
4139
fmt::print("b: \n{} \n", b.mdspan());
4240
fmt::print("in: \n{} \n", in.mdspan());
4341
fmt::print("out: \n{} \n", out.mdspan());
4442
}
4543

46-
mhp::finalize();
44+
dr::mp::finalize();
4745

4846
return 0;
4947
}

Diff for: src/example6.cpp

+12-14
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
//
33
// SPDX-License-Identifier: BSD-3-Clause
44

5-
#include <dr/mhp.hpp>
5+
#include <dr/mp.hpp>
66
#include <fmt/core.h>
77

8-
namespace mhp = dr::mhp;
9-
108
using T = uint16_t;
11-
using MDA = dr::mhp::distributed_mdarray<T, 2>;
9+
using MDA = dr::mp::distributed_mdarray<T, 2>;
1210

1311
/* 2D pattern search in a distributed multidimensional (2D) array */
1412
int main() {
15-
mhp::init(sycl::default_selector_v);
13+
dr::mp::init(sycl::default_selector_v);
1614

1715
std::size_t arr_size = 7;
1816
// keep in mind that if you change the pattern size, you have to also change
@@ -22,16 +20,16 @@ int main() {
2220
std::array slice_starts{radius - 1, radius - 1};
2321
std::array slice_ends{arr_size - radius, arr_size - radius};
2422

25-
auto dist = dr::mhp::distribution().halo(radius);
23+
auto dist = dr::mp::distribution().halo(radius);
2624
MDA a({arr_size, arr_size}, dist);
2725
MDA occurrences_coords({arr_size, arr_size});
2826

29-
mhp::iota(a, 1);
30-
mhp::transform(a, a.begin(), [](auto &&v) { return v % 2; });
31-
mhp::fill(occurrences_coords, 0);
27+
dr::mp::iota(a, 1);
28+
dr::mp::transform(a, a.begin(), [](auto &&v) { return v % 2; });
29+
dr::mp::fill(occurrences_coords, 0);
3230

3331
auto a_submdspan =
34-
dr::mhp::views::submdspan(a.view(), slice_starts, slice_ends);
32+
dr::mp::views::submdspan(a.view(), slice_starts, slice_ends);
3533
int pattern[pattern_size][pattern_size] = {{1, 0}, {0, 1}};
3634

3735
auto mdspan_pattern_op = [pattern](auto &&v) {
@@ -44,16 +42,16 @@ int main() {
4442
}
4543
};
4644

47-
mhp::halo(a).exchange();
48-
mhp::stencil_for_each(mdspan_pattern_op, a_submdspan, occurrences_coords);
45+
dr::mp::halo(a).exchange();
46+
dr::mp::stencil_for_each(mdspan_pattern_op, a_submdspan, occurrences_coords);
4947

50-
if (mhp::rank() == 0) {
48+
if (dr::mp::rank() == 0) {
5149
fmt::print("a: \n{} \n", a.mdspan());
5250
fmt::print("pattern: \n{} \n", pattern);
5351
fmt::print("occurrences: \n{} \n", occurrences_coords.mdspan());
5452
}
5553

56-
mhp::finalize();
54+
dr::mp::finalize();
5755

5856
return 0;
5957
}

0 commit comments

Comments
 (0)