#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
use std::ptr;
pub struct PrefetchEngine;
impl PrefetchEngine {
#[inline(always)]
#[cfg(target_feature = "sse")]
pub unsafe fn compute_mapped_array_with_prefetch(data: &[u8]) -> usize {
let mut checksum = 0usize;
let prefetch_offset = 64 * 12; let chunk_step = 64;
let mut index = 0;
while index + prefetch_offset + chunk_step <= data.len() {
_mm_prefetch(
data.as_ptr().add(index + prefetch_offset) as *const i8,
_MM_HINT_T0,
);
for sub_idx in 0..chunk_step {
checksum = checksum.wrapping_add(data[index + sub_idx] as usize);
}
index += chunk_step;
}
while index < data.len() {
checksum = checksum.wrapping_add(data[index] as usize);
index += 1;
}
checksum
}
}