Skip to content

Commit

Permalink
Add cfg conditionals to support compiling on non-x86 targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Schuwi committed Jul 17, 2020
1 parent 01999a2 commit 23c6905
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions src/lib.rs
Expand Up @@ -82,6 +82,7 @@
//! ```

extern crate simdeez;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub mod avx2;
pub mod cellular;
pub mod cellular_64;
Expand All @@ -91,9 +92,12 @@ pub mod scalar;
mod shared;
pub mod simplex;
pub mod simplex_64;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub mod sse2;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub mod sse41;

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
macro_rules! get_1d_noise {
($setting:expr) => {
if is_x86_feature_detected!("avx2") {
Expand All @@ -108,6 +112,14 @@ macro_rules! get_1d_noise {
};
}

#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
macro_rules! get_1d_noise {
($setting:expr) => {
unsafe { scalar::get_1d_noise($setting) }
};
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
macro_rules! get_2d_noise {
($setting:expr) => {
if is_x86_feature_detected!("avx2") {
Expand All @@ -122,6 +134,14 @@ macro_rules! get_2d_noise {
};
}

#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
macro_rules! get_2d_noise {
($setting:expr) => {
unsafe { scalar::get_2d_noise($setting) }
};
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
macro_rules! get_3d_noise {
($setting:expr) => {
if is_x86_feature_detected!("avx2") {
Expand All @@ -136,6 +156,14 @@ macro_rules! get_3d_noise {
};
}

#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
macro_rules! get_3d_noise {
($setting:expr) => {
unsafe { scalar::get_3d_noise($setting) }
};
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
macro_rules! get_4d_noise {
($setting:expr) => {
if is_x86_feature_detected!("avx2") {
Expand All @@ -150,6 +178,14 @@ macro_rules! get_4d_noise {
};
}

#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
macro_rules! get_4d_noise {
($setting:expr) => {
unsafe { scalar::get_4d_noise($setting) }
};
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
macro_rules! get_1d_scaled_noise {
($setting:expr) => {
if is_x86_feature_detected!("avx2") {
Expand All @@ -164,6 +200,14 @@ macro_rules! get_1d_scaled_noise {
};
}

#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
macro_rules! get_1d_scaled_noise {
($setting:expr) => {
unsafe { scalar::get_1d_scaled_noise($setting) }
};
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
macro_rules! get_2d_scaled_noise {
($setting:expr) => {
if is_x86_feature_detected!("avx2") {
Expand All @@ -178,6 +222,14 @@ macro_rules! get_2d_scaled_noise {
};
}

#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
macro_rules! get_2d_scaled_noise {
($setting:expr) => {
unsafe { scalar::get_2d_scaled_noise($setting) }
};
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
macro_rules! get_3d_scaled_noise {
($setting:expr) => {
if is_x86_feature_detected!("avx2") {
Expand All @@ -192,6 +244,14 @@ macro_rules! get_3d_scaled_noise {
};
}

#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
macro_rules! get_3d_scaled_noise {
($setting:expr) => {
unsafe { scalar::get_3d_scaled_noise($setting) }
};
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
macro_rules! get_4d_scaled_noise {
($setting:expr) => {
if is_x86_feature_detected!("avx2") {
Expand All @@ -206,6 +266,13 @@ macro_rules! get_4d_scaled_noise {
};
}

#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
macro_rules! get_4d_scaled_noise {
($setting:expr) => {
unsafe { scalar::get_4d_scaled_noise($setting) }
};
}

#[derive(Copy, Clone)]
/// The function to use to compute distance between cells
pub enum CellDistanceFunction {
Expand Down

0 comments on commit 23c6905

Please sign in to comment.