#memory #clear #flush

clf

flush the cpu cache line by __builtin_clear_cache()

4 releases

0.1.3 Nov 14, 2021
0.1.2 Sep 10, 2021
0.1.1 Jun 16, 2021
0.1.0 Jun 16, 2021

#402 in Algorithms

MIT/Apache

6KB
73 lines

clf

Flush the cpu cache line by __builtin_clear_cache()

This crate can be used when you do benchmarks that are not dependent on the cpu cache.

Supports

  • gcc and clang
  • gnu and musl
  • x86_64, aarch64, mips64el, powerpc64le ... etc
  • minimum support rustc 1.38.0 (625451e37 2019-09-23)

Bugs

  • armv7-unknown-linux-musleabihf: can not compile

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()) };
clf::cache_line_flush_with_ptr(begin_ptr, end_ptr);

References

CPU cache

Changelogs

This crate's changelog here.

License

This project is licensed under either of

at your option.

No runtime deps

~140KB

a