Skip to content

Get overload to consider compiler flags in cache lookup - #6888

Merged
sklam merged 5 commits into
numba:masterfrom
sklam:enh/flag_as_key
May 24, 2021
Merged

sklam merged 5 commits into
numba:masterfrom
sklam:enh/flag_as_key

Conversation

@sklam

@sklam sklam commented Apr 1, 2021

Copy link
Copy Markdown
Member

as titled

@sklam

sklam commented Apr 2, 2021

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Contributor
Azure Pipelines successfully started running 1 pipeline(s).

@stuartarchibald stuartarchibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the patch, I think this fixes the issue with ensuring that overloads are selected based on flags.

Comment thread numba/core/utils.py
if self:
flags = self.top()
else:
# Note: should this be the default flag for the target instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think perhaps it should be the default so it is always known precisely which flags are in use for a given function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm getting into a rabbit hole trying to put a default flag there. Currently, the TargetOptions is not really part of any contexts. It's floating in the TargetDescriptor. I can put the options into the target-context but it doesn't make sense for it to appear in the typing-context. However, I need it during typing. This goes back to the purity problem of needing flags (which I don't think is part of types) during the typing phase.

The only doable hack I can think of is putting the info into the ConfigStack to read the default flag later.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hm.... the other way is to let flags be part of the typing context.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I sampled the testsuite and found that this branch is only reached from test that bypass the user-facing compiler API---e.g. tests that invokes part of the compiler to test for specific internal behavior. The failure to use a default flag will only result in redundant compilation. I don't think we should spend too much time on this problem for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From OOB conversation, agree on leaving it for now as this fixes the immediate issue.

@stuartarchibald stuartarchibald added this to the Numba 0.54 RC milestone Apr 6, 2021
@sklam

sklam commented Apr 8, 2021

Copy link
Copy Markdown
Member Author

#6898 may provide new facility that this PR can depend on. Also, not sure if this smaller PR will conflict with the work in the larger #6898.

@sklam
sklam marked this pull request as ready for review May 24, 2021 15:09
@sklam
sklam requested a review from esc as a code owner May 24, 2021 15:09

@stuartarchibald stuartarchibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the patch. There's a typo to resolve, else I think this should be merged as it'll permit multiple lines of work in figuring out what needs fixing else where!

@sklam IIRC you ran the test suite to check this and None for flags in the cache key was quite rare and seemed like a harmless recompile?

Comment thread numba/core/utils.py Outdated
@stuartarchibald stuartarchibald added 4 - Waiting on author Waiting for author to respond to review Effort - short Short size effort needed and removed 3 - Ready for Review labels May 24, 2021
Co-authored-by: stuartarchibald <stuartarchibald@users.noreply.github.com>
@sklam

sklam commented May 24, 2021

Copy link
Copy Markdown
Member Author

@sklam IIRC you ran the test suite to check this and None for flags in the cache key was quite rare and seemed like a harmless recompile?

Correct. It only happens from our testsuite using compile_isolated()

@sklam sklam added 4 - Waiting on reviewer Waiting for reviewer to respond to author and removed 4 - Waiting on author Waiting for author to respond to review labels May 24, 2021

@stuartarchibald stuartarchibald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the patch and fixes!

@stuartarchibald stuartarchibald added 5 - Ready to merge Review and testing done, is ready to merge and removed 4 - Waiting on reviewer Waiting for reviewer to respond to author labels May 24, 2021
@sklam
sklam merged commit 6067c24 into numba:master May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Review and testing done, is ready to merge Effort - short Short size effort needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants