-
Notifications
You must be signed in to change notification settings - Fork 350
[UnitTests] Add initial set of dedicated early-exit unit tests. #264
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
base: main
Are you sure you want to change the base?
Conversation
Adds initial unit tests for early-exit vectorization covering a variation of auto-vectorization and forced interleaving with pragmas. The interleaving variant is currently mis-compiled and needs * llvm/llvm-project#145340 * llvm/llvm-project#145394. We should probably extend the tests to make sure we cover various other scenarios, including returning the loaded element for the early exit, different index types and array sizes.
b349e09
to
28ae6ea
Compare
@@ -1,3 +1,12 @@ | |||
|
|||
# Enable matrix types extension tests for compilers supporting -fenable-matrix. |
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.
I think the comment doesn't match the code below?
}; \ | ||
auto InterleavedFn = [](std::function<void(int *)> II) -> unsigned { \ | ||
Init II(Src); \ | ||
_Pragma("clang loop vectorize(enable) interleave_count(4)") Loop \ |
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.
Looks like this PR cannot be merged until the pragma has handled correctly.
/// * one where VF is picked automatically and interleaving is forced. | ||
#define DEFINE_SCALAR_AND_VECTOR_EARLY_EXIT(Init, Src, Loop) \ | ||
auto ScalarFn = [](std::function<void(int *)> II) -> unsigned { \ | ||
Init II(Src); \ |
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.
This is pretty confusing as it looks like constructing a variable. Can you split this out over different lines so it's clearer, i.e.
InitSrc;
II(Src);
// for to zero. | ||
auto Init1 = [IdxToFind](int *Arr) { | ||
std::fill_n(Arr, N, 1); | ||
if (IdxToFind < N) |
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.
Is there a risk that a future compiler optimisation basically figures out the answer based on this init code (after inlining) and just optimises ScalarFn
to return a constant before we even reach the loop vectoriser? It might be better to have Init1 and Init2 as real functions marked as noinline
.
Adds initial unit tests for early-exit vectorization covering a variation of auto-vectorization and forced interleaving with pragmas.
The interleaving variant is currently mis-compiled and needs
We should probably extend the tests to make sure we cover various other scenarios, including returning the loaded element for the early exit, different index types and array sizes.