Open nkysg opened 2 years ago
On my macos run this cmd rustc --print=cfg
, it output this
debug_assertions
target_arch="x86_64"
target_endian="little"
target_env=""
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="sse3"
target_feature="ssse3"
target_os="macos"
target_pointer_width="64"
target_vendor="apple"
unix
but i run this cmd sysctl -a | grep machdep.cpu | grep features
it output
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C
why rustc --print=cfg
does not show SSE4.2
I thought this is rustc bug. I found a artcile Possible issue detecting SSE4.2 support - help
this artcile say I must use rustc --print=cfg -C target-cpu=native
it output
debug_assertions
target_arch="x86_64"
target_endian="little"
target_env=""
target_family="unix"
target_feature="aes"
target_feature="avx"
target_feature="avx2"
target_feature="bmi1"
target_feature="bmi2"
target_feature="fma"
target_feature="fxsr"
target_feature="lzcnt"
target_feature="pclmulqdq"
target_feature="popcnt"
target_feature="rdrand"
target_feature="rdseed"
target_feature="sha"
target_feature="sse"
target_feature="sse2"
target_feature="sse3"
target_feature="sse4.1"
target_feature="sse4.2"
target_feature="ssse3"
target_feature="xsave"
target_feature="xsavec"
target_feature="xsaveopt"
target_feature="xsaves"
target_os="macos"
target_pointer_width="64"
target_vendor="apple"
unix
satisfy
config.flag_if_supported("-msse2");
}
if target_features.contains(&"sse4.1") {
config.flag_if_supported("-msse4.1");
}
if target_features.contains(&"sse4.2") {
config.flag_if_supported("-msse4.2");
config.define("HAVE_SSE42", Some("1"));
}
May be use this cmd RUSTFLAGS="-C target-cpu=native" cargo build --release
OK?
but this https://stackoverflow.com/questions/67444134/rust-target-cpu-native-gets-slower-simd-execution show that it may be have bug
This bug seems to have been fixed @nkysg SSE42 is pretty old. It's really hard to find a X86-64 CPU which doesn't support SSE4.2. We could add this feature manually if there is still a bug.
This bug seems to have been fixed @nkysg SSE42 is pretty old. It's really hard to find a X86-64 CPU which doesn't support SSE4.2. We could add this feature manually if there is still a bug.
Yes, I think you are right. We can try do it。@templexxx
https://github.com/rust-rocksdb/rust-rocksdb/pull/526 the build.rs show this
we can add this compile flags