Skip to content

Commit 7324b3e

Browse files
authored
[SYCL][FPGA] Add mutual diagnostic of max_concurrency attribute in conjunction of disable_loop_pipelining attribute (#3512)
This patch 1. removes FIXME and adds mutual diagnostic of max_concurrency and disable_loop_pipelining attributes. 2. updates document 3. adds tests Signed-off-by: Soumi Manna <[email protected]>
1 parent 35db973 commit 7324b3e

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

clang/include/clang/Basic/Attr.td

+3
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,9 @@ def : MutualExclusions<[SYCLIntelFPGAIVDep,
19571957
def : MutualExclusions<[SYCLIntelFPGAMaxConcurrency,
19581958
SYCLIntelFPGADisableLoopPipelining]>;
19591959

1960+
def : MutualExclusions<[SYCLIntelFPGAMaxConcurrency,
1961+
SYCLIntelFPGADisableLoopPipelining]>;
1962+
19601963
def SYCLIntelFPGAMaxInterleaving : StmtAttr {
19611964
let Spellings = [CXX11<"intelfpga","max_interleaving">,
19621965
CXX11<"intel","max_interleaving">];

clang/include/clang/Basic/AttrDocs.td

+6-5
Original file line numberDiff line numberDiff line change
@@ -2869,7 +2869,7 @@ This attribute applies to a loop or a function. It indicates that the
28692869
loop/function should allow no more than N threads or iterations to execute it
28702870
simultaneously. N must be a non negative integer. '0' indicates the
28712871
max_concurrency case to be unbounded. Cannot be applied multiple times to the
2872-
same loop.
2872+
same loop or function, or in conjunction with ``disable_loop_pipelining``.
28732873

28742874
.. code-block:: c++
28752875

@@ -2935,17 +2935,18 @@ def SYCLIntelFPGADisableLoopPipeliningAttrDocs : Documentation {
29352935
This attribute applies to a loop or a function. Takes no arguments and
29362936
disables pipelining of the loop or function data path, causing the loop
29372937
or function to be executed serially. Cannot be used on the same loop or
2938-
function in conjunction with max_interleaving, speculated_iterations,
2939-
max_concurrency, initiation_interval, or ivdep.
2938+
function, or in conjunction with ``max_interleaving``,
2939+
``speculated_iterations``, ``max_concurrency``, ``initiation_interval``,
2940+
or ``ivdep``.
29402941

29412942
.. code-block:: c++
29422943

29432944
void foo() {
29442945
int var = 0;
2945-
[[intel::disable_loop_pipelining] for (int i = 0; i < 10; ++i) var++;
2946+
[[intel::disable_loop_pipelining]] for (int i = 0; i < 10; ++i) var++;
29462947
}
29472948

2948-
[[intel::disable_loop_pipelining] void foo1() { }
2949+
[[intel::disable_loop_pipelining]] void foo1() { }
29492950

29502951
}];
29512952
}

clang/lib/Sema/SemaDeclAttr.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -6292,12 +6292,6 @@ SYCLIntelFPGAMaxConcurrencyAttr *Sema::MergeSYCLIntelFPGAMaxConcurrencyAttr(
62926292
}
62936293
return nullptr;
62946294
}
6295-
// FIXME
6296-
// max_concurrency and disable_component_pipelining attributes can't be
6297-
// applied to the same function. Upcoming patch needs to have this code
6298-
// added to it:
6299-
// if (checkAttrMutualExclusion<IntelDisableComponentPipeline>(S, D, AL))
6300-
// return;
63016295

63026296
return ::new (Context)
63036297
SYCLIntelFPGAMaxConcurrencyAttr(Context, A, A.getNThreadsExpr());
@@ -6337,12 +6331,6 @@ void Sema::AddSYCLIntelFPGAMaxConcurrencyAttr(Decl *D,
63376331
static void handleSYCLIntelFPGAMaxConcurrencyAttr(Sema &S, Decl *D,
63386332
const ParsedAttr &A) {
63396333
S.CheckDeprecatedSYCLAttributeSpelling(A);
6340-
// FIXME
6341-
// max_concurrency and disable_component_pipelining attributes can't be
6342-
// applied to the same function. Upcoming patch needs to have this code
6343-
// added to it:
6344-
// if (checkAttrMutualExclusion<IntelDisableComponentPipeline>(S, D, AL))
6345-
// return;
63466334

63476335
Expr *E = A.getArgAsExpr(0);
63486336
S.AddSYCLIntelFPGAMaxConcurrencyAttr(D, A, E);

clang/test/SemaSYCL/max-concurrency.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ class Functor1 {
1616

1717
[[intel::max_concurrency]] void foo() {} // expected-error {{'max_concurrency' attribute takes one argument}}
1818

19+
// Tests for Intel FPGA max_concurrency and disable_loop_pipelining function attributes compatibility.
20+
// expected-error@+2 {{'max_concurrency' and 'disable_loop_pipelining' attributes are not compatible}}
21+
// expected-note@+1 {{conflicting attribute is here}}
22+
[[intel::disable_loop_pipelining]] [[intel::max_concurrency(2)]] void check();
23+
24+
// expected-error@+2 {{'disable_loop_pipelining' and 'max_concurrency' attributes are not compatible}}
25+
// expected-note@+1 {{conflicting attribute is here}}
26+
[[intel::max_concurrency(4)]] [[intel::disable_loop_pipelining]] void check1();
27+
28+
// expected-error@+3 {{'disable_loop_pipelining' and 'max_concurrency' attributes are not compatible}}
29+
// expected-note@+1 {{conflicting attribute is here}}
30+
[[intel::max_concurrency(4)]] void check2();
31+
[[intel::disable_loop_pipelining]] void check2();
32+
1933
class Functor2 {
2034
public:
2135
void operator()() const {

clang/utils/TableGen/ClangAttrEmitter.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -3695,6 +3695,11 @@ static void GenerateMutualExclusionsChecks(const Record &Attr,
36953695
}
36963696
}
36973697

3698+
// If there are any decl or stmt attributes, silence -Woverloaded-virtual
3699+
// warnings for them both.
3700+
if (!DeclAttrs.empty() || !StmtAttrs.empty())
3701+
OS << " using ParsedAttrInfo::diagMutualExclusion;\n\n";
3702+
36983703
// If we discovered any decl or stmt attributes to test for, generate the
36993704
// predicates for them now.
37003705
if (!DeclAttrs.empty()) {

0 commit comments

Comments
 (0)