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 optimization that automatically adds the restrict keyword to kernels #263

Merged
merged 7 commits into from
Mar 12, 2024

Conversation

NaderAlAwar
Copy link
Contributor

This adds a feature (enabled by setting the PK_RESTRICT environment variable) to automatically add restrict to views, which tells the compiler that the restricted views/arrays do not alias, enabling it optimize the code better. The alias analysis is done automatically by PyKokkos.

Ideally we would use the Kokkos::Restrict memory trait, however most compilers ignore restrict with pointers that are member variables (as it is with Kokkos Views). This PR solves this issue by generating a KOKKOS_FUNCTION that accepts the raw view pointers as arguments which we can then use restrict with.

@NaderAlAwar NaderAlAwar requested a review from gliga March 12, 2024 19:45
def add_parent_refs(classdef: ast.ClassDef) -> ast.ClassDef:
"""
Add references to each node's parent node in classdef (Copied from
static.py, can't be imported due to circular import)
Copy link
Contributor

Choose a reason for hiding this comment

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

could it be moved to a util file and then imported in both places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, would require some more refactoring. I'll get to this in a later PR

Copy link
Contributor

@gliga gliga left a comment

Choose a reason for hiding this comment

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

LG (I like the tests ;)

@NaderAlAwar NaderAlAwar merged commit 74ad693 into kokkos:main Mar 12, 2024
5 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