Skip to content

Commit b1cf776

Browse files
authored
[SYCL] Add support for new spelling of FPGA kernel attribute scheduler_target_fmax_mhz (#2618)
Clang support for FPGA kernel attribute [[intelfpga::scheduler_target_fmax_mhz()]] was added on commit 20013e2. commit 5949228 updated all FPGA attribute spellings that currently used intelfpga:: prefixes to intel:: in all lowercase to avoid mismatch between our namespace in SYCL (which use intel::) and the prefixes we used for FPGA attributes in LLVM. This patches 1. Enable attribute spelling with intel:: prefix, without disabling the previous one. 2. Provide a deprecation warning for the previous attribute spelling. 3. Modify the tests and documentation. Signed-off-by: Soumi Manna <[email protected]>
1 parent ca8b94e commit b1cf776

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,8 @@ def SYCLIntelNumSimdWorkItems : InheritableAttr {
12271227
}
12281228

12291229
def SYCLIntelSchedulerTargetFmaxMhz : InheritableAttr {
1230-
let Spellings = [CXX11<"intelfpga","scheduler_target_fmax_mhz">];
1230+
let Spellings = [CXX11<"intelfpga","scheduler_target_fmax_mhz">,
1231+
CXX11<"intel","scheduler_target_fmax_mhz">];
12311232
let Args = [ExprArgument<"Value">];
12321233
let LangOpts = [SYCLIsDevice, SYCLIsHost];
12331234
let Subjects = SubjectList<[Function], ErrorDiag>;

clang/include/clang/Basic/AttrDocs.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2225,14 +2225,14 @@ device kernel, the attribute is ignored and it is not propagated to a kernel.
22252225

22262226
def SYCLIntelSchedulerTargetFmaxMhzAttrDocs : Documentation {
22272227
let Category = DocCatFunction;
2228-
let Heading = "scheduler_target_fmax_mhz (IntelFPGA)";
2228+
let Heading = "intel::scheduler_target_fmax_mhz";
22292229
let Content = [{
22302230
Applies to a device function/lambda function. Indicates that the kernel should
22312231
be pipelined so as to achieve the specified target clock frequency (Fmax) of N
22322232
MHz. The argument N may be a template parameter. This attribute should be
22332233
ignored for the FPGA emulator device.
22342234

2235-
``[[intelfpga::scheduler_target_fmax_mhz(N)]]``
2235+
``[[intel::scheduler_target_fmax_mhz(N)]]``
22362236
Valid values of N are integers in the range [0, 1048576]. The upper limit,
22372237
although too high to be a realistic value for frequency, is chosen to be future
22382238
proof. The FPGA backend emits a diagnostic message if the passed value is

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,6 +3058,10 @@ static void handleSchedulerTargetFmaxMhzAttr(Sema &S, Decl *D,
30583058
if (D->getAttr<SYCLIntelSchedulerTargetFmaxMhzAttr>())
30593059
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
30603060

3061+
if (checkDeprecatedSYCLAttributeSpelling(S, AL))
3062+
S.Diag(AL.getLoc(), diag::note_spelling_suggestion)
3063+
<< "'intel::scheduler_target_fmax_mhz'";
3064+
30613065
S.addSYCLIntelSchedulerTargetFmaxMhzAttr(D, AL, E);
30623066
}
30633067

clang/test/CodeGenSYCL/scheduler-target-fmax-mhz.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// RUN: %clang_cc1 -fsycl -fsycl-is-device -disable-llvm-passes -triple spir64-unknown-unknown-sycldevice -emit-llvm -o - %s | FileCheck %s
22

33
#include "Inputs/sycl.hpp"
4-
[[intelfpga::scheduler_target_fmax_mhz(5)]] void
4+
[[intel::scheduler_target_fmax_mhz(5)]] void
55
func() {}
66

77
template <int N>
8-
[[intelfpga::scheduler_target_fmax_mhz(N)]] void zoo() {}
8+
[[intel::scheduler_target_fmax_mhz(N)]] void zoo() {}
99

1010
int main() {
1111
cl::sycl::kernel_single_task<class test_kernel1>(
12-
[]() [[intelfpga::scheduler_target_fmax_mhz(2)]]{});
12+
[]() [[intel::scheduler_target_fmax_mhz(2)]]{});
1313

1414
cl::sycl::kernel_single_task<class test_kernel2>(
1515
[]() { func(); });

clang/test/SemaSYCL/scheduler_target_fmax_mhz.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
// RUN: %clang_cc1 %s -fsyntax-only -ast-dump -fsycl -fsycl-is-device -triple spir64 -Wno-sycl-2017-compat -verify | FileCheck %s
22

33
#include "Inputs/sycl.hpp"
4+
// expected-warning@+2 {{attribute 'intelfpga::scheduler_target_fmax_mhz' is deprecated}}
5+
// expected-note@+1 {{did you mean to use 'intel::scheduler_target_fmax_mhz' instead?}}
46
[[intelfpga::scheduler_target_fmax_mhz(2)]] void
57
func() {}
68

79
template <int N>
8-
[[intelfpga::scheduler_target_fmax_mhz(N)]] void zoo() {}
10+
[[intel::scheduler_target_fmax_mhz(N)]] void zoo() {}
911

1012
int main() {
1113
// CHECK-LABEL: FunctionDecl {{.*}}test_kernel1 'void ()'
1214
// CHECK: SYCLIntelSchedulerTargetFmaxMhzAttr {{.*}}
1315
// CHECK-NEXT: ConstantExpr {{.*}} 'int'
1416
// CHECK-NEXT: value: Int 5
1517
// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 5
18+
// expected-warning@+3 {{attribute 'intelfpga::scheduler_target_fmax_mhz' is deprecated}}
19+
// expected-note@+2 {{did you mean to use 'intel::scheduler_target_fmax_mhz' instead?}}
1620
cl::sycl::kernel_single_task<class test_kernel1>(
1721
[]() [[intelfpga::scheduler_target_fmax_mhz(5)]]{});
1822

@@ -32,14 +36,14 @@ int main() {
3236
cl::sycl::kernel_single_task<class test_kernel3>(
3337
[]() { zoo<75>(); });
3438

35-
[[intelfpga::scheduler_target_fmax_mhz(0)]] int Var = 0; // expected-error{{'scheduler_target_fmax_mhz' attribute only applies to functions}}
39+
[[intel::scheduler_target_fmax_mhz(0)]] int Var = 0; // expected-error{{'scheduler_target_fmax_mhz' attribute only applies to functions}}
3640

3741
cl::sycl::kernel_single_task<class test_kernel4>(
38-
[]() [[intelfpga::scheduler_target_fmax_mhz(1048577)]]{}); // expected-error{{'scheduler_target_fmax_mhz' attribute requires integer constant between 0 and 1048576 inclusive}}
42+
[]() [[intel::scheduler_target_fmax_mhz(1048577)]]{}); // expected-error{{'scheduler_target_fmax_mhz' attribute requires integer constant between 0 and 1048576 inclusive}}
3943

4044
cl::sycl::kernel_single_task<class test_kernel5>(
41-
[]() [[intelfpga::scheduler_target_fmax_mhz(-4)]]{}); // expected-error{{'scheduler_target_fmax_mhz' attribute requires integer constant between 0 and 1048576 inclusive}}
45+
[]() [[intel::scheduler_target_fmax_mhz(-4)]]{}); // expected-error{{'scheduler_target_fmax_mhz' attribute requires integer constant between 0 and 1048576 inclusive}}
4246

4347
cl::sycl::kernel_single_task<class test_kernel6>(
44-
[]() [[intelfpga::scheduler_target_fmax_mhz(1), intelfpga::scheduler_target_fmax_mhz(2)]]{}); // expected-warning{{attribute 'scheduler_target_fmax_mhz' is already applied with different parameters}}
48+
[]() [[intel::scheduler_target_fmax_mhz(1), intel::scheduler_target_fmax_mhz(2)]]{}); // expected-warning{{attribute 'scheduler_target_fmax_mhz' is already applied with different parameters}}
4549
}

0 commit comments

Comments
 (0)