Multitarget compiling and runtime cpuflag detection #6022
-
Hi, Halide is supporting 'runtime CPU flags detection' especially for x86 to find out whether the current CPU flags has avx2/avx512 etc support. And also CPU-flag presence itself is not sufficient as OS can disable the support of AVX etc. And thus using avx/avx2 libraries in such cases will result in crash. (Ref: https://stackoverflow.com/questions/48677575/does-gccs-builtin-cpu-supports-check-for-os-support) Just checking on the Halide's detection, whether it checks both the CPU flags presence and the if the OS enabled it for use. Code in 'x86_cpuid_halide' https://github.com/halide/Halide/blob/master/src/runtime/x86.ll. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Currently, Halide checks only for the CPU flags, and does not consider disabling via the OS. This is clearly suboptimal; we'd welcome a patch that added OS detection. |
Beta Was this translation helpful? Give feedback.
-
Most numerical libraries check cpuid and branch to specialized implementations accordingly. If you disable avx in the OS but not in the bios, I'd expect a lot of things to crash or produce garbage due to not saving avx registers on context switches. |
Beta Was this translation helpful? Give feedback.
-
BTW, please note that it's straightforward to just provide your own override of the runtime code that handles this -- just define a non-weak-linked version of
|
Beta Was this translation helpful? Give feedback.
BTW, please note that it's straightforward to just provide your own override of the runtime code that handles this -- just define a non-weak-linked version of