-
-
Notifications
You must be signed in to change notification settings - Fork 957
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
Add common type conversions #2238
base: master
Are you sure you want to change the base?
Conversation
I think if you pass by ref (use |
I did some quick tests with Inlining and the performance was the same or similar on a few runs. It seems like the compiler does not make any significant changes with or witthout it to the compiled code, I tested with the Bepu library mentioned above. Unless Im missing something I cant seem to use |
As you can see, the jit tends to inline such a small function regardless of the attribute. |
Ah nice, BitCast looks awesome. I was imagining it like this, which it looks like BitCast creates the same code in a cleaner way. public static Vector2 ToStride(this in NVector2 v) => Unsafe.As<NVector2, Vector2>(ref Unsafe.AsRef(v)); The
The assembly for C.Bitcast(System.Numerics.Vector2)
L0000: vzeroupper
L0003: vmovq xmm0, rcx
L0008: vmovq rax, xmm0
L000d: ret
C.BitcastIn(System.Numerics.Vector2 ByRef)
L0000: mov rax, [rcx]
L0003: ret |
PR Details
This PR adds some useful extensions that are commonly used with external libraries since Numerics has become the standard.
Related Issue
#2131 this is a great example where something like this could be used.
Motivation and Context
the Bepu branch has this built into the library but its also used in the model importer as well as any library that may need these fast conversions.
Types of changes
Checklist