Skip to content

Commit af4f734

Browse files
committed
Fixes after Prem's review
Signed-off-by: Zahira Ammarguellat <[email protected]>
1 parent 447ca30 commit af4f734

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,10 +2865,11 @@ def SYCLIntelFPGAMaxConcurrencyAttrDocs : Documentation {
28652865
let Category = DocCatVariable;
28662866
let Heading = "intel::max_concurrency";
28672867
let Content = [{
2868-
This attribute applies to a loop or a function. Indicates that the loop/function
2869-
should allow no more than N threads or iterations to execute it simultaneously.
2870-
N must be a non negative integer. '0' indicates the max_concurrency case to b
2871-
unbounded. Cannot be applied multiple times to the same loop.
2868+
This attribute applies to a loop or a function. It indicates that the
2869+
loop/function should allow no more than N threads or iterations to execute it
2870+
simultaneously. N must be a non negative integer. '0' indicates the
2871+
max_concurrency case to be unbounded. Cannot be applied multiple times to the
2872+
same loop.
28722873

28732874
.. code-block:: c++
28742875

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6471,9 +6471,9 @@ void Sema::AddSYCLIntelFPGAMaxConcurrencyAttr(Decl *D,
64716471
E = Res.get();
64726472

64736473
// This attribute requires a strictly positive value.
6474-
if (ArgVal <= 0) {
6474+
if (ArgVal < 0) {
64756475
Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer)
6476-
<< CI << /*positive*/ 0;
6476+
<< CI << /*non-negative*/ 1;
64776477
return;
64786478
}
64796479

clang/test/SemaSYCL/max-concurrency.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
using namespace cl::sycl;
66

7+
class Functor0 {
8+
public:
9+
[[intel::max_concurrency(0)]] void operator()() const {}
10+
};
11+
712
class Functor1 {
813
public:
914
[[intel::max_concurrency(4)]] void operator()() const {}
@@ -36,7 +41,7 @@ class Functor4 {
3641
}
3742
};
3843

39-
// expected-error@+1 {{'max_concurrency' attribute requires a positive integral compile time constant expression}}
44+
// expected-error@+1 {{'max_concurrency' attribute requires a non-negative integral compile time constant expression}}
4045
[[intel::max_concurrency(-1)]] void bar() {}
4146
class Functor5 {
4247
public:
@@ -45,6 +50,14 @@ class Functor5 {
4550
}
4651
};
4752

53+
[[intel::max_concurrency(0)]] void bar0() {}
54+
class Functor6 {
55+
public:
56+
void operator() () const {
57+
bar0();
58+
}
59+
};
60+
4861
// expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'const char [16]'}}
4962
[[intel::max_concurrency("numberofthreads")]] void zoo() {}
5063

@@ -58,6 +71,9 @@ int main() {
5871
queue q;
5972

6073
q.submit([&](handler &h) {
74+
Functor1 f0;
75+
h.single_task<class kernel_name1>(f0);
76+
6177
Functor1 f1;
6278
h.single_task<class kernel_name1>(f1);
6379

@@ -81,6 +97,11 @@ int main() {
8197
});
8298
}
8399

100+
// CHECK: CXXMethodDecl {{.*}} operator() {{.*}}
101+
// CHECK: SYCLIntelFPGAMaxConcurrencyAttr
102+
// CHECK: ConstantExpr {{.*}} 'int'
103+
// CHECK: value: Int 0
104+
// CHECK: IntegerLiteral {{.*}}0{{$}}
84105
// CHECK: CXXMethodDecl {{.*}}used operator() {{.*}}
85106
// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}}
86107
// CHECK: ConstantExpr {{.*}} 'int'
@@ -94,6 +115,11 @@ int main() {
94115
// CHECK: ConstantExpr {{.*}} 'int'
95116
// CHECK: value: Int 4
96117
// CHECK: IntegerLiteral {{.*}}4{{$}}
118+
// CHECK: FunctionDecl {{.*}}{{.*}} used bar0 {{.*}}
119+
// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}}
120+
// CHECK: ConstantExpr {{.*}} 'int'
121+
// CHECK: value: Int 0
122+
// CHECK:IntegerLiteral {{.*}}{{.*}}0{{$}}
97123
// CHECK: FunctionDecl {{.*}}{{.*}}func {{.*}}
98124
// CHECK: SYCLIntelFPGAMaxConcurrencyAttr {{.*}}
99125
// CHECK: FunctionDecl {{.*}}{{.*}}used func 'void ()'

0 commit comments

Comments
 (0)