Skip to content

Usage of "constants" Vector #40989

Answered by gfoidl
ycrumeyrolle asked this question in General
Aug 18, 2020 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

See #40900 --> For .NET 5 onwards just use Vector256.Create(...) with constant arguments.

What are the differences ?

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.


Vector class like Vector256<byte>

It's a (readonly) struct, striclty speaking 😉

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ycrumeyrolle
Comment options

@gfoidl
Comment options

Answer selected by ycrumeyrolle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants