Skip to main content

prefetch_index

Function prefetch_index 

Source
pub fn prefetch_index<T>(data: impl AsRef<[T]>, index: usize)
Expand description

Prefetches the cache line containing (the first byte of) data[index] into all levels of the cache.

On x86/x86_64, this uses _mm_prefetch which only requires the (commonly available) SSE feature.

On aarch64, this is gated behind the aarch64 feature flag as aarch64::_prefetch is nightly.

On other architectures, this is a no-op.

use prefetch_index::prefetch_index;
let data = vec![0u8; 1024];
prefetch_index(&data, 512);