start adding stdsimd support
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 4 May 2021 05:02:08 +0000 (22:02 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Tue, 4 May 2021 05:02:08 +0000 (22:02 -0700)
Cargo.toml
src/lib.rs
src/stdsimd.rs [new file with mode: 0644]

index 3cf9665228c5329f13bce7ca7eabc823be897268..5f82460a1e0c49ffa8d95b64b8d795ac0eec75e5 100644 (file)
@@ -8,6 +8,7 @@ license = "MIT OR Apache-2.0"
 [dependencies]
 half = { version = "1.7.1", optional = true }
 typed-arena = { version = "2.0.1", optional = true }
 [dependencies]
 half = { version = "1.7.1", optional = true }
 typed-arena = { version = "2.0.1", optional = true }
+core_simd = { version = "0.1.0", git = "https://github.com/rust-lang/stdsimd", optional = true }
 
 [features]
 default = ["f16", "fma"]
 
 [features]
 default = ["f16", "fma"]
@@ -15,3 +16,4 @@ f16 = ["half"]
 fma = ["std"]
 std = []
 ir = ["std", "typed-arena"]
 fma = ["std"]
 std = []
 ir = ["std", "typed-arena"]
+stdsimd = ["core_simd"]
index 1b3add31dc4ccf23ecdc99f184ba12cf39500ba8..cecc2e4566d62787705f20076e5291b873080add 100644 (file)
@@ -10,4 +10,6 @@ pub mod ieee754;
 #[cfg(feature = "ir")]
 pub mod ir;
 pub mod scalar;
 #[cfg(feature = "ir")]
 pub mod ir;
 pub mod scalar;
+#[cfg(feature = "stdsimd")]
+pub mod stdsimd;
 pub mod traits;
 pub mod traits;
diff --git a/src/stdsimd.rs b/src/stdsimd.rs
new file mode 100644 (file)
index 0000000..4e76d8f
--- /dev/null
@@ -0,0 +1,45 @@
+use crate::{f16::F16, traits::Context};
+use core::marker::PhantomData;
+use core_simd::SimdF32;
+
+#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default)]
+pub struct StdSimd<const LANES: usize>(PhantomData<[(); LANES]>);
+
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default)]
+pub struct Scalar<T, const LANES: usize>(pub T, PhantomData<[(); LANES]>);
+
+impl<T, const LANES: usize> From<T> for Scalar<T, LANES> {
+    fn from(v: T) -> Self {
+        Scalar(v, PhantomData)
+    }
+}
+
+/*
+TODO(programmerjake): finish after splitting Context::VecBool
+impl<const LANES: usize> Context for StdSimd<LANES> {
+    type Bool = Scalar<bool>;
+    type U8 = Scalar<u8>;
+    type I8 = Scalar<i8>;
+    type U16 = Scalar<u16>;
+    type I16 = Scalar<i16>;
+    type F16 = Scalar<F16>;
+    type U32 = Scalar<u32>;
+    type I32 = Scalar<i32>;
+    type F32 = Scalar<f32>;
+    type U64 = Scalar<u64>;
+    type I64 = Scalar<i64>;
+    type F64 = Scalar<f64>;
+    type VecBool;
+    type VecU8;
+    type VecI8;
+    type VecU16;
+    type VecI16;
+    type VecF16;
+    type VecU32;
+    type VecI32;
+    type VecF32;
+    type VecU64;
+    type VecI64;
+    type VecF64;
+}
+*/