#![allow(
clippy::cast_precision_loss,
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::float_cmp
)]
use crate::simd_native::{
calculate_prefetch_distance, prefetch_vector, prefetch_vector_multi_cache_line,
};
#[test]
fn test_prefetch_vector_compiles_x86() {
let vector: Vec<f32> = (0..768).map(|i| i as f32).collect();
prefetch_vector(&vector);
}
#[test]
fn test_prefetch_vector_empty() {
let vector: Vec<f32> = vec![];
prefetch_vector(&vector);
}
#[test]
fn test_prefetch_vector_null_safe() {
let small_vector: Vec<f32> = vec![1.0, 2.0, 3.0];
prefetch_vector(&small_vector);
}
#[test]
fn test_prefetch_multi_cache_line_384d() {
let vector: Vec<f32> = (0..384).map(|i| i as f32).collect();
prefetch_vector_multi_cache_line(&vector);
}
#[test]
fn test_prefetch_multi_cache_line_768d() {
let vector: Vec<f32> = (0..768).map(|i| i as f32).collect();
prefetch_vector_multi_cache_line(&vector);
}
#[test]
fn test_prefetch_multi_cache_line_1536d() {
let vector: Vec<f32> = (0..1536).map(|i| i as f32).collect();
prefetch_vector_multi_cache_line(&vector);
}
#[test]
fn test_calculate_prefetch_distance() {
assert_eq!(calculate_prefetch_distance(128), 8);
assert_eq!(calculate_prefetch_distance(384), 16);
assert_eq!(calculate_prefetch_distance(768), 16);
assert_eq!(calculate_prefetch_distance(1536), 16);
}
#[test]
fn test_prefetch_distance_bounds() {
assert_eq!(calculate_prefetch_distance(0), 4);
assert_eq!(calculate_prefetch_distance(1), 4);
assert_eq!(calculate_prefetch_distance(32), 4);
assert!(calculate_prefetch_distance(10000) == 16);
}