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

Annotate kernel params #289

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

chelini
Copy link
Collaborator

@chelini chelini commented Jan 28, 2025

No description provided.

@chelini chelini force-pushed the lchelini/annotate branch 2 times, most recently from 1057012 to 20604de Compare January 28, 2025 15:32
2. Block dimension
3. Block index.
Additionally, set all the following attributes for all the kernel pointers:
1. align 16
Copy link
Member

Choose a reason for hiding this comment

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

@chelini chelini force-pushed the lchelini/annotate branch 2 times, most recently from 3caf315 to 0dba906 Compare January 28, 2025 15:54
auto callee = symTable.lookup<FunctionOpInterface>(symbolName);
if (!callee)
return WalkResult::advance();
MLIRContext *ctx = callee->getContext();
Copy link
Member

Choose a reason for hiding this comment

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

Something I realize here. this (and the above) is wrong. A callee could have multiple callers. You need to conservatively min the dereferencable size over all callers (and same for the range above, though that's a max)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mind taking another look? thanks!

@chelini chelini force-pushed the lchelini/annotate branch 2 times, most recently from e0733ea to fb7f715 Compare February 2, 2025 16:56
if (matchPattern(maybeCst, m_ConstantInt(&intValue)))
target->setAttr("range", LLVM::ConstantRangeAttr::get(
ctx, 32, 0, intValue.getSExtValue()));
if (matchPattern(maybeCst, m_ConstantInt(&intValue))) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the best way to do things.

If, for example, there is already range metadata (that is weaker), we won't do the update.

I think the thing to do here is to

  1. get all kernelcall ops
  2. then get all called functions
  3. for each called function
    a) loop over all callers, getting the max over all ranges/etc
    b) set the derived values/aliasing/etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did not understand your previous comment then. What do you mean by "weaker range"? Can you provide an example?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah supposed that the existing kernel code before this pass has a range of 1-100000, but all the callers have a range 1-100. We would be taking the max over the previous setting and all the actual callers

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