#memory #flush #clear

clf

flush the cpu cache line by __builtin_clear_cache()

8 releases

0.1.7 Feb 12, 2023
0.1.6 Jan 27, 2023
0.1.4 Jun 14, 2022
0.1.3 Nov 14, 2021
0.1.1 Jun 16, 2021

#334 in Algorithms

Download history 35/week @ 2023-01-27 4/week @ 2023-02-03 46/week @ 2023-02-10 33/week @ 2023-02-17 1/week @ 2023-02-24 2/week @ 2023-03-03 6/week @ 2023-03-10 3/week @ 2023-03-17 6/week @ 2023-03-24 2/week @ 2023-03-31 32/week @ 2023-04-07 9/week @ 2023-04-14 17/week @ 2023-04-21 6/week @ 2023-04-28 21/week @ 2023-05-05 14/week @ 2023-05-12

62 downloads per month

MIT/Apache

9KB
101 lines

clf

crate Docs Rust Version Apache2/MIT licensed Test ubu Test mac Test win

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.56.1 (59eed8a2a 2021-11-01)

Bugs

  • armv7-unknown-linux-musleabihf: can not compile
  • x86_64-pc-windows-msvc: 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