-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Split optimisation passes. #6335
Merged
stuartarchibald
merged 4 commits into
numba:master
from
stuartarchibald:wip/enable_more_vectorization_1
Oct 13, 2020
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import numpy as np | ||
from numba import njit, types | ||
from unittest import TestCase | ||
from numba.tests.support import override_env_config | ||
|
||
_DEBUG = False | ||
if _DEBUG: | ||
from llvmlite import binding as llvm | ||
# Prints debug info from the LLVMs vectorizer | ||
llvm.set_option("", "--debug-only=loop-vectorize") | ||
|
||
|
||
class TestVectorization(TestCase): | ||
""" | ||
Tests to assert that code which should vectorize does indeed vectorize | ||
""" | ||
def gen_ir(self, func, args_tuple, **flags): | ||
with override_env_config( | ||
"NUMBA_CPU_NAME", "skylake-avx512" | ||
), override_env_config("NUMBA_CPU_FEATURES", ""): | ||
jobj = njit(**flags)(func) | ||
jobj.compile(args_tuple) | ||
ol = jobj.overloads[jobj.signatures[0]] | ||
return ol.library.get_llvm_str() | ||
|
||
def test_nditer_loop(self): | ||
# see https://github.com/numba/numba/issues/5033 | ||
def do_sum(x): | ||
acc = 0 | ||
for v in np.nditer(x): | ||
acc += v.item() | ||
return acc | ||
|
||
llvm_ir = self.gen_ir(do_sum, (types.float64[::1],), fastmath=True) | ||
self.assertIn("vector.body", llvm_ir) | ||
self.assertIn("llvm.loop.isvectorized", llvm_ir) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious... why O2 and not O1?
Also, do we need to override the inlining_threshold? e.g. cheap and full run has different threshold.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was think that producing more optimised code might let the refpruner run quicker and also permit more inlining if the complexity is reduce. Turns out in some checks @esc did that
O2
massively increases compile time, whereasO1
increases it a small bit, but both cases leading to huge performance gains, so I thinkO1
is probably the way to go for now. RE inline threshold, I've been thinking lately that it'd be a good idea to put more of these "trade-off" options into the hands of users, some will want to optimise something as much as possible regardless of the compilation cost, others will want to optimise for short compilation times, others may be inbetween!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4cf27a9 moves to
O1