Skip to content

Commit c267492

Browse files
authored
openssf issue (#12)
* openssf issue * update namespaces * github auto disabled scheduled workflows on inactive repos * pre-commit issues * build issues * avoid double test * save file
1 parent 1515916 commit c267492

File tree

7 files changed

+73
-83
lines changed

7 files changed

+73
-83
lines changed

.github/workflows/docker_workflow.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,32 @@
33
# SPDX-License-Identifier: BSD-3-Clause
44

55
name: Docker
6+
permissions: read-all
67

78
on:
8-
push:
99
pull_request:
1010
workflow_dispatch:
11-
# 8am UTC is 12am PST, 1am PDT
12-
schedule:
13-
- cron: '0 8 * * *'
11+
push:
12+
branches:
13+
- main
1414

1515
jobs:
1616
run_precommit:
1717
name: Run pre-commit
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Check out
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2222
- name: Setup Python
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
2424
with:
25-
python-version: '3.10'
25+
python-version: '3.11'
2626
cache: 'pip'
27-
- name: Run pre-commit
28-
uses: pre-commit/[email protected]
27+
- name: Run checkers
28+
run: |
29+
pip install pre-commit
30+
pre-commit run --all
31+
2932
run_examples:
3033
name: Build and run examples
3134
runs-on: ubuntu-latest
@@ -38,9 +41,7 @@ jobs:
3841
- ${{ github.workspace }}:/src
3942
steps:
4043
- name: Check out
41-
uses: actions/checkout@v3
42-
- name: Setup cmake
43-
uses: jwlawson/[email protected]
44+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
4445
- name: Build examples
4546
run: |
4647
cmake -B build

src/example1.cpp

Lines changed: 8 additions & 10 deletions
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
}

src/example2.cpp

Lines changed: 9 additions & 11 deletions
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
}

src/example3.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
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
/* The example simulates the elementary 1-d cellular automaton. Description of
119
* what the automaton is and how it works can be found at
1210
* https://en.wikipedia.org/wiki/Elementary_cellular_automaton
@@ -27,10 +25,10 @@ auto newvalue = [](auto &&p) {
2725

2826
int main(int argc, char **argv) {
2927

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

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

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

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

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

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

5048
std::swap(in, out);
5149

5250
/* fmt::print() is rather slow here, as it gets element by element from
5351
* remote nodes. Use with care. */
54-
if (mhp::rank() == 0)
52+
if (dr::mp::rank() == 0)
5553
fmt::print("{}\n", in);
5654
}
5755

58-
mhp::finalize();
56+
dr::mp::finalize();
5957

6058
return 0;
6159
}

src/example4.cpp

Lines changed: 10 additions & 11 deletions
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
}

src/example5.cpp

Lines changed: 12 additions & 14 deletions
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;
11-
using MDA = dr::mhp::distributed_mdarray<T, 2>;
9+
using MDA = dr::mp::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
}

src/example6.cpp

Lines changed: 12 additions & 14 deletions
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)