mem_prefetch 0.1.1

mem_prefetch provides a simple platform agnostic wrapper for memory prefetching.
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented1 out of 5 items with examples
  • Size
  • Source code size: 7.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.15 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • vdrn/mem_prefetch
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vdrn

mem_prefetch

This crate provides a simple platform agnostic wrapper for memory prefetching.

Cargo.toml

[dependencies]
mem_prefetch = "0.1"

Usage

mem_prefetch::prefetch_read_data::<_, 3>(reference);  // most local
mem_prefetch::prefetch_write_data::<_, 3>(reference); // most local 

mem_prefetch::prefetch_read_data::<_, 2>(reference);
mem_prefetch::prefetch_write_data::<_, 2>(reference);

mem_prefetch::prefetch_read_data::<_, 1>(reference);
mem_prefetch::prefetch_write_data::<_, 1>(reference);

mem_prefetch::prefetch_read_data::<_, 0>(reference);  // least local
mem_prefetch::prefetch_write_data::<_, 0>(reference); // least local


// Or raw ptr variants:
unsafe {
    mem_prefetch::prefetch_read_data_raw::<_, 0>(ptr);
    mem_prefetch::prefetch_write_data_raw::<_, 0>(ptr);
}

Features

  • fallback: Use fallback ptr::read_volatile for prefetching if no prefetch instruction is available. (Enabled by default).
  • nightly: Use llvm intrinsics from core_intrinsics for prefetching.

Notes

  • read/write variants map to same instructions on x86.