Skip to content

Commit

Permalink
Add portable simd (core::simd) implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <[email protected]>
  • Loading branch information
Licenser committed Oct 18, 2023
1 parent 38bea76 commit 0c29ff5
Show file tree
Hide file tree
Showing 8 changed files with 889 additions and 3 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ jobs:
env:
RUSTFLAGS: ${{ matrix.rustflags }}

test-portable-simd:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
features: ["", "--features std", "--features public_imp", "--features std,public_imp"]
rustflags: ["-D warnings", "-D warnings -C target-feature=+avx2", "-D warnings -C target-feature=+sse4.2"]
exclude:
- os: macos-11
rustflags: "-D warnings -C target-feature=+avx2"
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
override: true
- name: Run tests
run: cargo test --no-default-features --features portable ${{ matrix.features }} --all-targets --verbose
env:
RUSTFLAGS: ${{ matrix.rustflags }}

test-inlining-x86:
runs-on: ubuntu-latest
strategy:
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ aarch64_neon = []
# enable aarch64 prefetching for minor speedup - requires nightly
aarch64_neon_prefetch = []

# support for portable simd (nightly only)
portable = []

# deprecated - does not do anything
hints = []

Expand Down
8 changes: 8 additions & 0 deletions src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ pub mod imp {
}
}

/// Includes the portable SIMD implementations.
#[cfg(feature = "portable")]
pub mod portable {
/// Includes the validation implementation using portable SIMD.
pub use crate::implementation::portable::validate_utf8_basic as validate_utf8;
pub use crate::implementation::portable::ChunkedUtf8ValidatorImp;
pub use crate::implementation::portable::Utf8ValidatorImp;
}
/// Includes the aarch64 SIMD implementations.
#[cfg(all(feature = "aarch64_neon", target_arch = "aarch64"))]
pub mod aarch64 {
Expand Down
7 changes: 7 additions & 0 deletions src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ pub mod imp {
}
}

/// Includes the x86/x86-64 SIMD implementations.
#[cfg(feature = "portable")]
pub mod portable {
/// Includes the validation implementation for portable SIMD.
pub use crate::implementation::portable::validate_utf8_compat as validate_utf8;
}

/// Includes the aarch64 SIMD implementations.
#[cfg(all(feature = "aarch64_neon", target_arch = "aarch64"))]
pub mod aarch64 {
Expand Down
5 changes: 5 additions & 0 deletions src/implementation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type ValidateUtf8Fn = unsafe fn(input: &[u8]) -> Result<(), Utf8ErrorBasic>;
#[allow(dead_code)]
type ValidateUtf8CompatFn = unsafe fn(input: &[u8]) -> Result<(), Utf8ErrorCompat>;

// Rust Portable SIMD implementation

#[cfg(feature = "portable")]
pub(crate) mod portable;

// x86 implementation

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Expand Down
Loading

0 comments on commit 0c29ff5

Please sign in to comment.