Skip to content

Commit e6eed1a

Browse files
[SYCL] Emit suppressed warnings from SYCL headers (#2575)
This updates FE tests related to the following warnings: - Passing kernel functions by value is deprecated in SYCL 2020. - Passing of kernel functions by reference is a SYCL 2020 extension. - SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable. The updated tests include the mock <sycl.hpp> header file and call the kernel invocation functions defined in the mock header.
1 parent dceaeaa commit e6eed1a

File tree

6 files changed

+98
-121
lines changed

6 files changed

+98
-121
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11060,10 +11060,10 @@ def err_sycl_invalid_accessor_property_list_template_param : Error<
1106011060
"%select{parameter pack|type|non-negative integer}1">;
1106111061
def warn_sycl_pass_by_value_deprecated
1106211062
: Warning<"Passing kernel functions by value is deprecated in SYCL 2020">,
11063-
InGroup<Sycl2020Compat>;
11063+
InGroup<Sycl2020Compat>, ShowInSystemHeader;
1106411064
def warn_sycl_pass_by_reference_future
1106511065
: Warning<"Passing of kernel functions by reference is a SYCL 2020 extension">,
11066-
InGroup<Sycl2017Compat>;
11066+
InGroup<Sycl2017Compat>, ShowInSystemHeader;
1106711067
def warn_sycl_attibute_function_raw_ptr
1106811068
: Warning<"SYCL 1.2.1 specification does not allow %0 attribute applied "
1106911069
"to a function with a raw pointer "
@@ -11073,7 +11073,7 @@ def warn_sycl_implicit_decl
1107311073
: Warning<"SYCL 1.2.1 specification requires an explicit forward "
1107411074
"declaration for a kernel type name; your program may not "
1107511075
"be portable">,
11076-
InGroup<SyclStrict>, DefaultIgnore;
11076+
InGroup<SyclStrict>, ShowInSystemHeader, DefaultIgnore;
1107711077
def warn_sycl_restrict_recursion
1107811078
: Warning<"SYCL kernel cannot call a recursive function">,
1107911079
InGroup<SyclStrict>, DefaultError;

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ ATTR_SYCL_KERNEL void kernel_single_task(const KernelType &kernelFunc) {
281281
kernelFunc();
282282
}
283283

284+
template <typename KernelName = auto_name, typename KernelType>
285+
ATTR_SYCL_KERNEL void kernel_single_task_2017(KernelType kernelFunc) {
286+
kernelFunc();
287+
}
288+
284289
template <typename KernelName, typename KernelType, int Dims>
285290
ATTR_SYCL_KERNEL void
286291
kernel_parallel_for(const KernelType &KernelFunc) {
@@ -323,6 +328,16 @@ class handler {
323328
kernel_single_task<NameT>(kernelFunc);
324329
#else
325330
kernelFunc();
331+
#endif
332+
}
333+
334+
template <typename KernelName = auto_name, typename KernelType>
335+
void single_task_2017(KernelType kernelFunc) {
336+
using NameT = typename get_kernel_name_t<KernelName, KernelType>::name;
337+
#ifdef __SYCL_DEVICE_ONLY__
338+
kernel_single_task_2017<NameT>(kernelFunc);
339+
#else
340+
kernelFunc();
326341
#endif
327342
}
328343
};
Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,37 @@
1-
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -sycl-std=2017 -DSYCL2017 %s
2-
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -sycl-std=2020 -DSYCL2020 %s
3-
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -Wno-sycl-strict -DNODIAG %s
4-
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only -sycl-std=2020 -Wno-sycl-strict -DNODIAG %s
1+
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -verify -fsyntax-only -sycl-std=2017 -DSYCL2017 %s
2+
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -verify -fsyntax-only -sycl-std=2020 -DSYCL2020 %s
3+
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -verify -fsyntax-only -Wno-sycl-strict -DNODIAG %s
4+
// RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -verify -fsyntax-only -sycl-std=2020 -Wno-sycl-strict -DNODIAG %s
55

6-
// SYCL 1.2/2017 - kernel functions passed directly. (Also no const requirement, though mutable lambdas never supported)
7-
template <typename name, typename Func>
8-
#if defined(SYCL2020)
9-
// expected-warning@+2 {{Passing kernel functions by value is deprecated in SYCL 2020}}
10-
#endif
11-
__attribute__((sycl_kernel)) void sycl_2017_single_task(Func kernelFunc) {
12-
kernelFunc();
13-
}
6+
#include "sycl.hpp"
147

15-
// SYCL 2020 - kernel functions are passed by reference.
16-
template <typename name, typename Func>
17-
#if defined(SYCL2017)
18-
// expected-warning@+2 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
19-
#endif
20-
__attribute__((sycl_kernel)) void sycl_2020_single_task(const Func &kernelFunc) {
21-
kernelFunc();
22-
}
8+
using namespace cl::sycl;
239

24-
int do_nothing(int i) {
10+
int simple_add(int i) {
2511
return i + 1;
2612
}
2713

2814
// ensure both compile.
2915
int main() {
30-
sycl_2017_single_task<class sycl12>([]() {
31-
do_nothing(10);
16+
queue q;
17+
#if defined(SYCL2020)
18+
// expected-warning@Inputs/sycl.hpp:285 {{Passing kernel functions by value is deprecated in SYCL 2020}}
19+
// expected-note@+3 {{in instantiation of function template specialization}}
20+
#endif
21+
q.submit([&](handler &h) {
22+
h.single_task_2017<class sycl2017>([]() { simple_add(10); });
3223
});
3324

34-
sycl_2020_single_task<class sycl2020>([]() {
35-
do_nothing(11);
25+
#if defined(SYCL2017)
26+
// expected-warning@Inputs/sycl.hpp:280 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
27+
// expected-note@+3 {{in instantiation of function template specialization}}
28+
#endif
29+
q.submit([&](handler &h) {
30+
h.single_task<class sycl2020>([]() { simple_add(11); });
3631
});
3732

3833
return 0;
3934
}
4035
#if defined(NODIAG)
4136
// expected-no-diagnostics
42-
#endif
37+
#endif
Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
1-
// RUN: %clang_cc1 -fsycl -triple spir64 -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
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -fsyntax-only -Wsycl-strict -sycl-std=2020 -verify %s
32

4-
#include "Inputs/sycl.hpp"
3+
#include "sycl.hpp"
54
class Foo;
65

7-
template <typename Name, typename F>
8-
__attribute__((sycl_kernel)) void kernel(F KernelFunc) {
9-
KernelFunc();
10-
}
6+
using namespace cl::sycl;
117

12-
template <typename Name, typename F>
13-
void parallel_for(F KernelFunc) {
14-
#ifdef ERROR
15-
// expected-error@+4 {{size of kernel arguments (7994 bytes) may exceed the supported maximum of 2048 bytes on some devices}}
16-
#else
17-
// expected-warning@+2 {{size of kernel arguments (7994 bytes) may exceed the supported maximum of 2048 bytes on some devices}}
18-
#endif
19-
kernel<Name>(KernelFunc);
20-
}
8+
queue q;
219

2210
using Accessor =
23-
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer>;
11+
accessor<int, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer>;
12+
13+
// expected-warning@Inputs/sycl.hpp:220 {{size of kernel arguments (7994 bytes) may exceed the supported maximum of 2048 bytes on some devices}}
2414

2515
void use() {
2616
struct S {
@@ -31,6 +21,8 @@ void use() {
3121
int Array[1991];
3222
} Args;
3323
auto L = [=]() { (void)Args; };
34-
// expected-note@+1 {{in instantiation of function template specialization 'parallel_for<Foo}}
35-
parallel_for<Foo>(L);
36-
}
24+
q.submit([&](handler &h) {
25+
// expected-note@+1 {{in instantiation of function template specialization}}
26+
h.single_task<class Foo>(L);
27+
});
28+
}
Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,20 @@
1-
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-int-header=%t.h -fsyntax-only -verify %s -Werror=sycl-strict -DERROR
2-
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-int-header=%t.h -fsyntax-only -verify %s -Wsycl-strict -DWARN
3-
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsycl-int-header=%t.h -fsycl-unnamed-lambda -fsyntax-only -verify %s -Werror=sycl-strict
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -fsycl-int-header=%t.h -fsyntax-only -sycl-std=2020 -verify %s -Werror=sycl-strict -DERROR
2+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -fsycl-int-header=%t.h -fsyntax-only -sycl-std=2020 -verify %s -Wsycl-strict -DWARN
3+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -internal-isystem %S/Inputs -fsycl-int-header=%t.h -fsycl-unnamed-lambda -fsyntax-only -sycl-std=2020 -verify %s -Werror=sycl-strict
44

5-
// SYCL 1.2 Definitions
6-
template <typename name, typename Func>
7-
__attribute__((sycl_kernel)) void sycl_121_single_task(Func kernelFunc) {
8-
kernelFunc();
9-
}
10-
11-
class event {};
12-
class queue {
13-
public:
14-
template <typename T>
15-
event submit(T cgf) { return event{}; }
16-
};
17-
class auto_name {};
18-
template <typename Name, typename Type>
19-
struct get_kernel_name_t {
20-
using name = Name;
21-
};
22-
class handler {
23-
public:
24-
template <typename KernelName = auto_name, typename KernelType>
25-
void single_task(KernelType kernelFunc) {
26-
using NameT = typename get_kernel_name_t<KernelName, KernelType>::name;
27-
#ifdef __SYCL_DEVICE_ONLY__
28-
sycl_121_single_task<NameT>(kernelFunc);
29-
#else
30-
kernelFunc();
31-
#endif
32-
}
33-
};
34-
// -- /Definitions
5+
#include "sycl.hpp"
356

367
#ifdef __SYCL_UNNAMED_LAMBDA__
378
// expected-no-diagnostics
389
#endif
3910

11+
using namespace cl::sycl;
4012

13+
// user-defined function
4114
void function() {
4215
}
4316

44-
// user-defined class
17+
// user-defined struct
4518
struct myWrapper {
4619
};
4720

@@ -50,34 +23,57 @@ class myWrapper2;
5023

5124
int main() {
5225
queue q;
53-
#ifndef __SYCL_UNNAMED_LAMBDA__
26+
27+
#if defined(WARN)
28+
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
29+
// expected-note@+7 {{InvalidKernelName1 declared here}}
30+
// expected-note@+8 {{in instantiation of function template specialization}}
31+
#elif defined(ERROR)
32+
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
5433
// expected-note@+3 {{InvalidKernelName1 declared here}}
55-
// expected-note@+4{{in instantiation of function template specialization}}
56-
// expected-error@28 {{kernel needs to have a globally-visible name}}
34+
// expected-note@+4 {{in instantiation of function template specialization}}
35+
#endif
5736
class InvalidKernelName1 {};
5837
q.submit([&](handler &h) {
5938
h.single_task<InvalidKernelName1>([]() {});
6039
});
61-
#endif
40+
6241
#if defined(WARN)
63-
// expected-warning@+6 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
64-
// expected-note@+5 {{fake_kernel declared here}}
42+
// expected-warning@Inputs/sycl.hpp:220 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
6543
#elif defined(ERROR)
66-
// expected-error@+3 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
67-
// expected-note@+2 {{fake_kernel declared here}}
44+
// expected-error@Inputs/sycl.hpp:220 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
6845
#endif
69-
sycl_121_single_task<class fake_kernel>([]() { function(); });
46+
47+
q.submit([&](handler &h) {
48+
#ifndef __SYCL_UNNAMED_LAMBDA__
49+
// expected-note@+3 {{fake_kernel declared here}}
50+
// expected-note@+2 {{in instantiation of function template specialization}}
51+
#endif
52+
h.single_task<class fake_kernel>([]() { function(); });
53+
});
54+
7055
#if defined(WARN)
71-
// expected-warning@+6 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
72-
// expected-note@+5 {{fake_kernel2 declared here}}
56+
// expected-warning@Inputs/sycl.hpp:220 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
7357
#elif defined(ERROR)
74-
// expected-error@+3 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
75-
// expected-note@+2 {{fake_kernel2 declared here}}
58+
// expected-error@Inputs/sycl.hpp:220 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
59+
#endif
60+
61+
q.submit([&](handler &h) {
62+
#ifndef __SYCL_UNNAMED_LAMBDA__
63+
// expected-note@+3 {{fake_kernel2 declared here}}
64+
// expected-note@+2 {{in instantiation of function template specialization}}
7665
#endif
77-
sycl_121_single_task<class fake_kernel2>([]() {
78-
auto l = [](auto f) { f(); };
66+
h.single_task<class fake_kernel2>([]() {
67+
auto l = [](auto f) { f(); };
68+
});
69+
});
70+
71+
q.submit([&](handler &h) {
72+
h.single_task<class myWrapper>([]() { function(); });
73+
});
74+
75+
q.submit([&](handler &h) {
76+
h.single_task<class myWrapper2>([]() { function(); });
7977
});
80-
sycl_121_single_task<class myWrapper>([]() { function(); });
81-
sycl_121_single_task<class myWrapper2>([]() { function(); });
8278
return 0;
8379
}

sycl/test/basic_tests/args-size-overflow.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)