迈向无畏的单指令多数据(SIMD),7 年后

  • 2018 Post and Current Status: 7 years ago, a blog post outlined Rust for SIMD. Currently, writing SIMD in Rust is rough but there has been progress. Linebender projects are now using SIMD for CPU/GPU hybrid rendering and other tasks.
  • Simple Sigmoid Example: A scalar sigmoid function and its autovectorized version are shown. More complex examples often fail to autovectorize due to floating-point semantics.
  • Safety Issue: Exposed SIMD intrinsics are marked as unsafe as SIMD support varies. Hand-written intrinsic code for sigmoid on different architectures is provided.
  • Multiversioning: A central problem for SIMD is multiversioning and runtime dispatch. Different approaches like multiversion crate, rust-target-feature-dispatch, and writing functions polymorphic on a zero-sized SIMD type are discussed. The fearless_simd#2 prototype is proposed with arithmetic traits for vector types.
  • FP16 and AVX-512: Smaller scalars with higher throughputs are a trend. Native Rust support for f16 is awaited. AVX-512 has pros and cons, and Intel is proposing AVX10.
  • About std::simd: It focuses on portability and doesn't solve the multiversion problem, considered a souped-up version of autovectorization.
  • Language Evolution: Rust's SIMD support is rough. Proposals like target_feature 1.1 and safe intrinsics in core::arch are in progress to improve. More work is needed to help the compiler recognize safe SIMD use.
  • Looking Forward: The goal is to spark conversation on supporting SIMD programming in Rust. The Vello project needs good SIMD code, and the Rust ecosystem should build infrastructure similar to Highway.
阅读 8
0 条评论