Skip to content
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

MiniEngine blur shader has a data race #870

Open
jenatali opened this issue May 29, 2024 · 0 comments
Open

MiniEngine blur shader has a data race #870

jenatali opened this issue May 29, 2024 · 0 comments
Labels
miniengine Issues related to MiniEngine

Comments

@jenatali
Copy link
Member

The blur shader has a data race. This race is specifically problematic on WARP, but can reproduce on any GPU with small wave sizes. The access pattern for the groupshared memory is:

  • Store 2xf16 in every slot of the arrays.
  • Sync
  • Read 2xf16
  • Compute horizontal blur
  • Store 1xf32 in every slot of the arrays
  • Sync
  • Read 1xf32

This pattern correctly inserts barriers to prevent hazards from write -> read (readers must wait until writes complete), but is missing barriers to prevent hazards from read -> write (writers must wait until all readers complete before overwriting data).

Since WARP executes 4-channel waves sequentially, it will deterministically hit a problematic case where some readers try to load 2xf16 data, but instead they read 1xf32 data. Trying to unpack this f32 as f16s produces nans and other garbage. Theoretically any GPU with a wave size smaller than 64 (since the blur uses 8x8 thread groups) can hit this.

@microsoft microsoft deleted a comment from GameDreamByHuo May 29, 2024
@walbourn walbourn added the miniengine Issues related to MiniEngine label Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
miniengine Issues related to MiniEngine
Projects
None yet
Development

No branches or pull requests

2 participants