|
1 |
| -// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -sycl-std=2020 -fsyntax-only -ast-dump -verify -pedantic %s | FileCheck %s |
| 1 | +// RUN: %clang_cc1 -fsycl-is-device -verify %s |
2 | 2 |
|
3 |
| -#include "sycl.hpp" |
| 3 | +// Test that checks max_concurrency attribute support on function. |
4 | 4 |
|
5 |
| -using namespace cl::sycl; |
| 5 | +// Tests for incorrect argument values for Intel FPGA max_concurrency function attribute. |
| 6 | +[[intel::max_concurrency]] void one() {} // expected-error {{'max_concurrency' attribute takes one argument}} |
6 | 7 |
|
7 |
| -class Functor0 { |
8 |
| -public: |
9 |
| - [[intel::max_concurrency(0)]] void operator()() const {} |
10 |
| -}; |
| 8 | +[[intel::max_concurrency(5)]] int a; // expected-error{{'max_concurrency' attribute only applies to 'for', 'while', 'do' statements, and functions}} |
11 | 9 |
|
12 |
| -class Functor1 { |
13 |
| -public: |
14 |
| - [[intel::max_concurrency(4)]] void operator()() const {} |
15 |
| -}; |
| 10 | +[[intel::max_concurrency("foo")]] void func() {} // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const char[4]'}} |
16 | 11 |
|
17 |
| -[[intel::max_concurrency]] void foo() {} // expected-error {{'max_concurrency' attribute takes one argument}} |
| 12 | +[[intel::max_concurrency(-1)]] void func1() {} // expected-error{{'max_concurrency' attribute requires a non-negative integral compile time constant expression}} |
| 13 | + |
| 14 | +[[intel::max_concurrency(0, 1)]] void func2() {} // expected-error{{'max_concurrency' attribute takes one argument}} |
| 15 | + |
| 16 | +// Tests for Intel FPGA max_concurrency function attribute duplication. |
| 17 | +// No diagnostic is emitted because the arguments match. Duplicate attribute is silently ignored. |
| 18 | +[[intel::max_concurrency(2)]] [[intel::max_concurrency(2)]] void func3() {} |
| 19 | + |
| 20 | +// No diagnostic is emitted because the arguments match. |
| 21 | +[[intel::max_concurrency(4)]] void func4(); |
| 22 | +[[intel::max_concurrency(4)]] void func4(); // OK |
| 23 | + |
| 24 | +// Diagnostic is emitted because the arguments mismatch. |
| 25 | +[[intel::max_concurrency(2)]] // expected-note {{previous attribute is here}} |
| 26 | +[[intel::max_concurrency(4)]] void |
| 27 | +func5() {} // expected-warning@-1 {{attribute 'max_concurrency' is already applied with different arguments}} |
| 28 | + |
| 29 | +[[intel::max_concurrency(1)]] void func6(); // expected-note {{previous attribute is here}} |
| 30 | +[[intel::max_concurrency(3)]] void func6(); // expected-warning {{attribute 'max_concurrency' is already applied with different arguments}} |
18 | 31 |
|
19 | 32 | // Tests for Intel FPGA max_concurrency and disable_loop_pipelining function attributes compatibility.
|
20 | 33 | // expected-error@+2 {{'max_concurrency' and 'disable_loop_pipelining' attributes are not compatible}}
|
21 | 34 | // expected-note@+1 {{conflicting attribute is here}}
|
22 |
| -[[intel::disable_loop_pipelining]] [[intel::max_concurrency(2)]] void check(); |
| 35 | +[[intel::disable_loop_pipelining]] [[intel::max_concurrency(2)]] void func7(); |
23 | 36 |
|
24 | 37 | // expected-error@+2 {{'disable_loop_pipelining' and 'max_concurrency' attributes are not compatible}}
|
25 | 38 | // expected-note@+1 {{conflicting attribute is here}}
|
26 |
| -[[intel::max_concurrency(4)]] [[intel::disable_loop_pipelining]] void check1(); |
| 39 | +[[intel::max_concurrency(4)]] [[intel::disable_loop_pipelining]] void func8(); |
27 | 40 |
|
28 | 41 | // expected-error@+3 {{'disable_loop_pipelining' and 'max_concurrency' attributes are not compatible}}
|
29 | 42 | // expected-note@+1 {{conflicting attribute is here}}
|
30 |
| -[[intel::max_concurrency(4)]] void check2(); |
31 |
| -[[intel::disable_loop_pipelining]] void check2(); |
32 |
| - |
33 |
| -class Functor2 { |
34 |
| -public: |
35 |
| - void operator()() const { |
36 |
| - foo(); |
37 |
| - } |
38 |
| -}; |
39 |
| - |
40 |
| -template <int NT> |
41 |
| -class Functor3 { |
42 |
| -public: |
43 |
| - [[intel::max_concurrency(NT)]] void operator()() const {} |
44 |
| - // expected-error@+1 {{'max_concurrency' attribute only applies to 'for', 'while', 'do' statements, and functions}} |
45 |
| - [[intel::max_concurrency(2)]] int a[10]; |
46 |
| -}; |
47 |
| - |
48 |
| -// expected-error@+1 {{'max_concurrency' attribute takes one argument}} |
49 |
| -[[intel::max_concurrency(3, 3)]] void goo() {} |
50 |
| - |
51 |
| -class Functor4 { |
52 |
| -public: |
53 |
| - void operator() () const { |
54 |
| - goo(); |
55 |
| - } |
56 |
| -}; |
57 |
| - |
58 |
| -// expected-error@+1 {{'max_concurrency' attribute requires a non-negative integral compile time constant expression}} |
59 |
| -[[intel::max_concurrency(-1)]] void bar() {} |
60 |
| -class Functor5 { |
61 |
| -public: |
62 |
| - void operator() () const { |
63 |
| - bar(); |
64 |
| - } |
65 |
| -}; |
66 |
| - |
67 |
| -[[intel::max_concurrency(0)]] void bar0() {} |
68 |
| -class Functor6 { |
69 |
| -public: |
70 |
| - void operator() () const { |
71 |
| - bar0(); |
72 |
| - } |
73 |
| -}; |
74 |
| - |
75 |
| -// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'const char[16]'}} |
76 |
| -[[intel::max_concurrency("numberofthreads")]] void zoo() {} |
77 |
| - |
78 |
| -template <int NT> |
79 |
| -[[intel::max_concurrency(NT)]] void func() {} |
80 |
| - |
81 |
| -[[intel::max_concurrency(8)]] void dup(); // expected-note {{previous attribute is here}} |
82 |
| -[[intel::max_concurrency(9)]] void dup() {} // expected-warning {{attribute 'max_concurrency' is already applied with different arguments}} |
83 |
| - |
84 |
| -int main() { |
85 |
| - queue q; |
86 |
| - |
87 |
| - q.submit([&](handler &h) { |
88 |
| - Functor1 f0; |
89 |
| - h.single_task<class kernel_name1>(f0); |
90 |
| - |
91 |
| - Functor1 f1; |
92 |
| - h.single_task<class kernel_name1>(f1); |
93 |
| - |
94 |
| - Functor2 f2; |
95 |
| - h.single_task<class kernel_name2>(f2); |
96 |
| - |
97 |
| - h.single_task<class kernel_name3>( |
98 |
| - []() [[intel::max_concurrency(3)]]{}); |
99 |
| - |
100 |
| - Functor3<4> f3; |
101 |
| - h.single_task<class kernel_name4>(f3); |
102 |
| - |
103 |
| - h.single_task<class kernel_name5>([]() { |
104 |
| - func<5>(); |
105 |
| - }); |
106 |
| - |
107 |
| - }); |
| 43 | +[[intel::max_concurrency(4)]] void func9(); |
| 44 | +[[intel::disable_loop_pipelining]] void func9(); |
| 45 | + |
| 46 | +// Tests that check template parameter support for Intel FPGA initiation_interval function attributes |
| 47 | +template <int N> |
| 48 | +[[intel::max_concurrency(N)]] void func10(); // expected-error {{'max_concurrency' attribute requires a non-negative integral compile time constant expression}} |
| 49 | + |
| 50 | +template <int size> |
| 51 | +[[intel::max_concurrency(10)]] void func11(); // expected-note {{previous attribute is here}} |
| 52 | +template <int size> |
| 53 | +[[intel::max_concurrency(size)]] void func11() {} // expected-warning {{attribute 'max_concurrency' is already applied with different arguments}} |
| 54 | + |
| 55 | +void checkTemplates() { |
| 56 | + func10<4>(); // OK |
| 57 | + func10<-1>(); // expected-note {{in instantiation of function template specialization 'func10<-1>' requested here}} |
| 58 | + func10<0>(); // OK |
| 59 | + func11<20>(); // expected-note {{in instantiation of function template specialization 'func11<20>' requested here}} |
108 | 60 | }
|
109 | 61 |
|
110 |
| -// CHECK: CXXMethodDecl {{.*}} operator() {{.*}} |
111 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr |
112 |
| -// CHECK: ConstantExpr {{.*}} 'int' |
113 |
| -// CHECK: value: Int 0 |
114 |
| -// CHECK: IntegerLiteral {{.*}}0{{$}} |
115 |
| -// CHECK: CXXMethodDecl {{.*}}used operator() {{.*}} |
116 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
117 |
| -// CHECK: ConstantExpr {{.*}} 'int' |
118 |
| -// CHECK: value: Int 4 |
119 |
| -// CHECK: IntegerLiteral {{.*}}4{{$}} |
120 |
| -// CHECK: CXXMethodDecl {{.*}}operator() {{.*}} |
121 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
122 |
| -// CHECK: DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'NT' 'int' |
123 |
| -// CHECK: CXXMethodDecl {{.*}}{{.*}}used operator() {{.*}} |
124 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
125 |
| -// CHECK: ConstantExpr {{.*}} 'int' |
126 |
| -// CHECK: value: Int 4 |
127 |
| -// CHECK: IntegerLiteral {{.*}}4{{$}} |
128 |
| -// CHECK: FunctionDecl {{.*}}{{.*}} used bar0 {{.*}} |
129 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
130 |
| -// CHECK: ConstantExpr {{.*}} 'int' |
131 |
| -// CHECK: value: Int 0 |
132 |
| -// CHECK:IntegerLiteral {{.*}}{{.*}}0{{$}} |
133 |
| -// CHECK: FunctionDecl {{.*}}{{.*}}func {{.*}} |
134 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
135 |
| -// CHECK: FunctionDecl {{.*}}{{.*}}used func 'void ()' |
136 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
137 |
| -// CHECK: ConstantExpr {{.*}} 'int' |
138 |
| -// CHECK: value: Int 5 |
139 |
| -// CHECK: IntegerLiteral {{.*}}5{{$}} |
140 |
| -// CHECK: FunctionDecl {{.*}}{{.*}}dup {{.*}} |
141 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
142 |
| -// CHECK: ConstantExpr {{.*}} 'int' |
143 |
| -// CHECK: value: Int 8 |
144 |
| -// CHECK: IntegerLiteral {{.*}}8{{$}} |
145 |
| -// CHECK: FunctionDecl {{.*}}{{.*}}dup {{.*}} |
146 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
147 |
| -// CHECK: ConstantExpr {{.*}} 'int' |
148 |
| -// CHECK: value: Int 9 |
149 |
| -// CHECK: IntegerLiteral {{.*}}9{{$}} |
150 |
| -// CHECK: FunctionDecl {{.*}}{{.*}}kernel_name1{{.*}} |
151 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
152 |
| -// CHECK: ConstantExpr {{.*}} 'int' |
153 |
| -// CHECK: value: Int 4 |
154 |
| -// CHECK: IntegerLiteral{{.*}}4{{$}} |
155 |
| -// CHECK: FunctionDecl {{.*}}{{.*}}kernel_name4{{.*}} |
156 |
| -// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}} |
157 |
| -// CHECK: ConstantExpr {{.*}} 'int' |
158 |
| -// CHECK: value: Int 4 |
159 |
| -// CHECK: IntegerLiteral{{.*}}4{{$}} |
| 62 | +// Test that checks expression is not a constant expression. |
| 63 | +// expected-note@+1{{declared here}} |
| 64 | +int baz(); |
| 65 | +// expected-error@+2{{expression is not an integral constant expression}} |
| 66 | +// expected-note@+1{{non-constexpr function 'baz' cannot be used in a constant expression}} |
| 67 | +[[intel::max_concurrency(baz() + 1)]] void func12(); |
| 68 | + |
| 69 | +// Test that checks expression is a constant expression. |
| 70 | +constexpr int bar() { return 0; } |
| 71 | +[[intel::max_concurrency(bar() + 2)]] void func13(); // OK |
| 72 | + |
| 73 | +// Test that checks wrong function template instantiation and ensures that the type |
| 74 | +// is checked properly when instantiating from the template definition. |
| 75 | +template <typename Ty> |
| 76 | +// expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'S'}} |
| 77 | +// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'float'}} |
| 78 | +[[intel::max_concurrency(Ty{})]] void func14() {} |
| 79 | + |
| 80 | +struct S {}; |
| 81 | +void test() { |
| 82 | + // expected-note@+1{{in instantiation of function template specialization 'func14<S>' requested here}} |
| 83 | + func14<S>(); |
| 84 | + // expected-note@+1{{in instantiation of function template specialization 'func14<float>' requested here}} |
| 85 | + func14<float>(); |
| 86 | +} |
0 commit comments