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 padding to reduce shared memory bank conflicts #193

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

harsh-nod
Copy link
Contributor

This PR adds padding to shared memory allocations
to minimize bank conflicts.

This PR adds padding to shared memory allocations
to minimize bank conflicts.

Signed-off-by: Harsh Menon <harsh@nod-labs.com>
would involve swizzling of the shared memory access patterns.
"""
padding = 64 // dtype.bitwidth()
return tuple(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if it's already aligned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this approach, we just apply a blanket padding value that is independent of whether the shape is aligned or not. We could also making this a tuning parameter to see which value gives the best performance for a given shape.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense!

"""
padding = 64 // dtype.bitwidth()
return tuple(
value + padding if i == len(shape) - 1 else value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do something like shape[-1] += padding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shape is a tuple so unfortunately not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see

Copy link
Contributor

@raikonenfnu raikonenfnu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great just couple minor NITs/Qs.

@harsh-nod harsh-nod merged commit da3436d into iree-org:main Oct 4, 2024
6 of 8 checks passed
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.

2 participants