Expand description
Flush the data cache line.
This crate can be used when you do benchmarks that are not dependent on the cpu cache.
§Supports
- x86_64, aarch64 (native implementation)
- mips64el, powerpc64le … etc (fallback to
__builtin_clear_cache) - minimum support rustc 1.70.0 (due to
core::archandasm!)
§Examples
Easy to use:
let a = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
clf::cache_line_flush_with_slice(&a);or
let a = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
let begin_ptr = a.as_ptr();
let end_ptr = unsafe { begin_ptr.add(a.len()) };
unsafe { clf::cache_line_flush_with_ptr(begin_ptr, end_ptr) };§References
§Benchmarking
To measure the effectiveness of the cache flushing, you can run the included benchmarks:
make benchThis will compare the access time of “warm” data versus “flushed” data.
Functions§
- cache_
line_ ⚠flush_ with_ ptr - flush the data cache line, this parameters are pointers.
- cache_
line_ flush_ with_ slice - flush the data cache line, this parameter is a slice.