Add ARM SIMD

This commit is contained in:
Patrick Walton 2019-03-28 14:55:38 -07:00
parent e4b613c2c8
commit ae192ffee7
10 changed files with 4079 additions and 9 deletions

29
Cargo.lock generated
View File

@ -214,6 +214,7 @@ name = "demo"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_demo 0.1.0", "pathfinder_demo 0.1.0",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
@ -647,7 +648,6 @@ dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"pathfinder_geometry 0.3.0", "pathfinder_geometry 0.3.0",
"pathfinder_gl 0.1.0", "pathfinder_gl 0.1.0",
"pathfinder_gpu 0.1.0", "pathfinder_gpu 0.1.0",
@ -715,6 +715,9 @@ dependencies = [
[[package]] [[package]]
name = "pathfinder_simd" name = "pathfinder_simd"
version = "0.3.0" version = "0.3.0"
dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "pathfinder_svg" name = "pathfinder_svg"
@ -1036,6 +1039,14 @@ name = "rustc-serialize"
version = "0.3.24" version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "0.2.7" version = "0.2.7"
@ -1090,6 +1101,19 @@ dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.88" version = "1.0.88"
@ -1469,6 +1493,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rustache 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c86de9443c1a5618e0d51bbd8eb6227ead9916446eb8952575a70d1ef7e00209" "checksum rustache 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c86de9443c1a5618e0d51bbd8eb6227ead9916446eb8952575a70d1ef7e00209"
"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
"checksum safe-transmute 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9604873ffe1980bc1f179103704a65c8aca141c248d9e52b7af95ff10578166e" "checksum safe-transmute 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9604873ffe1980bc1f179103704a65c8aca141c248d9e52b7af95ff10578166e"
"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
@ -1477,6 +1502,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum sdl2 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ebf85f207d42e4da59fa31fff977be5ff0b224873506c4bd70cc1c94b331593" "checksum sdl2 0.32.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0ebf85f207d42e4da59fa31fff977be5ff0b224873506c4bd70cc1c94b331593"
"checksum sdl2-sys 0.32.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e82803e85c2e6178d28886cef25b2c53afc2eecaeff739f2247f23ed3352e6c1" "checksum sdl2-sys 0.32.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e82803e85c2e6178d28886cef25b2c53afc2eecaeff739f2247f23ed3352e6c1"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)" = "9f301d728f2b94c9a7691c90f07b0b4e8a4517181d9461be94c04bddeb4bd850" "checksum serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)" = "9f301d728f2b94c9a7691c90f07b0b4e8a4517181d9461be94c04bddeb4bd850"
"checksum serde_derive 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)" = "beed18e6f5175aef3ba670e57c60ef3b1b74d250d962a26604bff4c80e970dd4" "checksum serde_derive 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)" = "beed18e6f5175aef3ba670e57c60ef3b1b74d250d962a26604bff4c80e970dd4"
"checksum serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "27dce848e7467aa0e2fcaf0a413641499c0b745452aaca1194d24dedde9e13c9" "checksum serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "27dce848e7467aa0e2fcaf0a413641499c0b745452aaca1194d24dedde9e13c9"

View File

@ -7,7 +7,6 @@ authors = ["Patrick Walton <pcwalton@mimiga.net>"]
[dependencies] [dependencies]
clap = "2.32" clap = "2.32"
gl = "0.6" gl = "0.6"
jemallocator = "0.1"
rayon = "1.0" rayon = "1.0"
usvg = "0.4" usvg = "0.4"

View File

@ -15,7 +15,6 @@ use crate::ui::{DemoUI, UIAction};
use crate::window::{Event, Keycode, SVGPath, Window, WindowSize}; use crate::window::{Event, Keycode, SVGPath, Window, WindowSize};
use clap::{App, Arg}; use clap::{App, Arg};
use image::ColorType; use image::ColorType;
use jemallocator;
use pathfinder_geometry::basic::point::{Point2DF32, Point2DI32, Point3DF32}; use pathfinder_geometry::basic::point::{Point2DF32, Point2DI32, Point3DF32};
use pathfinder_geometry::basic::rect::{RectF32, RectI32}; use pathfinder_geometry::basic::rect::{RectF32, RectI32};
use pathfinder_geometry::basic::transform2d::Transform2DF32; use pathfinder_geometry::basic::transform2d::Transform2DF32;
@ -47,9 +46,6 @@ use std::thread;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use usvg::{Options as UsvgOptions, Tree}; use usvg::{Options as UsvgOptions, Tree};
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
static DEFAULT_SVG_VIRTUAL_PATH: &'static str = "svg/Ghostscript_Tiger.svg"; static DEFAULT_SVG_VIRTUAL_PATH: &'static str = "svg/Ghostscript_Tiger.svg";
const MOUSELOOK_ROTATION_SPEED: f32 = 0.007; const MOUSELOOK_ROTATION_SPEED: f32 = 0.007;

View File

@ -9,6 +9,7 @@ pf-no-simd = ["pathfinder_simd/pf-no-simd"]
[dependencies] [dependencies]
gl = "0.6" gl = "0.6"
jemallocator = "0.1"
nfd = "0.0.4" nfd = "0.0.4"
sdl2 = "0.32" sdl2 = "0.32"
sdl2-sys = "0.32" sdl2-sys = "0.32"

View File

@ -10,6 +10,7 @@
//! A demo app for Pathfinder using SDL 2. //! A demo app for Pathfinder using SDL 2.
use jemallocator;
use nfd::Response; use nfd::Response;
use pathfinder_demo::DemoApp; use pathfinder_demo::DemoApp;
use pathfinder_demo::window::{Event, Keycode, SVGPath, Window, WindowSize}; use pathfinder_demo::window::{Event, Keycode, SVGPath, Window, WindowSize};
@ -24,6 +25,9 @@ use sdl2_sys::{SDL_Event, SDL_UserEvent};
use std::path::PathBuf; use std::path::PathBuf;
use std::ptr; use std::ptr;
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
const DEFAULT_WINDOW_WIDTH: u32 = 1067; const DEFAULT_WINDOW_WIDTH: u32 = 1067;
const DEFAULT_WINDOW_HEIGHT: u32 = 800; const DEFAULT_WINDOW_HEIGHT: u32 = 800;

View File

@ -3,8 +3,12 @@ name = "pathfinder_simd"
version = "0.3.0" version = "0.3.0"
edition = "2018" edition = "2018"
authors = ["Patrick Walton <pcwalton@mimiga.net>"] authors = ["Patrick Walton <pcwalton@mimiga.net>"]
build = "build.rs"
[features] [features]
pf-no-simd = [] pf-no-simd = []
[dependencies] [dependencies]
[build-dependencies]
rustc_version = "0.2"

26
simd/build.rs Normal file
View File

@ -0,0 +1,26 @@
// pathfinder/simd/build.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate rustc_version;
use rustc_version::Channel;
fn main() {
// Assert we haven't travelled back in time
assert!(rustc_version::version().unwrap().major >= 1);
// Set cfg flags depending on release channel
match rustc_version::version_meta().unwrap().channel {
Channel::Nightly => {
println!("cargo:rustc-cfg=pf_rustc_nightly");
}
_ => {}
}
}

4003
simd/src/arm.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,14 +8,24 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![cfg_attr(pf_rustc_nightly, feature(link_llvm_intrinsics, platform_intrinsics))]
#![cfg_attr(pf_rustc_nightly, feature(simd_ffi, stdsimd))]
//! A minimal SIMD abstraction, usable outside of Pathfinder. //! A minimal SIMD abstraction, usable outside of Pathfinder.
#[cfg(any(feature = "pf-no-simd", all(not(target_arch = "x86"), not(target_arch = "x86_64"))))] #[cfg(any(feature = "pf-no-simd",
not(any(target_arch = "x86",
target_arch = "x86_64",
all(pf_rustc_nightly, target_arch = "aarch64")))))]
pub use crate::scalar as default; pub use crate::scalar as default;
#[cfg(all(not(feature = "pf-no-simd"), pf_rustc_nightly, target_arch = "aarch64"))]
pub use crate::arm as default;
#[cfg(all(not(feature = "pf-no-simd"), any(target_arch = "x86", target_arch = "x86_64")))] #[cfg(all(not(feature = "pf-no-simd"), any(target_arch = "x86", target_arch = "x86_64")))]
pub use crate::x86 as default; pub use crate::x86 as default;
pub mod scalar; pub mod scalar;
#[cfg(all(pf_rustc_nightly, target_arch = "aarch64"))]
pub mod arm;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub mod x86; pub mod x86;
mod extras; mod extras;

View File

@ -3935,10 +3935,10 @@ impl U8x16 {
} }
#[inline] #[inline]
pub fn shuffle(self, table: U8x16) -> U8x16 { pub fn shuffle(self, indices: U8x16) -> U8x16 {
let mut result = [0; 16]; let mut result = [0; 16];
for index in 0..16 { for index in 0..16 {
result[index] = self.0[(table.0[index] & 0x0f) as usize] result[index] = self.0[(indices.0[index] & 0x0f) as usize]
} }
U8x16(result) U8x16(result)
} }