❔ System.Numerics.Vector<double> limited to 2 components with NativeAOT instead of 4
Hi! Im using the mentioned Vector struct for double Vectors and have seen that using NativeAOT it only allows for 2 components instead of 4 (without NativeAOT). Why is that?
11 Replies
the size of
Vector<T>
needs to be known when the code is compiled, and Native AOT does not enable support for 256-bit vectors by default
many CPUs, even ones released as late as 2020, do not have support for 256-bit vectors. enabling 256-bit vectors would make your Native AOT program not work on those processorsOh ok, thanks for the explanation! Is there alternative?
for Native AOT, you either deal with it the way it is, or you make it so people with Atoms or Celerons cannot use your program
If I want something with "similar" performance I would just go for a
fixed double buffer[4] I guess?
what are you actually going to do with the values in the buffer
I'll have four of them to represent a 4x4 double Matrix. So I'll do calculations with the values and recreate some matrices few times a frame
if you were mostly doing individual accesses to the elements, you will get much better performance with a struct that has 16 double fields compared to Vector<double>
you do not want to use the indexer on Vector<T> very much
Yeah individual access is happening a lot
Would a 16 double field struct be better than
the fixed buffer approach will be slower
it introduces all manner of security checks wherever you use them
i guess if you need an indexer, the 16 fields are sort of unpleasant
I guess it would be fine to do it once, just so I understand it...why would it faster with 16 double fields?
Which security checks are there on the fixed buffer?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.