Skip to content

OpenCL race condition with TailStrategy::ShiftInwards? #5430

Answered by abadams
Bastacyclop asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, Halide can generate race conditions of this specific type: Two threads race to store the same value to the same memory location, and then there's a full memory barrier before any thread tries to read that location.

It's the most benign possible race condition I can think of, but it's still technically UB in many contexts. If it's a problem I would say just use GuardWithIf instead. We have seen it cause non-determinism in the past when the tail case gets compiled as a separate piece of code, floating point optimizations shake out differently, and then the race is between different values, both presumably "correct" ones according to -ffast-math wild west rules.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alexreinking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5430 on November 24, 2020 00:40.