Skip to content

[SYCL] [FPGA] Add mutual diagnostic of max_concurrency attribute in conjunction of disable_loop_pipelining attribute #3512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 13, 2021
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,9 @@ def SYCLIntelFPGADisableLoopPipelining : DeclOrStmtAttr {
def : MutualExclusions<[SYCLIntelFPGAInitiationInterval,
SYCLIntelFPGADisableLoopPipelining]>;

def : MutualExclusions<[SYCLIntelFPGAMaxConcurrency,
SYCLIntelFPGADisableLoopPipelining]>;

def SYCLIntelFPGAMaxInterleaving : StmtAttr {
let Spellings = [CXX11<"intelfpga","max_interleaving">,
CXX11<"intel","max_interleaving">];
Expand Down
11 changes: 6 additions & 5 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -2869,7 +2869,7 @@ This attribute applies to a loop or a function. It indicates that the
loop/function should allow no more than N threads or iterations to execute it
simultaneously. N must be a non negative integer. '0' indicates the
max_concurrency case to be unbounded. Cannot be applied multiple times to the
same loop.
same loop or function, or in conjunction with ``disable_loop_pipelining``.

.. code-block:: c++

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

.. code-block:: c++

void foo() {
int var = 0;
[[intel::disable_loop_pipelining] for (int i = 0; i < 10; ++i) var++;
[[intel::disable_loop_pipelining]] for (int i = 0; i < 10; ++i) var++;
}

[[intel::disable_loop_pipelining] void foo1() { }
[[intel::disable_loop_pipelining]] void foo1() { }

}];
}
Expand Down
12 changes: 0 additions & 12 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6292,12 +6292,6 @@ SYCLIntelFPGAMaxConcurrencyAttr *Sema::MergeSYCLIntelFPGAMaxConcurrencyAttr(
}
return nullptr;
}
// FIXME
// max_concurrency and disable_component_pipelining attributes can't be
// applied to the same function. Upcoming patch needs to have this code
// added to it:
// if (checkAttrMutualExclusion<IntelDisableComponentPipeline>(S, D, AL))
// return;

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

Expr *E = A.getArgAsExpr(0);
S.AddSYCLIntelFPGAMaxConcurrencyAttr(D, A, E);
Expand Down
14 changes: 14 additions & 0 deletions clang/test/SemaSYCL/max-concurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ class Functor1 {

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

// Tests for Intel FPGA max_concurrency and disable_loop_pipelining function attributes compatibility.
// expected-error@+2 {{'max_concurrency' and 'disable_loop_pipelining' attributes are not compatible}}
// expected-note@+1 {{conflicting attribute is here}}
[[intel::disable_loop_pipelining]] [[intel::max_concurrency(2)]] void check();

// expected-error@+2 {{'disable_loop_pipelining' and 'max_concurrency' attributes are not compatible}}
// expected-note@+1 {{conflicting attribute is here}}
[[intel::max_concurrency(4)]] [[intel::disable_loop_pipelining]] void check1();

// expected-error@+3 {{'disable_loop_pipelining' and 'max_concurrency' attributes are not compatible}}
// expected-note@+1 {{conflicting attribute is here}}
[[intel::max_concurrency(4)]] void check2();
[[intel::disable_loop_pipelining]] void check2();

class Functor2 {
public:
void operator()() const {
Expand Down
5 changes: 5 additions & 0 deletions clang/utils/TableGen/ClangAttrEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3694,6 +3694,11 @@ static void GenerateMutualExclusionsChecks(const Record &Attr,
}
}

// If there are any decl or stmt attributes, silence -Woverloaded-virtual
// warnings for them both.
if (!DeclAttrs.empty() || !StmtAttrs.empty())
OS << " using ParsedAttrInfo::diagMutualExclusion;\n\n";

// If we discovered any decl or stmt attributes to test for, generate the
// predicates for them now.
if (!DeclAttrs.empty()) {
Expand Down