Skip to content

Commit 4960fc9

Browse files
[SYCL] Generate warning about kernel argument size on all devices (#2509)
* [SYCL] Generate warning about kernel argument size on all devices Warning about possible device limitation for kernel argument size should be generated for all devices. Signed-off-by: Elizabeth Andrews <[email protected]>
1 parent d76a6a0 commit 4960fc9

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11004,8 +11004,8 @@ def err_sycl_restrict : Error<
1100411004
"nor constant-initialized"
1100511005
"}0">;
1100611006
def warn_sycl_kernel_too_big_args : Warning<
11007-
"size of kernel arguments (%0 bytes) exceeds supported maximum of %1 bytes "
11008-
"on GPU">, InGroup<SyclStrict>;
11007+
"size of kernel arguments (%0 bytes) may exceed the supported maximum "
11008+
"of %1 bytes on some devices">, InGroup<SyclStrict>;
1100911009
def err_sycl_virtual_types : Error<
1101011010
"No class with a vtable can be used in a SYCL kernel or any code included in the kernel">;
1101111011
def note_sycl_recursive_function_declared_here: Note<"function implemented using recursion declared here">;

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ enum KernelInvocationKind {
5858

5959
const static std::string InitMethodName = "__init";
6060
const static std::string FinalizeMethodName = "__finalize";
61-
constexpr unsigned GPUMaxKernelArgsSize = 2048;
61+
constexpr unsigned MaxKernelArgsSize = 2048;
6262

6363
namespace {
6464

@@ -1697,11 +1697,9 @@ class SyclKernelArgsSizeChecker : public SyclKernelFieldHandler {
16971697
: SyclKernelFieldHandler(S), KernelLoc(Loc) {}
16981698

16991699
~SyclKernelArgsSizeChecker() {
1700-
if (SemaRef.Context.getTargetInfo().getTriple().getSubArch() ==
1701-
llvm::Triple::SPIRSubArch_gen)
1702-
if (SizeOfParams > GPUMaxKernelArgsSize)
1703-
SemaRef.Diag(KernelLoc, diag::warn_sycl_kernel_too_big_args)
1704-
<< SizeOfParams << GPUMaxKernelArgsSize;
1700+
if (SizeOfParams > MaxKernelArgsSize)
1701+
SemaRef.Diag(KernelLoc, diag::warn_sycl_kernel_too_big_args)
1702+
<< SizeOfParams << MaxKernelArgsSize;
17051703
}
17061704

17071705
bool handleSyclAccessorType(FieldDecl *FD, QualType FieldTy) final {

clang/test/SemaSYCL/args-size-overflow.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// RUN: %clang_cc1 -fsycl -triple spir64_gen -DGPU -fsycl-is-device -fsyntax-only -verify %s
21
// RUN: %clang_cc1 -fsycl -triple spir64 -fsycl-is-device -fsyntax-only -verify %s
3-
// RUN: %clang_cc1 -fsycl -triple spir64_gen -Wno-sycl-strict -fsycl-is-device -fsyntax-only -verify %s
4-
// RUN: %clang_cc1 -fsycl -triple spir64_gen -Werror=sycl-strict -DERROR -fsycl-is-device -fsyntax-only -verify %s
2+
// RUN: %clang_cc1 -fsycl -triple spir64 -Werror=sycl-strict -DERROR -fsycl-is-device -fsyntax-only -verify %s
53

64
#include "Inputs/sycl.hpp"
75
class Foo;
@@ -13,12 +11,10 @@ __attribute__((sycl_kernel)) void kernel(F KernelFunc) {
1311

1412
template <typename Name, typename F>
1513
void parallel_for(F KernelFunc) {
16-
#ifdef GPU
17-
// expected-warning@+6 {{size of kernel arguments (7994 bytes) exceeds supported maximum of 2048 bytes on GPU}}
18-
#elif ERROR
19-
// expected-error@+4 {{size of kernel arguments (7994 bytes) exceeds supported maximum of 2048 bytes on GPU}}
14+
#ifdef ERROR
15+
// expected-error@+4 {{size of kernel arguments (7994 bytes) may exceed the supported maximum of 2048 bytes on some devices}}
2016
#else
21-
// expected-no-diagnostics
17+
// expected-warning@+2 {{size of kernel arguments (7994 bytes) may exceed the supported maximum of 2048 bytes on some devices}}
2218
#endif
2319
kernel<Name>(KernelFunc);
2420
}
@@ -35,8 +31,6 @@ void use() {
3531
int Array[1991];
3632
} Args;
3733
auto L = [=]() { (void)Args; };
38-
#if defined(GPU) || defined(ERROR)
39-
// expected-note@+2 {{in instantiation of function template specialization 'parallel_for<Foo}}
40-
#endif
34+
// expected-note@+1 {{in instantiation of function template specialization 'parallel_for<Foo}}
4135
parallel_for<Foo>(L);
4236
}

0 commit comments

Comments
 (0)