File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -26,3 +26,8 @@ add_executable(example3 example3.cpp)
26
26
27
27
target_compile_definitions (example3 INTERFACE DR_FORMAT )
28
28
target_link_libraries (example3 DR::mpi fmt::fmt )
29
+
30
+ add_executable (example4 example4.cpp )
31
+
32
+ target_compile_definitions (example4 INTERFACE DR_FORMAT )
33
+ target_link_libraries (example4 DR::mpi fmt::fmt )
Original file line number Diff line number Diff line change
1
+ // SPDX-FileCopyrightText: Intel Corporation
2
+ //
3
+ // SPDX-License-Identifier: BSD-3-Clause
4
+
5
+ #include < dr/mhp.hpp>
6
+ #include < fmt/core.h>
7
+
8
+ namespace mhp = dr::mhp;
9
+ using T = int ;
10
+
11
+ int main (int argc, char **argv) {
12
+
13
+ mhp::init (sycl::default_selector_v);
14
+ std::size_t xdim = 9 , ydim = 5 ;
15
+
16
+ std::array<std::size_t , 2 > extents2d = {xdim, ydim};
17
+
18
+ // 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);
22
+
23
+ // try populating the arrays with any data
24
+ mhp::iota (a, 100 );
25
+ mhp::iota (b, 200 );
26
+
27
+ auto copy_op = [](auto v) {
28
+ auto [in1, in2, out] = v;
29
+ out = in1 + in2;
30
+ };
31
+ mhp::for_each (copy_op, a, b, c);
32
+
33
+ if (mhp::rank () == 0 ) {
34
+ fmt::print (" A:\n {}\n " , a.mdspan ());
35
+ fmt::print (" B:\n {}\n " , b.mdspan ());
36
+ fmt::print (" C:\n {}\n " , c.mdspan ());
37
+ }
38
+
39
+ mhp::finalize ();
40
+
41
+ return 0 ;
42
+ }
You can’t perform that action at this time.
0 commit comments