Skip to content

Commit 4567468

Browse files
authored
FPGA: Add a note for race condition to the pipelined kernel sample (#2345)
Adding a note about race condition when using pipelined kernel invocation.
1 parent 2aaf3f2 commit 4567468

File tree

1 file changed

+4
-0
lines changed
  • DirectProgramming/C++SYCL_FPGA/Tutorials/Features/hls_flow_interfaces/invocation_interfaces

1 file changed

+4
-0
lines changed

DirectProgramming/C++SYCL_FPGA/Tutorials/Features/hls_flow_interfaces/invocation_interfaces/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ for (int i = 0; i < count; i++) {
190190
q.wait();
191191
```
192192

193+
> **Note**: As per the SYCL language semantics, separate invocations of a kernel are **independent**. This means that you can't make assumptions about memory ordering or memory dependences between kernel invocations. Make sure you use synchronization mechanisms such as the `.wait()` function or *atomic operations* to avoid race conditions. \
194+
If you want to guarantee sequential equivalence, you can also write your kernel with a `while(1)` loop in the kernel body instead of using a pipelined kernel. \
195+
In particular, a repeatedly-invoked kernel with memory dependence will result in undefined behavior in SYCL and may not function as you expect.
196+
193197
For an example of a pipelined streaming kernel, see `src/stream_pipelined.cpp`.
194198
195199
### Customizing the Kernel Argument Interface

0 commit comments

Comments
 (0)