Closed brocaar closed 2 years ago
Hm, we have been following the Rust reference which assumes that enabled AVX2 implies AVX.
But isn't this to manually enable target features? I read this as: If you enable avx2
, this will automatically enable avx
(no need to enable both explicitly). It doesn't say anything about the detection of this CPU extension.
The Intel note is quite clear on this: "Application Software must identify that hardware supports AVX ...., after that it must also detect support for AVX2 ....".
Can you check what the following snippet prints on the CPU?
println!("avx: {}", is_x86_feature_detected!("avx"));
println!("avx2: {}", is_x86_feature_detected!("avx2"));
Output:
avx: false
avx2: false
The output of:
cpufeatures::new!(avx_cpuid, "avx");
cpufeatures::new!(avx2_cpuid, "avx2");
fn main() {
println!("Supports avx: {}", avx_cpuid::get());
println!("Supports avx2: {}", avx2_cpuid::get());
}
Supports avx: false
Supports avx2: true
The output of:
cpufeatures::new!(avx2_cpuid, "avx", "avx2");
fn main() {
println!("Supports avx2: {}", avx2_cpuid::get());
}
Supports avx2: false
I've updated the pull-request. After merging, would you be able to create a new release?
Hm, the is_x86_feature_detected!
results are interesting. So it looks like the std
code checks both AVX and AVX2 when we test existence of avx2
.
@tarcieri
Maybe it's better to modify cpufeatures
to follow std
?
Sure, sounds good
The above PR solved this issue. Thanks! :+1:
Please see the Intel note about detecting the
avx2
extension:https://www.intel.com/content/dam/develop/external/us/en/documents/36945
It states that both the support for AVX and AVX2 must be detected.
Some context:
I had a bug report that trying to login caused the application (ChirpStack) to panic. After a deep dive, it turned out that the host (Qemu CPU) does not support these instructions, but
avx2_cpuid::get()
returns true.Then I noticed that the Intel docs state that both
AVX
andAVX2
must be checked. Running this application on this specific Qemu CPU returns:As reference, this is the content of
/proc/cpuinfo
: