Skip to content

Commit 1974560

Browse files
[SYCL] Emit suppressed warnings from the below FE tests:
* SemaSYCL/implicit_kernel_type.cpp * CodeGenSYCL/kernel-by-reference.cpp
1 parent a7ad8b8 commit 1974560

File tree

4 files changed

+99
-84
lines changed

4 files changed

+99
-84
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
};

clang/test/CodeGenSYCL/kernel-by-reference.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
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 -sycl-std=2020 -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 "Inputs/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;
Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,16 @@
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 -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 -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 -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
35-
36-
#ifdef __SYCL_UNNAMED_LAMBDA__
37-
// expected-no-diagnostics
38-
#endif
5+
#include "Inputs/sycl.hpp"
396

7+
using namespace cl::sycl;
408

9+
// user-defined function
4110
void function() {
4211
}
4312

44-
// user-defined class
13+
// user-defined struct
4514
struct myWrapper {
4615
};
4716

@@ -50,34 +19,70 @@ class myWrapper2;
5019

5120
int main() {
5221
queue q;
53-
#ifndef __SYCL_UNNAMED_LAMBDA__
54-
// 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}}
22+
23+
#if defined(WARN)
24+
// expected-warning@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
25+
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
26+
// expected-note@+8 {{InvalidKernelName1 declared here}}
27+
#elif defined(ERROR)
28+
// expected-error@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
29+
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
30+
// expected-note@+4 {{InvalidKernelName1 declared here}}
31+
#elif defined(__SYCL_UNNAMED_LAMBDA__)
32+
// expected-error@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
33+
#endif
5734
class InvalidKernelName1 {};
35+
// expected-note@+2 {{in instantiation of function template specialization}}
5836
q.submit([&](handler &h) {
5937
h.single_task<InvalidKernelName1>([]() {});
6038
});
61-
#endif
39+
6240
#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}}
41+
// 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}}
42+
// expected-warning@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
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}}
45+
// expected-error@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
46+
#elif defined(__SYCL_UNNAMED_LAMBDA__)
47+
// expected-error@Inputs/sycl.hpp:211 {{Passing of kernel functions by reference is a SYCL 2020 extension}}
6848
#endif
69-
sycl_121_single_task<class fake_kernel>([]() { function(); });
49+
50+
q.submit([&](handler &h) {
51+
#ifndef __SYCL_UNNAMED_LAMBDA__
52+
// expected-note@+3 {{fake_kernel declared here}}
53+
#endif
54+
// expected-note@+1 {{in instantiation of function template specialization}}
55+
h.single_task<class fake_kernel>([]() { function(); });
56+
});
57+
7058
#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}}
59+
// 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}}
60+
// expected-warning@Inputs/sycl.hpp:211 3{{Passing of kernel functions by reference is a SYCL 2020 extension}}
7361
#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}}
62+
// 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}}
63+
// expected-error@Inputs/sycl.hpp:211 3{{Passing of kernel functions by reference is a SYCL 2020 extension}}
64+
#elif defined(__SYCL_UNNAMED_LAMBDA__)
65+
// expected-error@Inputs/sycl.hpp:211 3{{Passing of kernel functions by reference is a SYCL 2020 extension}}
7666
#endif
77-
sycl_121_single_task<class fake_kernel2>([]() {
78-
auto l = [](auto f) { f(); };
67+
68+
q.submit([&](handler &h) {
69+
#ifndef __SYCL_UNNAMED_LAMBDA__
70+
// expected-note@+3 {{fake_kernel2 declared here}}
71+
#endif
72+
// expected-note@+1 {{in instantiation of function template specialization}}
73+
h.single_task<class fake_kernel2>([]() {
74+
auto l = [](auto f) { f(); };
75+
});
76+
});
77+
78+
q.submit([&](handler &h) {
79+
// expected-note@+1 {{in instantiation of function template specialization}}
80+
h.single_task<class myWrapper>([]() { function(); });
81+
});
82+
83+
q.submit([&](handler &h) {
84+
// expected-note@+1 {{in instantiation of function template specialization}}
85+
h.single_task<class myWrapper2>([]() { function(); });
7986
});
80-
sycl_121_single_task<class myWrapper>([]() { function(); });
81-
sycl_121_single_task<class myWrapper2>([]() { function(); });
8287
return 0;
8388
}

0 commit comments

Comments
 (0)