-
Notifications
You must be signed in to change notification settings - Fork 386
[MicroBenchmarks] Add initial early-exit vectorization microbenchmarks. #317
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
| #include "benchmark/benchmark.h" | ||
|
|
||
| static std::mt19937 rng; | ||
| uint64_t Sum = 0; |
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.
Why is Sum a global?
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 may just be a bit paranoid, to ensure the result of the loops are used
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.
benchmark::DoNotOptimize(Sum); does this already, no?
| __builtin_assume_dereferenceable(AlignedA, Iterations * sizeof(Ty)); | ||
| __builtin_assume_dereferenceable(AlignedB, Iterations * sizeof(Ty)); | ||
| __builtin_assume_dereferenceable(AlignedC, Iterations * sizeof(Ty)); |
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.
Are the __builtin_assume_aligned and __builtin_assume_dereferenceable necessary? User code almost never uses them, so this takes away from the representativeness of the test.
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.
Yes they are currently necessary for Clang to vectorize this, as the current implementation is limited to cases where we can prove all accesses in the loop are dereferenceable. This will likely be improved in the future, but for now I updated the code to at least check if they are available before using them
| // This program tests performance impact of Epilogue Vectorization | ||
| // with varying epilogue lengths, and vector widths. |
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.
Have you considered doxygen comments? However, it might not be applicable on test-suite since we do not run doxygen on it.
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.
Updated to use doxygen comment, as it is a bit more descriptive, thanks!
| BENCHMARK_TEMPLATE(BenchFunc, uint64_t) BENCHMARK_ARGS; | ||
|
|
||
| REGISTER_BENCHMARK_FOR_TYPES(autovec_no_early_exit_single_load) | ||
| REGISTER_BENCHMARK_FOR_TYPES(autovec_early_exit_taken_first_single_load) |
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.
Any reason why there's no autovec_early_exit_taken_mid_single_load or autovec_no_early_exit_taken_two_loads?
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 an oversight, registered autovec_no_early_exit_taken_two_loads and added def for autovec_early_exit_taken_mid_single_load
lukel97
left a comment
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.
LGTM
No description provided.