Skip to content

Commit ace7f7b

Browse files
committed
Expand attribute defintion and add upper limit for attribute parameter
1 parent 72fdbae commit ace7f7b

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,17 @@ Applies to a device function/lambda function. Indicates that the kernel should
22052205
be pipelined so as to achieve the specified target clock frequency (Fmax) of N
22062206
MHz. The argument N may be a template parameter. This attribute should be
22072207
ignored for the FPGA emulator device.
2208+
2209+
``[[intelfpga::scheduler_target_fmax_mhz(N)]]``
2210+
Valid values of N are integers in the range [0, 1048576]. The upper limit,
2211+
although too high to be a realistic value for frequency, is chosen to be future
2212+
proof. The FPGA backend emits a diagnostic message if the passed value is
2213+
unachievable by the device.
2214+
2215+
This attribute enables communication of the desired maximum frequency of the
2216+
device operation, guiding the FPGA backend to insert the appropriate number of
2217+
registers to break-up the combinational logic circuit, and therby controlling
2218+
the length of the longest combinational path.
22082219
}];
22092220
}
22102221

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,9 +3017,12 @@ static void handleSchedulerTargetFmaxMhzAttr(Sema &S, Decl *D,
30173017
/*StrictlyUnsigned=*/true))
30183018
return;
30193019

3020-
if (TargetFmaxMhz == 0) {
3021-
S.Diag(Attr.getLoc(), diag::err_attribute_argument_is_zero)
3022-
<< Attr << E->getSourceRange();
3020+
uint32_t UpperLimit = 1048576;
3021+
if (TargetFmaxMhz > UpperLimit) {
3022+
// Allow frequency to be a "large enough" positive value, zero included
3023+
// Let FPGA backend handle unachievable frequency value
3024+
S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_range)
3025+
<< Attr << E->getSourceRange() << 0 << UpperLimit;
30233026
return;
30243027
}
30253028

clang/test/SemaSYCL/scheduler_target_fmax_mhz.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int main() {
2525
[[intelfpga::scheduler_target_fmax_mhz(0)]] int Var = 0; // expected-error{{'scheduler_target_fmax_mhz' attribute only applies to functions}}
2626

2727
cl::sycl::kernel_single_task<class test_kernel3>(
28-
[]() [[intelfpga::scheduler_target_fmax_mhz(0)]]{}); // expected-error{{'scheduler_target_fmax_mhz' attribute must be greater than 0}}
28+
[]() [[intelfpga::scheduler_target_fmax_mhz(1048577)]]{}); // expected-error{{'scheduler_target_fmax_mhz' attribute requires integer constant between 0 and 1048576 inclusive}}
2929

3030
cl::sycl::kernel_single_task<class test_kernel4>(
3131
[]() [[intelfpga::scheduler_target_fmax_mhz(-4)]]{}); // expected-error{{'scheduler_target_fmax_mhz' attribute requires a non-negative integral compile time constant expression}}

0 commit comments

Comments
 (0)