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.
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
Begin using the xplat hardware intrinsics in BitArray #63722
Begin using the xplat hardware intrinsics in BitArray #63722
Changes from all commits
ab45576
9b6ea8d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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've preserved the
Vector256
path given that it was already here and I would presume has undergone the necessary checks to ensure it is worth doing on x86/x64.Arm64 doesn't support
V256
and so will only go down theV128
codepath.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.
We now expose helper intrinsics that directly operate on
ref
:LoadUnsafe(ref T source, nuint elementOffset)
.This helps avoid pinning, which can have measurable overhead for small counts and which can hinder the GC in the case of long inputs.
It likewise helps improve readability over the pattern we are already utilizing in parts of the BCL where we were using
Unsafe.ReadUnaligned
+Unsafe.Add
+Unsafe.As
.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.
ExtractMostSignificantBits
behaves just likeMoveMask
on x86/x64. This is also exposed byWASM
asbitmask
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.
In what situation would we also want a Vector64 code path?
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.
Vector64
can be beneficial for cases where you know the inputs are going to be commonly small and for handling the "trailing" elements (rather than falling back to a scalar loop or manually unrolled loop).We aren't currently taking advantage of this anywhere and it would need some more work/profiling to show the extra complexity is worthwhile.
Vector64<T>
but rather from changing out the "fallback" fromfor (; index < length; index++)
to usingVector64<T>
orVector128<T>
with appropriate backtracking and maskingThere 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.
The xplat helper intrinsics support operators and so we can make this "more readable" by just using
x & y
.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.
Storing an intrinsic likewise no longer requires pinning or complex
Unsafe
logic.