Usage of "constants" Vector
#40989
-
Hi, When using a Vector class like For example:
Looking at the dotnet runtime: Since here: What are the differences ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
See #40900 --> For .NET 5 onwards just use
For the static readonly the JIT emits code that in the static construction of the type will create the vector, store it to memory and (later) can be read from there. If the vector elements are of size 1, as byte, sbyte, etc. and as in the Base64-code you linked, the vector is read from the assembly's static data segment directly. This works, as the C# compiler uses a trick for ReadOnlySpans iif element size is 1. See C# ReadOnlySpan and static data for further infos.
It's a (readonly) struct, striclty speaking 😉 |
Beta Was this translation helpful? Give feedback.
See #40900 --> For .NET 5 onwards just use
Vector256.Create(...)
with constant arguments.For the static readonly the JIT emits code that in the static construction of the type will create the vector, store it to memory and (later) can be read from there.
If the vector elements are of size 1, as byte, sbyte, etc. and as in the Base64-code you linked, the vector is read from the assembly's static data segment directly. This works, as the C# compiler uses a trick for ReadOnlySpans iif element size is 1. See C# ReadOnlySpan and static data for further infos.
It's a (readonly) struct, striclty speaking 😉