rust - 默认发布版本是否始终使用 SSSE3 指令?

标签 rust x86-64 sse simd

查看由 cargo (cargo build --release) 生成的二进制代码。我在二进制文件中发现使用了 SSSE3 指令,例如 pshufb

查看我的 cfg:

$ rustc --print cfg
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

给定 SIMD ISA(AVX2 或 SSSE3)我有不同的路径,并希望有一个非 SIMD 的默认构建。

#[cfg(target_feature = "avx2")]
{
    ...
    return;
}
#[cfg(target_feature = "ssse3")]
{
    ...
    return;
}
// portable Rust code at the end
...

这是否意味着默认发布版本将始终使用最多 SSSE3 指令,而不仅仅是 x86_64 上强制要求的 SSE2?

最佳答案

target_os="macos"

ma​​cOS 上构建的默认版本会,是的。

Since Apple has never sold any AMD or Pentium4 CPUs, x86-64 on OS X also implies SSSE3 (first-gen Core2). The first x86 Macs were Core (not Core2), but they were 32-bit only. You unfortunately can't assume SSE4.1 or -mpopcnt.

关于rust - 默认发布版本是否始终使用 SSSE3 指令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57256251/

相关文章:

string - 如何生成一个由字母数字字符组成的随机字符串?

rust - 如何对 float 的 Vec 进行二分查找?

assembly - 如何在 SSE 寄存器末尾添加 "remove"字节?

NASM 程序集中的 Windows API 蜂鸣功能

c++ - 数组初始化优化

c++ - char * 的 _mm_loadu_ps 是否有等效项?

rust - 如何以方便的方式对齐堆上的内存(在一个盒子里)?

rust - 在闭包之间共享Arc

c - 如何使用 SSE 进行 uint32/float 转换?

使用 SSE 计算到多个字符串的汉明距离