forked from oneapi-src/distributed-ranges-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example2.cpp
36 lines (25 loc) · 849 Bytes
/
example2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-FileCopyrightText: Intel Corporation
//
// SPDX-License-Identifier: BSD-3-Clause
#include <dr/mhp.hpp>
#include <fmt/core.h>
namespace mhp = dr::mhp;
int main(int argc, char **argv) {
mhp::init(sycl::default_selector_v);
fmt::print(
"Hello, World! Distributed ranges process is running on rank {} / {} on "
"host {}\n",
mhp::rank(), mhp::nprocs(), mhp::hostname());
std::size_t n = 100;
mhp::distributed_vector<int> v(n);
mhp::iota(v, 1);
if (mhp::rank() == 0) {
auto &&segments = v.segments();
fmt::print("Created distributed vector of size {} with {} segments.\n",
v.size(), segments.size());
}
fmt::print("Rank {} owns segment of size {} and content {}\n", mhp::rank(),
mhp::local_segment(v).size(), mhp::local_segment(v));
mhp::finalize();
return 0;
}