#![doc = include_str!("../README.md")]
#![allow(unexpected_cfgs)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![allow(
clippy::missing_transmute_annotations,
clippy::let_and_return,
unused_braces,
unused_imports
)]
#![deny(rustdoc::invalid_rust_codeblocks)]
#![cfg_attr(feature = "nightly", feature(core_intrinsics, const_eval_select))]
#![cfg_attr(
all(feature = "nightly", feature = "spirv", target_arch = "spirv"),
feature(asm_experimental_arch)
)]
#![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(all(feature = "nightly", target_arch = "wasm64"), feature(simd_wasm64))]
#![cfg_attr(
all(
feature = "nightly",
feature = "wasm",
any(target_arch = "wasm32", target_arch = "wasm64")
),
feature(wasm_numeric_instr)
)]
#![cfg_attr(all(feature = "nightly", feature = "std_simd"), feature(portable_simd))]
#[cfg(feature = "nightly")]
#[rustversion::not(nightly)]
fn nightly_check() {
compile_error!("The `nightly` feature requires a nightly compiler.");
}
#[cfg(all(feature = "spirv", not(thermite_unstable_spirv)))]
fn spirv_readiness_check() {
compile_error!(
"the `spirv` feature is incomplete and disabled in released versions of Thermite. \
To work on it anyway, depend on thermite \
from git and build with RUSTFLAGS='--cfg thermite_unstable_spirv'."
);
}
pub mod features {
pub const STRICT_IEEE754: bool = cfg!(feature = "strict_ieee754");
pub const PRESERVE_DENORMALS: bool = cfg!(feature = "preserve_denormals") || STRICT_IEEE754;
pub const IGNORE_DENORMALS: bool = cfg!(feature = "ignore_denormals") && !PRESERVE_DENORMALS;
pub const DISABLE_FAST_FMA: bool = cfg!(feature = "disable_fast_fma") || STRICT_IEEE754;
pub const ALGEBRAIC_SCALAR: bool = cfg!(feature = "algebraic-scalar") && !STRICT_IEEE754;
pub const DISABLE_DISPATCH: bool = cfg!(feature = "disable_dispatch");
pub const AVX2_F16C: bool = cfg!(feature = "avx2-f16c");
pub const AVX2_PCLMUL: bool = cfg!(feature = "avx2-pclmul");
}
#[cfg(feature = "bitvec")]
pub extern crate bitvec;
pub extern crate const_default;
pub extern crate generic_array;
pub use thermite_macros::{HasIsa, dispatch, dispatch_dyn};
#[macro_export]
macro_rules! MM_SHUFFLE {
() => { 0 };
($v:expr) => { $v };
($($v:expr),* $(,)?) => {const {
const LEN: usize = [$($v),*].len();
assert!(LEN.is_power_of_two(), "MM_SHUFFLE! requires a power of two number of lanes");
const SHIFT: u32 = LEN.ilog2();
let mut mask = 0;
$(
mask <<= SHIFT;
mask |= $v;
)*
mask
}};
}
#[macro_export] #[rustfmt::skip]
macro_rules! MM_SHUFFLE_R {
() => { 0 };
($v:expr) => { $v };
($($v:expr),* $(,)?) => {const {
const LEN: usize = [$($v),*].len();
assert!(LEN.is_power_of_two(), "MM_SHUFFLE_R! requires a power of two number of lanes");
const SHIFT: u32 = LEN.ilog2();
let mut mask = 0;
let mut shift = 0;
$(
mask |= $v << shift;
shift += SHIFT;
)*
mask
}};
}
pub mod guide {
#![doc = include_str!("../GUIDE.md")]
}
pub mod prelude {
pub use crate::{Mask, Vector};
pub use crate::{
divider::{BranchfreeDivider, Divider},
element::{Element, FloatElement},
mask::{CastMask, GenericMask},
math::{
CoreMath as _, CoreMathWithPolicy as _, FloatMath as _, FloatMathWithPolicy as _, RealMath as _,
RealMathWithPolicy as _, ScalarMath as _, ScalarMathWithPolicy as _, SpatialMath as _,
SpatialMathWithPolicy as _, TranscendentalMath as _, TranscendentalMathWithPolicy as _,
},
math::{FloatConsts, policy::Policy},
simd::{
FixedWidthSimd, FloatSimd, NativeIsa, NativeSimd, NativeSimdVectors, NativeSimdVectorsWithRegisters, Simd,
Simd3, Simd3A, Simd3AVectors, Simd3AVectorsWithRegisters, Simd3Vectors, Simd3VectorsWithRegisters,
SimdVectors, SimdVectorsWithRegisters, SizedSimd,
},
slice::SimdSlice as _,
sort::{Ascending, Descending, SortOrder},
swizzle::Swizzle as _,
vector::ops::{
AddAssignMasked as _, AddMasked as _, AddSubExt as _, AddSubExtMasked as _, BitAndAssignMasked as _,
BitAndMasked as _, BitAndNot as _, BitAndNotAssign as _, BitAndNotAssignMasked as _, BitAndNotMasked as _,
BitOrAssignMasked as _, BitOrMasked as _, BitXorAssignMasked as _, BitXorMasked as _, DivAssignMasked as _,
DivMasked as _, MulAddAssignExt as _, MulAddAssignExtMasked as _, MulAddExt as _, MulAddExtMasked as _,
MulAssignMasked as _, MulMasked as _, NegMasked as _, NotMasked as _, RemAssignMasked as _, RemMasked as _,
ShlAssignMasked as _, ShlMasked as _, ShrAssignMasked as _, ShrMasked as _, Square as _, SquareMasked as _,
SubAssignMasked as _, SubMasked as _,
},
vector::{
BitCastVector, BitshiftVector, BitwiseVector, CastVector, ConcatVector, ExtendVector, FloatVector,
FloatVectorWithBits, GenericVector, GenericVector2 as _, GenericVector3 as _, GenericVector4 as _,
IndexableVector, IntegerVector, Interleave, LinAlg3Vector, LinAlg4Vector, NumericVector, PackedFloatVector,
PartialOrdVector, SignedIntegerVector, SignedVector, SplatConst, StreamGroup, Swizzle3 as _, Swizzle4 as _,
SwizzleVector, UnsignedIntegerVector, VectorIndices, VectorWithRegister as _,
},
};
}
#[macro_use]
mod internal_macros;
#[macro_use]
pub mod simd;
pub mod isa;
pub mod vector;
pub mod backend;
pub mod compat;
pub mod cpu;
pub mod divider;
pub mod element;
pub mod mask;
pub mod math;
pub mod register;
pub mod slice;
pub mod sort;
#[doc(hidden)]
pub mod swizzle;
pub use divider::{BranchfreeDivider, Divider};
pub use isa::InstructionSet;
pub use mask::Mask;
pub use simd::HasIsa;
pub use swizzle::Swizzle;
pub use vector::Vector;
pub type LargeInt = cfg_select! {
all(feature = "spirv", target_arch = "spirv", not(target_feature = "Int64")) => i32,
_ => i64,
};
pub type LargeUInt = cfg_select! {
all(feature = "spirv", target_arch = "spirv", not(target_feature = "Int64")) => u32,
_ => u64,
};
cfg_if::cfg_if! {
if #[cfg(all(feature = "spirv", target_arch = "spirv"))] {
#[doc(hidden)] #[inline(always)] pub fn likely(b: bool) -> bool { b }
#[doc(hidden)] #[inline(always)] pub fn unlikely(b: bool) -> bool { b }
} else {
#[inline]
#[cold]
fn cold() {}
#[rustfmt::skip]
#[doc(hidden)] #[inline(always)]
pub fn likely(b: bool) -> bool {
if !b { cold() } b
}
#[rustfmt::skip]
#[doc(hidden)] #[inline(always)]
pub fn unlikely(b: bool) -> bool {
if b { cold() } b
}
}
}
#[macro_export]
macro_rules! ternlog_imm {
($($tt:tt)*) => {
const {
const A: i32 = 0xF0; const B: i32 = 0xCC; const C: i32 = 0xAA;
$($tt)*
}
};
}