Skip to content

Commit 8fd3b0a

Browse files
authored
FPGA: Worked around runtime bug with event dependences between invocations of the same kernel (#2361)
This change implements a workaround for a bug affecting FPGA targets. The bug and workaround will be documented in the upcoming 2024.2 release notes. This workaround can be removed when the underlying bug is fixed (presumably in 2025.0). Specifically, when kernels are explicitly made dependent on other invocations of the same kernel through events, the FPGA runtime can occasionally hang. The hang is rare, but since the gzip_ll code sample attempts to enqueue kernels in this way hundreds of times it has a good chance of hitting it on any given run. Unfortunately, this code sample seems to be affected by a second, unrelated hang though because while this fix allows the program to complete some of the time, it still hangs periodically. Runtime traces of those remaining hangs indicate that they are a different issue. I still think it's worth submitting this as it reduces the frequency with which the design hangs.
1 parent 5f891ad commit 8fd3b0a

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/gzip/src/gzipkernel_ll.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -783,9 +783,13 @@ template <int engineID, int BatchSize>
783783
event SubmitCRC(queue &q, size_t block_size, uint32_t *result_crc,
784784
std::vector<event> &depend_on) {
785785
event e = q.submit([&](handler &h) {
786-
if (!depend_on.empty()) {
787-
h.depends_on(depend_on[kCRCIndex]);
788-
}
786+
// Temporarily remove event dependences to work around a bug in 2024.2
787+
// This is safe on FPGA because invocations of the same kernel are
788+
// serialized for non-pipelined kernels
789+
// Note: this is not portable
790+
//if (!depend_on.empty()) {
791+
// h.depends_on(depend_on[kCRCIndex]);
792+
//}
789793

790794
h.single_task<CRC<engineID>>([=]() [[intel::kernel_args_restrict]] {
791795
auto accessor_isz = block_size;
@@ -2073,9 +2077,13 @@ event SubmitLZReduction(queue &q, size_t block_size, bool last_block,
20732077
event e = q.submit([&](handler &h) {
20742078
auto accessor_isz = block_size;
20752079

2076-
if (!depend_on.empty()) {
2077-
h.depends_on(depend_on[kLZReductionIndex]);
2078-
}
2080+
// Temporarily remove event dependences to work around a bug in 2024.2
2081+
// This is safe on FPGA because invocations of the same kernel are
2082+
// serialized for non-pipelined kernels
2083+
// Note: this is not portable
2084+
//if (!depend_on.empty()) {
2085+
// h.depends_on(depend_on[kLZReductionIndex]);
2086+
//}
20792087

20802088
h.single_task<LZReduction<engineID>>([=]() [[intel::kernel_args_restrict]] {
20812089
// Unpack the ptrs parameter pack and grab all of the pointers, annotating
@@ -2445,9 +2453,13 @@ event SubmitStaticHuffman(queue &q, size_t block_size,
24452453
std::vector<event> &depend_on,
24462454
PtrTypes... ptrs) {
24472455
event e = q.submit([&](handler &h) {
2448-
if (!depend_on.empty()) {
2449-
h.depends_on(depend_on[kStaticHuffmanIndex]);
2450-
}
2456+
// Temporarily remove event dependences to work around a bug in 2024.2
2457+
// This is safe on FPGA because invocations of the same kernel are
2458+
// serialized for non-pipelined kernels
2459+
// Note: this is not portable
2460+
//if (!depend_on.empty()) {
2461+
// h.depends_on(depend_on[kStaticHuffmanIndex]);
2462+
//}
24512463

24522464
h.single_task<StaticHuffman<engineID>>([=]() [[intel::kernel_args_restrict]] {
24532465

0 commit comments

Comments
 (0)