Replies: 1 comment
-
Looks like it's possible to set rustflags using a One idea is to include a "building and deploying your Valence server" section in the future valence book that would explain how to use Like you said, I'm not sure we have much work that would really benefit from SIMD, and the amount of that code that would actually be SIMDified automatically by the compiler shrinks that even more. But I don't have much experience in this area. As an aside, there is a single place in the codebase where SIMD instructions are used explicitly, which is the |
Beta Was this translation helpful? Give feedback.
-
I've discovered recently that rust does not do CPU feature detection by default. This means that if somebody builds their server using valence, and they don't know to add compiler flags to enable it, the compiler will never emit instructions for AVX2 or AVX512.
-C target_arch=native
makes it so that rustc treats the CPU that is running the compiler as the target CPU. This means rustc will output the most optimized code for your current CPU, but if you bring that binary over to another system and it doesn't support the instructions, it'll crash and burn. There's also-C target_feature=+avx2
and related flags to enable compiling for specific cpu features, but telling users to do this kinda sucks. Valence should perform well by default. That means doing dynamic CPU feature detection, at runtime.It's possible to allow the compiler to emit code for certain cpu features for specific functions by adding
#[target_feature(enable = "feature")]
. It's possible to have this kind of code:The problem is that
#[target_feature(enable = "feature")]
is only allowed on unsafe functions, even if technically there is no unsafe code inside. And ultimately, this does add additional complexity. We'd have to pick and choose where and when to employ this pattern.Thoughts? Honestly, I'm not entirely sure if we have workloads that would benefit from SIMD stuff. We'll have to benchmark for it.
Beta Was this translation helpful? Give feedback.
All reactions