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

[Puzzle 12, Test2] Question regarding shared memory #20

Open
VeritasYin opened this issue Aug 18, 2022 · 0 comments
Open

[Puzzle 12, Test2] Question regarding shared memory #20

VeritasYin opened this issue Aug 18, 2022 · 0 comments

Comments

@VeritasYin
Copy link

Hi,

For this puzzle, it seems that shared cuda arrays are lazily initialized. Since SIZE is 15 and TPB is 8, the last element of Block 1 is not overwritten, but the value got carried over from Block 0, even after calling cuda.syncthreads(). So is this a normal behavior or actually a leak?

My original implentation assumed that the shared array would all be intialized as 0, so it was safe to perform the sum over the entire block. Given the above findings, there are two options for those unaligned block: 1) fill the rest as 0 or 2) check the index bounds for sum ops ((i+step) < size). While both pass the test case, the latter gives a weird dependency graph for Block 1 as attached, which raises my concern.

Screen Shot 2022-08-18 at 12 55 17 AM

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

No branches or pull requests

1 participant