Hi Everyone,
In short, I was hoping someone could explain, or point me towards the documentation, for correctly using SIMD instructions in our code. What to configure in Build.cs/Target.cs etc., what to #ifdef guard code with that uses SIMD instructions etc.
As far as I have been able to test, for all our target platforms SIMD instructions seem to be available and usable by default without changing anything.
Based on what I read in the docs that I could fine, I thought that you would need to add “MinCpuArchX64 = MinimumCpuArchitectureX64.AVX2” to the Target.cs file, but even without that SIMD instructions compile correctly, properly emit SIMD instructions, and function as expected. I’m guessing that the version of the MSVC compiler we are using impicitly supports these or something…
One thing that adding “MinCpuArchX64 = MinimumCpuArchitectureX64.AVX2” to the Target.cs file does do, is that preprocessor directives such as __AVX__ and __AVX2__ get defined somewhere. And according to the UE docs, it means that running the game will not launch on a PC that doesn’t support at least AVX2, making this an explicit requirement (not sure where this would appear, but I guess it would be something we would have to declare when publishing for example).
Strangely the default value for MinCpuArchX64 appears to be MinimumCpuArchitectureX64.Default, which is defined as “None” in our version of UE (5.6 ish), so I would assume that if we just used SIMD instructions without setting MinCpuArchX64, the application would appear to support CPU’s that don’t support these instructions, but would inexplicably crash when you attempt to launch the game… And I would have thought that using SIMD instructions would either lead to a compiler error, runtime crashes, or maybe just the compiler emitting non SIMD instructions for the related code.
Anyway I would appreciate if we could get some clarification on this matter.
Thanks,
James
[Attachment Removed]