elasticsearch/libs/simdvec
Lorenzo Dematté 115062c643
Fix vec_caps to test for OS support too (on x64) (#126911)
On x64, we are testing if we support vector capabilities (1 = "basic" = AVX2, 2 = "advanced" = AVX-512) in order to enable and choose a native implementation for some vector functions, using CPUID.

However, under some circumstances, this is not sufficient: the OS on which we are running also needs to support AVX/AVX2 etc; basically, it needs to acknowledge it knows about the additional register and that it is able to handle them e.g. in context switches. To do that we need to a) test if the CPU has xsave feature and b) use the xgetbv to test if the OS set it (declaring it supports AVX/AVX2/etc).

In most cases this is not needed, as all modern OSes do that, but for some virtualized situations (hypervisors, emulators, etc.) all the component along the chain must support it, and in some cases this is not a given.

This PR introduces a change to the x64 version of vec_caps to check for OS support too, and a warning on the Java side in case the CPU supports vector capabilities but those are not enabled at OS level.

Tested by passing noxsave to my linux box kernel boot options, and ensuring that the avx flags "disappear" from /proc/cpuinfo, and we fall back to the "no native vector" case.

Fixes #126809
2025-04-16 16:06:46 +02:00
..
licenses Rename the vec module to better reflect that it provides SIMD optimized vector scorers (#109661) 2024-06-17 11:10:02 +01:00
native Fix vec_caps to test for OS support too (on x64) (#126911) 2025-04-16 16:06:46 +02:00
src Tweak the delta used for vector scorer tests (#126849) 2025-04-15 15:46:23 +01:00
build.gradle [Build] Remove deprecated BuildParams (#116984) 2024-11-22 16:30:57 +01:00
includes.txt Add AGPLv3 as a supported license 2024-09-13 15:29:46 -07:00
output.txt Update Gradle wrapper to 8.12 (#118683) 2024-12-30 15:34:24 +01:00