Support compilation outside x86-64

This commit is contained in:
Dirkjan Ochtman 2021-11-09 16:40:16 +01:00
parent 563d5cbcbf
commit 08cc3a78df
2 changed files with 38 additions and 29 deletions

View File

@ -1,4 +1,4 @@
[target.x86_64-apple-darwin] [build]
rustflags = [ rustflags = [
"-C", "link-arg=-undefined", "-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup", "-C", "link-arg=dynamic_lookup",

View File

@ -371,10 +371,12 @@ big_array! { BigArray; DIMENSIONS }
impl Point for FloatArray { impl Point for FloatArray {
fn distance(&self, rhs: &Self) -> f32 { fn distance(&self, rhs: &Self) -> f32 {
#[cfg(target_arch = "x86_64")]
{
use std::arch::x86_64::{ use std::arch::x86_64::{
_mm256_castps256_ps128, _mm256_extractf128_ps, _mm256_fmadd_ps, _mm256_load_ps, _mm256_castps256_ps128, _mm256_extractf128_ps, _mm256_fmadd_ps, _mm256_load_ps,
_mm256_setzero_ps, _mm256_sub_ps, _mm_add_ps, _mm_add_ss, _mm_cvtss_f32, _mm_fmadd_ps, _mm256_setzero_ps, _mm256_sub_ps, _mm_add_ps, _mm_add_ss, _mm_cvtss_f32,
_mm_load_ps, _mm_movehl_ps, _mm_shuffle_ps, _mm_sub_ps, _mm_fmadd_ps, _mm_load_ps, _mm_movehl_ps, _mm_shuffle_ps, _mm_sub_ps,
}; };
debug_assert_eq!(self.0.len() % 8, 4); debug_assert_eq!(self.0.len() % 8, 4);
@ -403,6 +405,13 @@ impl Point for FloatArray {
_mm_cvtss_f32(acc_4x) _mm_cvtss_f32(acc_4x)
} }
} }
#[cfg(not(target_arch = "x86_64"))]
self.0
.iter()
.zip(rhs.0.iter())
.map(|(&a, &b)| (a - b).powi(2))
.sum::<f32>()
}
} }
#[derive(Clone, Deserialize, Serialize)] #[derive(Clone, Deserialize, Serialize)]