Open
Conversation
LoopedBard3
approved these changes
Mar 17, 2026
Member
LoopedBard3
left a comment
There was a problem hiding this comment.
Looks good, thanks for the benchmarks!
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new SVE-focused microbenchmark for a 2D Sobel filter convolution, enabling comparison of scalar vs AdvSimd (Vector128) vs SVE implementations on Arm64/SVE-capable systems.
Changes:
- Introduces
SobelFiltermicrobenchmark withScalar,Vector128SobelFilter, andSveSobelFilterbenchmarks. - Adds setup/verification scaffolding and Sobel kernel initialization for repeatable runs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+196
to
+200
| Vector<float> resVec; | ||
| // Load coefficients of the filter into vectors. | ||
| Vector<float> kxVec = Sve.LoadVector((Vector<float>)Sve.CreateWhileLessThanMask32Bit(0, 3), kx); | ||
| Vector<float> kyVec = Sve.LoadVector((Vector<float>)Sve.CreateWhileLessThanMask32Bit(0, 3), ky); | ||
| for (int j = 0; j < img_size; j++) |
Comment on lines
+206
to
+213
| for (int i = 0; i < out_size; i += cntw) | ||
| { | ||
| Vector<float> pRow = (Vector<float>)Sve.CreateWhileLessThanMask32Bit(i, out_size); | ||
|
|
||
| // Load input elements from the next 3 columns. | ||
| Vector<float> col0 = Sve.LoadVector(pRow, in_ptr + i); | ||
| Vector<float> col1 = Sve.LoadVector(pRow, in_ptr + i + 1); | ||
| Vector<float> col2 = Sve.LoadVector(pRow, in_ptr + i + 2); |
Comment on lines
+229
to
+236
| for (int i = 0; i < out_size; i += cntw) | ||
| { | ||
| Vector<float> pRow = (Vector<float>)Sve.CreateWhileLessThanMask32Bit(i, out_size); | ||
|
|
||
| // Load input elements from the next 3 rows. | ||
| Vector<float> row0 = Sve.LoadVector(pRow, in_ptr + i); | ||
| Vector<float> row1 = Sve.LoadVector(pRow, in_ptr + i + out_size); | ||
| Vector<float> row2 = Sve.LoadVector(pRow, in_ptr + i + 2 * out_size); |
Comment on lines
+69
to
+100
| int img_size = Size; | ||
| // The output image size is 2-pixel smaller in each direction. | ||
| int out_size = img_size - 2; | ||
| fixed (float* input = _source, temp = _temp, output = _result) | ||
| fixed (float* kx = _kx, ky = _ky) | ||
| { | ||
| // Convolve the horizontal component first. | ||
| // The result is save to the temp array. | ||
| for (int j = 0; j < img_size; j++) | ||
| { | ||
| for (int i = 0; i < out_size; i++) | ||
| { | ||
| float res = 0.0F; | ||
| for (int k = 0; k < 3; k++) | ||
| { | ||
| res += kx[k] * input[j * img_size + i + k]; | ||
| } | ||
| temp[j * out_size + i] = res; | ||
| } | ||
| } | ||
| // Then convolve the vertical component. | ||
| // Using the temp array as input. | ||
| for (int j = 0; j < out_size; j++) | ||
| { | ||
| for (int i = 0; i < out_size; i++) | ||
| { | ||
| float res = 0.0F; | ||
| for (int k = 0; k < 3; k++) | ||
| { | ||
| res += ky[k] * temp[(j + k) * out_size + i]; | ||
| } | ||
| output[j * out_size + i] = res; |
| fixed (float* kx = _kx, ky = _ky) | ||
| { | ||
| // Convolve the horizontal component first. | ||
| // The result is save to the temp array. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Performance Results
Run on Neoverse-V2
cc @dotnet/arm64-contrib @SwapnilGaikwad @LoopedBard3