Skip to content

[SYCL] Add support for new spelling of FPGA kernel attribute scheduler_target_fmax_mhz #2618

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 3 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,8 @@ def SYCLIntelNumSimdWorkItems : InheritableAttr {
}

def SYCLIntelSchedulerTargetFmaxMhz : InheritableAttr {
let Spellings = [CXX11<"intelfpga","scheduler_target_fmax_mhz">];
let Spellings = [CXX11<"intelfpga","scheduler_target_fmax_mhz">,
CXX11<"intel","scheduler_target_fmax_mhz">];
let Args = [ExprArgument<"Value">];
let LangOpts = [SYCLIsDevice, SYCLIsHost];
let Subjects = SubjectList<[Function], ErrorDiag>;
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -2225,14 +2225,14 @@ device kernel, the attribute is ignored and it is not propagated to a kernel.

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

``[[intelfpga::scheduler_target_fmax_mhz(N)]]``
``[[intel::scheduler_target_fmax_mhz(N)]]``
Valid values of N are integers in the range [0, 1048576]. The upper limit,
although too high to be a realistic value for frequency, is chosen to be future
proof. The FPGA backend emits a diagnostic message if the passed value is
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3053,6 +3053,10 @@ static void handleSchedulerTargetFmaxMhzAttr(Sema &S, Decl *D,
if (D->getAttr<SYCLIntelSchedulerTargetFmaxMhzAttr>())
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;

if (checkDeprecatedSYCLAttributeSpelling(S, AL))
S.Diag(AL.getLoc(), diag::note_spelling_suggestion)
<< "'intel::scheduler_target_fmax_mhz'";

S.addSYCLIntelSchedulerTargetFmaxMhzAttr(D, AL, E);
}

Expand Down
6 changes: 3 additions & 3 deletions clang/test/CodeGenSYCL/scheduler-target-fmax-mhz.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// RUN: %clang_cc1 -fsycl -fsycl-is-device -disable-llvm-passes -triple spir64-unknown-unknown-sycldevice -emit-llvm -o - %s | FileCheck %s

#include "Inputs/sycl.hpp"
[[intelfpga::scheduler_target_fmax_mhz(5)]] void
[[intel::scheduler_target_fmax_mhz(5)]] void
func() {}

template <int N>
[[intelfpga::scheduler_target_fmax_mhz(N)]] void zoo() {}
[[intel::scheduler_target_fmax_mhz(N)]] void zoo() {}

int main() {
cl::sycl::kernel_single_task<class test_kernel1>(
[]() [[intelfpga::scheduler_target_fmax_mhz(2)]]{});
[]() [[intel::scheduler_target_fmax_mhz(2)]]{});

cl::sycl::kernel_single_task<class test_kernel2>(
[]() { func(); });
Expand Down
14 changes: 9 additions & 5 deletions clang/test/SemaSYCL/scheduler_target_fmax_mhz.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// RUN: %clang_cc1 %s -fsyntax-only -ast-dump -fsycl -fsycl-is-device -triple spir64 -Wno-sycl-2017-compat -verify | FileCheck %s

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

template <int N>
[[intelfpga::scheduler_target_fmax_mhz(N)]] void zoo() {}
[[intel::scheduler_target_fmax_mhz(N)]] void zoo() {}

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

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

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

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

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

cl::sycl::kernel_single_task<class test_kernel6>(
[]() [[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}}
[]() [[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}}
}