Skip to content

What is min of System.Numerics.Vector<T>.Count on any supported os+hw combination for net core? #50161

Answered by gfoidl
BreyerW asked this question in Q&A
Discussion options

You must be logged in to vote

128 bits is the min vector register size.
A float consists of 4 bytes, so 32 bits, hence Vector<float> has 128 / 32 = 4 elements.

For the (current) max the vector register size is 256 bits, so Vector<float> has 256 / 32 = 8 elements.

Note: Vector<T> does not have a "fixed" size, as it depends on the max. available register size on the executing hardware.
In contrast Vector128 and Vector256 are fix in the size of 128 bit and 256 bit respectively. So for

at least 6 floats in single Vec

you'd need at least 256 bits, that's AVX and you can guard your algorithm with

if (Avx.IsSupported)
{
    // vectorized code path that operates on 8 floats at once
}
else
{
    // software fallback for scal…

Replies: 4 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

@gfoidl
Comment options

Answer selected by BreyerW
Comment options

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

@tannergooding
Comment options

Comment options

You must be logged in to vote
3 replies
@gfoidl
Comment options

@BreyerW
Comment options

@tannergooding
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants