Skip to content

Commit

Permalink
Merge pull request #30 from burrbull/portable_simd
Browse files Browse the repository at this point in the history
Port to portable simd
  • Loading branch information
burrbull authored Aug 8, 2022
2 parents 26726a0 + 62c1610 commit 77c9266
Show file tree
Hide file tree
Showing 25 changed files with 3,334 additions and 3,256 deletions.
30 changes: 29 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
ci:
name: CI
runs-on: ubuntu-latest
needs: [build, test]
needs: [build, test, test-native]
steps:
- name: Done
run: exit 0
Expand Down Expand Up @@ -59,6 +59,34 @@ jobs:
profile: minimal
override: true

- name: Print enabled target features
run: rustc --print=cfg -C target-cpu=native

- uses: actions-rs/cargo@v1
with:
command: test

test-native:
name: Test
runs-on: ubuntu-latest
env:
RUST_BACKTRACE: 1
RUSTFLAGS: -C target-cpu=native

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
override: true

- name: Print enabled target features
run: rustc --print=cfg -C target-cpu=native

- uses: actions-rs/cargo@v1
with:
command: test
12 changes: 3 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ license = "MIT OR Apache-2.0"
readme = "README.md"

[dependencies.doubled]
version = "0.2.3"
features = ["packed_simd"]

[dependencies.packed_simd]
package = "packed_simd_2"
version = "0.3.8"
features = ["into_bits"]
version = "0.3.0"
features = ["simd"]

[features]
default = []
Expand All @@ -26,5 +21,4 @@ default = []
rug = "1.16"

[dev-dependencies.rand]
version = "0.8.5"
features = ["simd_support"]
version = "0.8.5"
6 changes: 4 additions & 2 deletions examples/hello.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use packed_simd::f64x2;
#![feature(portable_simd)]

use sleef::f64x2::f64x2;

fn main() {
let input = f64x2::new(1.43, 0.57);
let input = f64x2::from_array([1.43, 0.57]);
let output = sleef::f64x2::sin_u10(input);
println!("sin(α) = {:?}", output);
}
12 changes: 6 additions & 6 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ impl SqrtAsDoubled for f32 {
#[inline]
fn sqrt_as_doubled(self) -> Doubled<Self> {
let t = self.sqrt();
((self + t.mul_as_doubled(t)) * t.recpre()).scale(0.5)
((self + t.mul_as_doubled(t)) * t.recip_as_doubled()).scale(0.5)
}
}

impl SqrtAsDoubled for f64 {
#[inline]
fn sqrt_as_doubled(self) -> Doubled<Self> {
let t = self.sqrt();
((self + t.mul_as_doubled(t)) * t.recpre()).scale(0.5)
((self + t.mul_as_doubled(t)) * t.recip_as_doubled()).scale(0.5)
}
}

Expand All @@ -52,15 +52,15 @@ impl Sqrt for Doubled<f32> {
#[inline]
fn sqrt(self) -> Self {
let t = f32::from(self).sqrt();
((self + t.mul_as_doubled(t)) * t.recpre()).scale(0.5)
((self + t.mul_as_doubled(t)) * t.recip_as_doubled()).scale(0.5)
}
}

impl Sqrt for Doubled<f64> {
#[inline]
fn sqrt(self) -> Self {
let t = f64::from(self).sqrt();
((self + t.mul_as_doubled(t)) * t.recpre()).scale(0.5)
((self + t.mul_as_doubled(t)) * t.recip_as_doubled()).scale(0.5)
}
}

Expand Down Expand Up @@ -100,8 +100,8 @@ where
}

pub trait Sign: MaskType + BitsType {
fn is_sign_negative(self) -> Self::Mask;
fn is_sign_positive(self) -> Self::Mask;
/* fn is_sign_negative(self) -> Self::Mask;
fn is_sign_positive(self) -> Self::Mask;*/
fn sign_bit(self) -> Self::Bits;
fn sign(self) -> Self;
fn mul_sign(self, other: Self) -> Self;
Expand Down
Loading

0 comments on commit 77c9266

Please sign in to comment.