-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Apply hardware intrinsics to BitArray.*Shift
#113299
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
|
Hi @kzrnm, apologies for the delay in reviewing this. Is there a chance you could rebase your changes on top of the latest main? I don't have write permissions in your PR branch to do it myself. |
|
I updated to match the latest implementation. |
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.
Pull Request Overview
This PR optimizes the BitArray.LeftShift and BitArray.RightShift methods by leveraging hardware intrinsics (Vector512, Vector256, Vector128) to achieve significant performance improvements. The benchmark results show 3-6x speedup across different array sizes.
Key Changes:
- Replaced
int-based shifting withbyte-based operations using SIMD vectors - Introduced vectorized processing for bulk shift operations with fallback to scalar code
- Added comprehensive test coverage for various bit array sizes and shift amounts
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| BitArray.cs | Refactored RightShift and LeftShift to use byte-level operations with SIMD intrinsics (Vector512/256/128), replacing the previous int-based implementation |
| BitArray_OperatorsTests.cs | Enhanced test coverage with additional test cases covering various sizes (1023-1025) and shift amounts, plus validation of high-order bit clearing |
src/libraries/System.Private.CoreLib/src/System/Collections/BitArray.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Collections/BitArray.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Collections/BitArray.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Collections/BitArray.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Collections/tests/BitArray/BitArray_OperatorsTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Related #63722, #113005
benchmark
Benchmark code