Skip to content

Commit 4be6df0

Browse files
committed
Improve test and add comments
1 parent 13dd2b6 commit 4be6df0

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6284,7 +6284,13 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
62846284
O << "#include <sycl/detail/defines_elementary.hpp>\n";
62856285
O << "#include <sycl/detail/kernel_desc.hpp>\n";
62866286
O << "#include <sycl/ext/oneapi/experimental/free_function_traits.hpp>\n";
6287-
O << "#include <sycl/ext/oneapi/properties/properties.hpp>\n";
6287+
// When using work group memory parameters in free kernel functions, the
6288+
// integration header emits incorrect forward declarations for the work group
6289+
// memory type because it ignores default arguments. This means the user
6290+
// cannot use work group memory types with parameters omitted such as
6291+
// work_group_memory<int> where the hidden second parameter has a default
6292+
// value. To circumvent this, we include the correct forward declaration
6293+
// ourselves.
62886294
O << "#include <sycl/ext/oneapi/experimental/work_group_memory_forward_decl.hpp>\n";
62896295
O << "\n";
62906296

sycl/include/sycl/handler.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#pragma once
10-
#include <iostream>
1110
#include <sycl/access/access.hpp>
1211
#include <sycl/accessor.hpp>
1312
#include <sycl/context.hpp>

sycl/test-e2e/WorkGroupMemory/free_function_kernel.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ using namespace sycl;
1414
queue q;
1515
context ctx = q.get_context();
1616

17-
int sum_helper(sycl::ext::oneapi::experimental::work_group_memory<int[]> mem,
18-
size_t WGSIZE) {
19-
int ret = 0;
17+
void sum_helper(sycl::ext::oneapi::experimental::work_group_memory<int[]> mem,
18+
sycl::ext::oneapi::experimental::work_group_memory<int> ret,
19+
size_t WGSIZE) {
20+
ret = 0;
2021
for (int i = 0; i < WGSIZE; ++i) {
2122
ret += mem[i];
2223
}
23-
return ret;
2424
}
2525

2626
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
@@ -38,7 +38,9 @@ void sum(sycl::ext::oneapi::experimental::work_group_memory<int[]> mem,
3838
*Result += mem[i];
3939
}
4040
} else {
41-
*Result = sum_helper(mem, WGSIZE);
41+
sycl::ext::oneapi::experimental::work_group_memory<int> ret;
42+
sum_helper(mem, ret, WGSIZE);
43+
*Result = ret;
4244
}
4345
}
4446
}

0 commit comments

Comments
 (0)