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

Add syncthreads to scans prevent overwriting shared memory of previous chunk #97

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ivogabe
Copy link
Contributor

@ivogabe ivogabe commented Nov 19, 2023

Description

This PR fixes an issue that we had for a long time. Programs with scans would sometimes give incorrect values. As I found out, this is caused by missing synchronization in thread groups in the scan kernels.

Motivation and context

A thread group in a scan kernel may handle multiple chunks of the input.
A __syncthreads was missing between the end of one chunk and the start of the next, which caused that
shared memory could be overwritten in in the next iteration, before all threads are finished reading data from the previous iteration.
scanBlockShfl does perform synchronisation between its writes and reads, but there was no synchronisation between the reads of some iteration of the outer loop, and the writes in the next iteration.

How has this been tested?

Our quickhull implementation now works correctly on the GPU, whereas it previously would produce garbage values or crash (as it continues to compute with those garbage values). This was tested on an A100 and 4090.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

A __syncthreads was missing, which caused that
shared memory could be overwritten before all threads
are finished reading.
scanBlockShfl does perform synchronisation between its writes and reads,
but there was no synchronisation between the reads of some iteration
of the outer loop, and the writes in the next iteration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant