I have code that depends on CPU and OS support for various CPU functions.
In particular, I need to check SIMD instruction set support. Namely sse2 , avx , avx2 , fma4 and neon . ( neon is an ARM SIMD function. I'm less interested in this, given the fewer ARM end users.)
Now I am doing the following:
function cpu_flags() if is_linux() cpuinfo = readstring(`cat /proc/cpuinfo`); cpu_flag_string = match(r"flags\t\t: (.*)", cpuinfo).captures[1] elseif is_apple() sysinfo = readstring(`sysctl -a`); cpu_flag_string = match(r"machdep.cpu.features: (.*)", cpuinfo).captures[1] else @assert is_windows() warn("CPU Feature detection does not work on windows.") cpu_flag_string = "" end split(lowercase(cpu_flag_string)) end
This has two drawbacks:
- It does not work on Windows
- I'm just not sure if this is correct; This is true? Or will it go bad if, for example, the OS is disabled, but physically the processor supports it?
So my questions are:
- How can I do this work on windows.
- Is this the right way, or even an OK way to get this information?
This is part of the build script (with BinDeps.jl ); so I need a solution that is not related to opening a GUI. And ideally, this is one that does not add third-party addiction. Extracting information from GCC will work in some way, since I already require that GCC compile some shared libraries. (selection of those libraries that this code is to detect a set of commands for)
source share