Skip to content

Commit 0d63b37

Browse files
author
Kruglov, Oleg
committed
Add preview namespace
1 parent 594c10d commit 0d63b37

9 files changed

Lines changed: 67 additions & 68 deletions

File tree

cpp/oneapi/dal/backend/primitives/frontier/advance.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "oneapi/dal/backend/primitives/frontier/graph.hpp"
2222
#include "oneapi/dal/backend/primitives/frontier/frontier.hpp"
2323

24-
namespace oneapi::dal::backend::primitives {
24+
namespace oneapi::dal::preview::backend::primitives {
2525

2626
/// frontier_context_state holds the state of the current processing group in the kernel
2727
/// It includes the group offset, coarsening factor, offsets size, and the SYCL
@@ -325,7 +325,7 @@ sycl::event advance(const GraphT& graph,
325325
using bitmap_kernel_t =
326326
bitmap_kernel<element_t, decltype(context), decltype(graph_dev), LambdaT>;
327327

328-
const uint32_t max_num_subgroups = device_max_sg_count(q);
328+
const uint32_t max_num_subgroups = oneapi::dal::backend::device_max_sg_count(q);
329329

330330
auto e = q.submit([&](sycl::handler& cgh) {
331331
cgh.depends_on(to_wait);
@@ -391,4 +391,4 @@ sycl::event advance(const GraphT& graph,
391391
return { e };
392392
}
393393

394-
} // namespace oneapi::dal::backend::primitives
394+
} // namespace oneapi::dal::preview::backend::primitives

cpp/oneapi/dal/backend/primitives/frontier/bitset.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include "oneapi/dal/backend/memory.hpp"
2121

22-
namespace oneapi::dal::backend::primitives {
22+
namespace oneapi::dal::preview::backend::primitives {
2323

2424
/// A bitset class that provides a set of operations on a bitset implemented using an array of integers.
2525
/// \tparam ElementType the type of the elements in the bitset (e.g., std::uint32_t).
@@ -119,4 +119,4 @@ class bitset {
119119
std::uint64_t _num_items;
120120
};
121121

122-
} // namespace oneapi::dal::backend::primitives
122+
} // namespace oneapi::dal::preview::backend::primitives

cpp/oneapi/dal/backend/primitives/frontier/frontier.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#include "oneapi/dal/backend/primitives/frontier/bitset.hpp"
2323
#include "oneapi/dal/backend/primitives/ndarray.hpp"
2424

25-
namespace oneapi::dal::backend::primitives {
25+
namespace oneapi::dal::preview::backend::primitives {
26+
namespace pr = dal::backend::primitives;
2627

2728
/// @brief A view of a frontier that provides an interface for the kernel to interact with the frontier data structure.
2829
/// \tparam ElementType the type of the elements in the frontier (e.g., std::uint32_t).
@@ -110,19 +111,19 @@ class frontier {
110111
static_cast<std::uint64_t>(_data_layer.get_count()) };
111112
}
112113

113-
inline ndview<ElementType, 1> get_data() const {
114+
inline pr::ndview<ElementType, 1> get_data() const {
114115
return _data_layer;
115116
}
116117

117-
inline ndview<ElementType, 1> get_mlb() const {
118+
inline pr::ndview<ElementType, 1> get_mlb() const {
118119
return _mlb_layer;
119120
}
120121

121-
inline ndview<std::uint32_t, 1> get_offsets() const {
122+
inline pr::ndview<std::uint32_t, 1> get_offsets() const {
122123
return _offsets.slice(1, _offsets.get_count());
123124
}
124125

125-
inline ndview<std::uint32_t, 1> get_offsets_size() const {
126+
inline pr::ndview<std::uint32_t, 1> get_offsets_size() const {
126127
return _offsets.slice(0, 1);
127128
}
128129

@@ -153,10 +154,10 @@ class frontier {
153154
sycl::queue& _queue;
154155
std::uint64_t _num_items;
155156

156-
ndarray<ElementType, 1> _data_layer;
157-
ndarray<ElementType, 1> _mlb_layer;
158-
ndarray<std::uint32_t, 1> _offsets;
159-
ndarray<buffer_t, 1> _buffer;
157+
pr::ndarray<ElementType, 1> _data_layer;
158+
pr::ndarray<ElementType, 1> _mlb_layer;
159+
pr::ndarray<std::uint32_t, 1> _offsets;
160+
pr::ndarray<buffer_t, 1> _buffer;
160161
const std::uint64_t _TMP_VAR = 0;
161162
const std::uint64_t _CAF_FLAG =
162163
1; // Compute Active Frontier Flag (1 if already computed, 0 otherwise)
@@ -169,4 +170,4 @@ void swap_frontiers(frontier<ElementType>& f1, frontier<ElementType>& f2) {
169170
frontier<ElementType>::swap(f1, f2);
170171
}
171172

172-
} // namespace oneapi::dal::backend::primitives
173+
} // namespace oneapi::dal::preview::backend::primitives

cpp/oneapi/dal/backend/primitives/frontier/frontier_dpc.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "oneapi/dal/backend/primitives/frontier/frontier.hpp"
1919

20-
namespace oneapi::dal::backend::primitives {
20+
namespace oneapi::dal::preview::backend::primitives {
2121

2222
#ifdef ONEDAL_DATA_PARALLEL
2323

@@ -29,13 +29,13 @@ frontier<ElementType>::frontier(sycl::queue& queue, std::uint64_t num_items, syc
2929
bitset<ElementType>::element_bitsize;
3030
std::int64_t mlb_size = (array_size + bitset<ElementType>::element_bitsize - 1) /
3131
bitset<ElementType>::element_bitsize;
32-
_data_layer = ndarray<ElementType, 1>::empty(_queue, { array_size }, alloc);
33-
_mlb_layer = ndarray<ElementType, 1>::empty(_queue, { mlb_size }, alloc);
34-
_offsets = ndarray<std::uint32_t, 1>::empty(
32+
_data_layer = pr::ndarray<ElementType, 1>::empty(_queue, { array_size }, alloc);
33+
_mlb_layer = pr::ndarray<ElementType, 1>::empty(_queue, { mlb_size }, alloc);
34+
_offsets = pr::ndarray<std::uint32_t, 1>::empty(
3535
_queue,
3636
{ array_size + 1 },
3737
alloc); /// First offset is to keep the size of the frontier
38-
_buffer = ndarray<std::uint32_t, 1>::empty(_queue, { 10 }, alloc);
38+
_buffer = pr::ndarray<std::uint32_t, 1>::empty(_queue, { 10 }, alloc);
3939

4040
sycl::event e1, e2, e3;
4141
e1 = _data_layer.fill(_queue, ElementType(0));
@@ -49,13 +49,13 @@ frontier<ElementType>::frontier(sycl::queue& queue, std::uint64_t num_items, syc
4949

5050
template <typename ElementType>
5151
bool frontier<ElementType>::empty() {
52-
ndview<std::uint32_t, 1> empty_buff = _buffer.slice(0, 1);
52+
pr::ndview<std::uint32_t, 1> empty_buff = _buffer.slice(0, 1);
5353
auto copy_e = fill(_queue, empty_buff, buffer_t(0));
5454
auto* const empty_buff_ptr = empty_buff.get_mutable_data();
5555

5656
auto e = _queue.submit([&](sycl::handler& cgh) {
5757
cgh.depends_on(copy_e);
58-
const auto range = make_range_1d(_mlb_layer.get_count());
58+
const auto range = oneapi::dal::backend::make_range_1d(_mlb_layer.get_count());
5959
auto sum_reduction = sycl::reduction(empty_buff_ptr, sycl::plus<>());
6060
auto* const f_ptr = _mlb_layer.get_mutable_data();
6161

@@ -113,7 +113,7 @@ inline sycl::event frontier<ElementType>::compute_active_frontier() {
113113

114114
// check if local memory is enough
115115
bool use_local_mem =
116-
device_local_mem_size(this->_queue) >=
116+
oneapi::dal::backend::device_local_mem_size(this->_queue) >=
117117
static_cast<std::int64_t>(local_range * element_bitsize * sizeof(uint32_t));
118118

119119
auto e0 = _queue.submit([&](sycl::handler& cgh) {
@@ -129,7 +129,7 @@ inline sycl::event frontier<ElementType>::compute_active_frontier() {
129129
cgh.depends_on(e0);
130130

131131
if (!use_local_mem) {
132-
cgh.parallel_for(make_range_1d(_mlb_layer.get_count()),
132+
cgh.parallel_for(oneapi::dal::backend::make_range_1d(_mlb_layer.get_count()),
133133
[=,
134134
offsets = offsets_pointer,
135135
offsets_size = offsets_size_pointer,
@@ -157,7 +157,7 @@ inline sycl::event frontier<ElementType>::compute_active_frontier() {
157157
sycl::local_accessor<uint32_t, 1> local_size(1, cgh);
158158

159159
cgh.parallel_for(
160-
make_multiple_nd_range_1d(global_range, local_range),
160+
oneapi::dal::backend::make_multiple_nd_range_1d(global_range, local_range),
161161
[=,
162162
offsets = offsets_pointer,
163163
offsets_size = offsets_size_pointer,
@@ -216,4 +216,4 @@ INSTANTIATE(std::uint32_t)
216216

217217
#endif
218218

219-
} // namespace oneapi::dal::backend::primitives
219+
} // namespace oneapi::dal::preview::backend::primitives

cpp/oneapi/dal/backend/primitives/frontier/graph.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "oneapi/dal/graph/detail/container.hpp"
2323
#include "oneapi/dal/backend/primitives/ndarray.hpp"
2424

25-
namespace oneapi::dal::backend::primitives {
25+
namespace oneapi::dal::preview::backend::primitives {
2626

2727
template <typename VertexT = std::uint32_t,
2828
typename EdgeT = std::uint32_t,
@@ -129,9 +129,9 @@ class csr_graph {
129129
std::int64_t col_indices_size = static_cast<std::int64_t>(col_indices.size());
130130
std::int64_t weights_size = static_cast<std::int64_t>(weights.size());
131131

132-
_row_ptr = ndarray<vertex_t, 1>::empty(_queue, { row_ptr_size }, alloc);
133-
_col_indices = ndarray<edge_t, 1>::empty(_queue, { col_indices_size }, alloc);
134-
_weights = ndarray<weight_t, 1>::empty(_queue, { weights_size }, alloc);
132+
_row_ptr = pr::ndarray<vertex_t, 1>::empty(_queue, { row_ptr_size }, alloc);
133+
_col_indices = pr::ndarray<edge_t, 1>::empty(_queue, { col_indices_size }, alloc);
134+
_weights = pr::ndarray<weight_t, 1>::empty(_queue, { weights_size }, alloc);
135135

136136
auto e1 = dal::backend::copy_host2usm(_queue,
137137
_row_ptr.get_mutable_data(),
@@ -171,9 +171,9 @@ class csr_graph {
171171
private:
172172
sycl::queue& _queue;
173173
std::uint64_t _num_nodes;
174-
ndarray<vertex_t, 1> _row_ptr;
175-
ndarray<edge_t, 1> _col_indices;
176-
ndarray<weight_t, 1> _weights;
174+
pr::ndarray<vertex_t, 1> _row_ptr;
175+
pr::ndarray<edge_t, 1> _col_indices;
176+
pr::ndarray<weight_t, 1> _weights;
177177
};
178178

179-
} // namespace oneapi::dal::backend::primitives
179+
} // namespace oneapi::dal::preview::backend::primitives

cpp/oneapi/dal/backend/primitives/frontier/test/advance_dpc.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "oneapi/dal/test/engine/common.hpp"
2424

25-
namespace oneapi::dal::backend::primitives::test {
25+
namespace oneapi::dal::preview::backend::primitives::test {
2626

2727
namespace pr = dal::backend::primitives;
2828

@@ -81,12 +81,11 @@ TEST("test advance operation", "[advance]") {
8181
const std::uint64_t num_nodes = GENERATE(128, 512, 1024);
8282

8383
const auto graph_data = generate_random_graph(num_nodes, edge_probability, seed);
84-
auto graph =
85-
pr::csr_graph(queue, graph_data.row_ptr, graph_data.col_indices, graph_data.weights);
84+
auto graph = csr_graph(queue, graph_data.row_ptr, graph_data.col_indices, graph_data.weights);
8685
auto in_frontier =
87-
pr::frontier<std::uint32_t>(queue, graph.get_vertex_count(), sycl::usm::alloc::device);
86+
frontier<std::uint32_t>(queue, graph.get_vertex_count(), sycl::usm::alloc::device);
8887
auto out_frontier =
89-
pr::frontier<std::uint32_t>(queue, graph.get_vertex_count(), sycl::usm::alloc::device);
88+
frontier<std::uint32_t>(queue, graph.get_vertex_count(), sycl::usm::alloc::device);
9089

9190
std::vector<bool> host_frontier(num_nodes, false);
9291
std::mt19937 frontier_rng(seed ^ 0x9e3779b9u);
@@ -108,17 +107,17 @@ TEST("test advance operation", "[advance]") {
108107
host_frontier[fallback_vertex] = true;
109108
}
110109

111-
pr::advance(graph,
112-
in_frontier,
113-
out_frontier,
114-
[=](auto vertex, auto neighbor, auto edge, auto weight) {
115-
return true; // Always advance
116-
})
110+
advance(graph,
111+
in_frontier,
112+
out_frontier,
113+
[=](auto vertex, auto neighbor, auto edge, auto weight) {
114+
return true; // Always advance
115+
})
117116
.wait_and_throw();
118117

119118
auto tmp_frontier =
120119
compute_next_frontier(graph_data.row_ptr, graph_data.col_indices, host_frontier);
121120
compare_frontiers(out_frontier, tmp_frontier, num_nodes);
122121
} // TEST "test advance operation"
123122

124-
} // namespace oneapi::dal::backend::primitives::test
123+
} // namespace oneapi::dal::preview::backend::primitives::test

cpp/oneapi/dal/backend/primitives/frontier/test/bfs_dpc.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <vector>
2424
#include <map>
2525

26-
namespace oneapi::dal::backend::primitives::test {
26+
namespace oneapi::dal::preview::backend::primitives::test {
2727

2828
namespace pr = dal::backend::primitives;
2929

@@ -62,10 +62,9 @@ TEST("test BFS", "[bfs]") {
6262
const std::uint64_t num_nodes = GENERATE(128, 512, 1024);
6363

6464
const auto graph_data = generate_random_graph(num_nodes, edge_probability, seed);
65-
auto graph =
66-
pr::csr_graph(queue, graph_data.row_ptr, graph_data.col_indices, graph_data.weights);
67-
auto in_frontier = pr::frontier<std::uint32_t>(queue, num_nodes, sycl::usm::alloc::device);
68-
auto out_frontier = pr::frontier<std::uint32_t>(queue, num_nodes, sycl::usm::alloc::device);
65+
auto graph = csr_graph(queue, graph_data.row_ptr, graph_data.col_indices, graph_data.weights);
66+
auto in_frontier = frontier<std::uint32_t>(queue, num_nodes, sycl::usm::alloc::device);
67+
auto out_frontier = frontier<std::uint32_t>(queue, num_nodes, sycl::usm::alloc::device);
6968
pr::ndarray<std::uint32_t, 1> distance =
7069
pr::ndarray<std::uint32_t, 1>::empty(queue,
7170
{ static_cast<std::int64_t>(num_nodes) },
@@ -87,19 +86,19 @@ TEST("test BFS", "[bfs]") {
8786

8887
/// Start BFS
8988
while (!in_frontier.empty()) {
90-
auto e = pr::advance(graph,
91-
in_frontier,
92-
out_frontier,
93-
[=](auto vertex, auto neighbor, auto edge, auto weight) {
94-
bool visited = distance_ptr[neighbor] < num_nodes + 1;
95-
if (!visited) {
96-
distance_ptr[neighbor] = iter + 1;
97-
}
98-
return !visited;
99-
});
89+
auto e = advance(graph,
90+
in_frontier,
91+
out_frontier,
92+
[=](auto vertex, auto neighbor, auto edge, auto weight) {
93+
bool visited = distance_ptr[neighbor] < num_nodes + 1;
94+
if (!visited) {
95+
distance_ptr[neighbor] = iter + 1;
96+
}
97+
return !visited;
98+
});
10099
e.wait_and_throw();
101100
iter++;
102-
pr::swap_frontiers(in_frontier, out_frontier);
101+
swap_frontiers(in_frontier, out_frontier);
103102
out_frontier.clear();
104103
}
105104
/// End BFS
@@ -112,4 +111,4 @@ TEST("test BFS", "[bfs]") {
112111
}
113112
} // TEST "test advance operation"
114113

115-
} // namespace oneapi::dal::backend::primitives::test
114+
} // namespace oneapi::dal::preview::backend::primitives::test

cpp/oneapi/dal/backend/primitives/frontier/test/frontier_dpc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "oneapi/dal/backend/primitives/frontier/test/utils.hpp"
2020
#include "oneapi/dal/test/engine/common.hpp"
2121

22-
namespace oneapi::dal::backend::primitives::test {
22+
namespace oneapi::dal::preview::backend::primitives::test {
2323

2424
namespace pr = dal::backend::primitives;
2525

@@ -39,7 +39,7 @@ TEST("frontier queue basic operations", "[frontier]") {
3939
print_device_name(queue);
4040

4141
const std::uint64_t num_items = 100;
42-
auto f = pr::frontier<std::uint32_t>(queue, num_items, sycl::usm::alloc::shared);
42+
auto f = frontier<std::uint32_t>(queue, num_items, sycl::usm::alloc::shared);
4343

4444
REQUIRE(f.empty() == true);
4545
f.insert(0);
@@ -71,4 +71,4 @@ TEST("frontier queue basic operations", "[frontier]") {
7171
REQUIRE(f.empty() == true);
7272
} // TEST "frontier queue operations"
7373

74-
} // namespace oneapi::dal::backend::primitives::test
74+
} // namespace oneapi::dal::preview::backend::primitives::test

cpp/oneapi/dal/backend/primitives/frontier/test/utils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void print_device_name(sycl::queue& queue) {
2626
std::cout << "Running on device: " << device_name << std::endl;
2727
}
2828

29-
namespace oneapi::dal::backend::primitives {
29+
namespace oneapi::dal::preview::backend::primitives {
3030
struct csr_graph_data {
3131
std::vector<std::uint32_t> row_ptr;
3232
std::vector<std::uint32_t> col_indices;
@@ -76,4 +76,4 @@ csr_graph_data generate_random_graph(std::uint64_t vertex_count,
7676
return { std::move(row_ptr), std::move(col_indices), std::move(weights) };
7777
}
7878

79-
} // namespace oneapi::dal::backend::primitives
79+
} // namespace oneapi::dal::preview::backend::primitives

0 commit comments

Comments
 (0)