You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to re-write an old memory testing app called TM5 (https://testmem.tz.ru/testmem5.htm) in Rust, while adding a bunch of new features. AI assisted of course as I'm not a great programmer. Sorry if that makes you cringe.
I've had some fun trying to get SIMD non-temporal writes working, as it seems core::intrinsics::nontemporal_store just does compiler hints to LLVM, but these seem to get stripped by Rust/LLVM optimiser cycles. So for that I've admitted defeat and just went with std::arch intrinsics (_mm512_stream_si512), which emits inlines ASM with #APP/#NO_APP that is Opaque to LLVM and means manual unrolling is needed :( But given I have seen a good amount of debate on this topic and how to address it, I'll park it for another ask. It seems most people prefer targetting this way anyway to ensure full control of low level code. Though I thought Rust would have tried abstracting it at a higher level.
Anyway, like the author of this post I would like support for the _mm_clflushopt intrinsic to core::arch::x86_64, which is hopefully more straight forward then non-temporal. It would complete Rust’s coverage of the x86 cache‑flush and persistence‑related instructions and remove unneeded assembly. The implementation as I understand it would be a thin wrapper around LLVM’s existing intrinsic llvm.x86.clflushopt, consistent with how _mm_clflush and _mm_clwb are exposed.
Motivation
Rust currently exposes:
_mm_clflush (stable)
_mm_clwb (nightly)
_mm_sfence (stable)
…but does not expose_mm_clflushopt, even though:
LLVM provides the intrinsic
The instruction is widely supported (Skylake and newer)
It is part of the same family of cache‑management instructions
I'm after it, as in my micro benchmark CLFLUSHOPT was ~15× faster than the only currently-exposed flush (_mm_clflush/SSE2). So this will definetly be helpful in my memory testing app.
Activity
Amanieu commentedon Aug 11, 2023
LLVM has a
clflushopt, so it's fine to do the same here.jlpetz commentedon May 29, 2026
Hi All,
I'm trying to re-write an old memory testing app called TM5 (https://testmem.tz.ru/testmem5.htm) in Rust, while adding a bunch of new features. AI assisted of course as I'm not a great programmer. Sorry if that makes you cringe.
I've had some fun trying to get SIMD non-temporal writes working, as it seems core::intrinsics::nontemporal_store just does compiler hints to LLVM, but these seem to get stripped by Rust/LLVM optimiser cycles. So for that I've admitted defeat and just went with
std::archintrinsics (_mm512_stream_si512), which emits inlines ASM with#APP/#NO_APPthat is Opaque to LLVM and means manual unrolling is needed :( But given I have seen a good amount of debate on this topic and how to address it, I'll park it for another ask. It seems most people prefer targetting this way anyway to ensure full control of low level code. Though I thought Rust would have tried abstracting it at a higher level.Anyway, like the author of this post I would like support for the
_mm_clflushoptintrinsic tocore::arch::x86_64, which is hopefully more straight forward then non-temporal. It would complete Rust’s coverage of the x86 cache‑flush and persistence‑related instructions and remove unneeded assembly. The implementation as I understand it would be a thin wrapper around LLVM’s existing intrinsicllvm.x86.clflushopt, consistent with how_mm_clflushand_mm_clwbare exposed.Motivation
Rust currently exposes:
_mm_clflush(stable)_mm_clwb(nightly)_mm_sfence(stable)…but does not expose
_mm_clflushopt, even though:I'm after it, as in my micro benchmark CLFLUSHOPT was ~15× faster than the only currently-exposed flush (_mm_clflush/SSE2). So this will definetly be helpful in my memory testing app.
Rollup merge of rust-lang#157098 - jlpetz:clflushopt-target-feature, …