Skip to content

Commit c38ab43

Browse files
committed
WIP
1 parent a70e083 commit c38ab43

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

include/simsycl/detail/parallel_for.hh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ void execute_parallel_for(const sycl::range<Dimensions> &range, const Offset &of
6868
const KernelFunc &func,
6969
Reducers &...reducers) //
7070
{
71+
printf("execute_parallel_for 71\n");
7172
register_kernel_on_static_construction<KernelName, KernelFunc>();
73+
printf("execute_parallel_for 73\n");
7274

7375
simple_kernel<Dimensions, with_offset_v<Offset>> kernel;
7476
if constexpr(std::is_invocable_v<const KernelFunc, sycl::item<Dimensions, with_offset_v<Offset>>, Reducers &...,
@@ -79,7 +81,9 @@ void execute_parallel_for(const sycl::range<Dimensions> &range, const Offset &of
7981
std::is_invocable_v<const KernelFunc, sycl::item<Dimensions, with_offset_v<Offset>>, Reducers &...>);
8082
kernel = [&](const sycl::item<Dimensions> &item) { func(item, reducers...); };
8183
}
82-
sequential_for(range, offset, kernel);
84+
printf("execute_parallel_for 84\n");
85+
sequential_for(range, offset, kernel);
86+
printf("execute_parallel_for 86\n");
8387
}
8488

8589
template<typename KernelName, int Dimensions, typename KernelFunc, typename... Reducers>
@@ -137,6 +141,7 @@ void parallel_for(sycl::range<Dimensions> num_work_items, sycl::kernel_handler k
137141
template<typename KernelName, typename KernelFunc, int Dimensions>
138142
void parallel_for(sycl::range<Dimensions> num_work_items, sycl::id<Dimensions> work_item_offset,
139143
sycl::kernel_handler kh, const KernelFunc &kernel_func) {
144+
printf("parallel_for 140\n");
140145
execute_parallel_for<KernelName>(num_work_items, work_item_offset, kh, kernel_func);
141146
}
142147

include/simsycl/sycl/handler.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class handler {
9191
template<typename KernelName = simsycl::detail::unnamed_kernel, typename KernelType, int Dimensions>
9292
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL void parallel_for(
9393
range<Dimensions> num_work_items, id<Dimensions> work_item_offset, KernelType &&kernel_func) {
94+
printf("parallel_for 94\n");
9495
detail::parallel_for<KernelName>(num_work_items, work_item_offset, kernel_handler(this), kernel_func);
9596
}
9697

src/simsycl/schedule.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,33 @@ namespace simsycl::detail {
4343
template<int Dimensions, typename Offset>
4444
void sequential_for(const sycl::range<Dimensions> &range, const Offset &offset,
4545
const simple_kernel<Dimensions, with_offset_v<Offset>> &kernel) {
46+
printf("sequential_for 46\n");
4647
// limit the number of work items scheduled at a time to avoid allocating huge index buffers
4748
constexpr size_t max_schedule_chunk_size = 16 << 10;
4849
const auto schedule_chunk_size = std::min(range.size(), max_schedule_chunk_size);
4950
const auto &schedule = get_cooperative_schedule();
5051
std::vector<size_t> order(schedule_chunk_size);
5152
auto schedule_state = schedule.init(order);
52-
53+
54+
printf("sequential_for 54\n");
5355
for(size_t schedule_offset = 0; schedule_offset < range.size(); schedule_offset += max_schedule_chunk_size) {
5456
for(size_t schedule_id = 0; schedule_id < schedule_chunk_size; ++schedule_id) {
5557
const auto linear_id = schedule_offset + order[schedule_id];
5658
if(linear_id < range.size()) {
5759
if constexpr(with_offset_v<Offset>) {
5860
const auto id = offset + linear_index_to_id(range, linear_id);
59-
kernel(make_item(id, range, offset));
61+
printf("sequential_for 61\n");
62+
kernel(make_item(id, range, offset));
63+
printf("sequential_for 63\n");
6064
} else {
6165
const auto id = linear_index_to_id(range, linear_id);
6266
kernel(make_item(id, range));
6367
}
6468
}
6569
}
70+
printf("sequential_for 68\n");
6671
schedule_state = schedule.update(schedule_state, order);
72+
printf("sequential_for 70\n");
6773
}
6874
}
6975

test/ambiguity_tests.cc

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,44 @@ using namespace sycl;
77
SIMSYCL_START_IGNORING_DEPRECATIONS
88

99
TEST_CASE("Calls to the deprecated parallel_for signature are not ambiguous", "[ambiguity][parallel_for]") {
10+
printf("START\n");
1011
queue q;
12+
printf("q\n");
1113
constexpr int offset = 7;
14+
printf("1D\n");
1215
SECTION("1D") {
16+
printf("1D A\n");
1317
q.submit([&](handler &cgh) {
14-
cgh.parallel_for(range<1>{1}, id<1>{offset}, [=](id<1> i) { CHECK(i[0] == offset); });
18+
printf("1D B\n");
19+
cgh.parallel_for(range<1>{1}, id<1>{offset}, [=](id<1> i) {
20+
printf("1D C\n");
21+
CHECK(i[0] == offset);
22+
printf("1D D\n");
23+
});
24+
printf("1D E\n");
1525
});
26+
printf("1D F\n");
1627
}
28+
printf("2D\n");
1729
SECTION("2D") {
30+
printf("2D A\n");
1831
q.submit([&](handler &cgh) {
19-
cgh.parallel_for(range<2>{1, 1}, id<2>{0, offset}, [=](id<2> i) { CHECK(i == id<2>{0, offset}); });
32+
printf("2D B\n");
33+
cgh.parallel_for(range<2>{1, 1}, id<2>{0, offset}, [=](id<2> i) {
34+
printf("2D C\n");
35+
CHECK(i == id<2>{0, offset});
36+
printf("2D D\n");
37+
});
38+
printf("2D F\n");
2039
});
2140
}
41+
printf("3D\n");
2242
SECTION("3D") {
2343
q.submit([&](handler &cgh) {
2444
cgh.parallel_for(range<3>{1, 1, 1}, id<3>{0, offset, 0}, [=](id<3> i) { CHECK(i == id<3>{0, offset, 0}); });
2545
});
2646
}
47+
printf("END\n");
2748
}
2849

2950
SIMSYCL_STOP_IGNORING_DEPRECATIONS

0 commit comments

Comments
 (0)