pub fn prefetch_read_data<T, const LOCALITY: i32>(addr: *const T)Expand description
Prefetches data for reading into the cache.
This function hints to the CPU that the data at the given address will be read soon, allowing the CPU to load the data into the cache in advance. This can improve performance by reducing cache misses.
Prefetching is only a hint and never affects the observable behavior of the program: it is safe to call with any pointer, including dangling or out-of-bounds pointers.
§Arguments
addr- A pointer to the data to prefetch.LOCALITY- The cache level to prefetch into:0= L1,1= L2,2= L3, any other value = non-temporal. The convention is identical on stable and nightly toolchains.
§Supported architectures
On stable, the hint is emitted on rustc 1.59 or newer (the release that
stabilized inline assembly) for x86/x86_64 (with the sse target
feature, enabled by default on x86_64 and i686 targets), aarch64,
and riscv64 when compiled with the zicbop target feature
(-C target-feature=+zicbop); on rustc 1.84 or newer for s390x; and
on rustc 1.95 or newer for powerpc/powerpc64 (the releases that
stabilized inline assembly for those architectures). s390x,
powerpc and powerpc64 have a single prefetch instruction with no
cache-level selection, so LOCALITY is ignored there. On other targets,
and on stable compilers older than the listed versions, this compiles to
a no-op. On nightly, the hint is lowered by LLVM for every architecture
that supports one.