Commit Graph

94 Commits

Author SHA1 Message Date
Folkert de Vries 6abb95cc00 gate use of wasm_target_feature on wasm target arch 2026-03-06 14:09:59 +01:00
Brian Cain d6b2cb08a8 examples: Make gaussian build on all targets
Restructure gaussian.rs to follow the pattern used by hex.rs and
connect5.rs.

Remove the 'hexagon' feature gate.
2026-02-15 07:10:55 -06:00
Brian Cain be9dc99118 examples: Use HvxVectorPair for precise Gaussian blur arithmetic
Update the Gaussian 3x3 blur example to use HvxVectorPair widening
operations. This demonstrates that HvxVectorPair intrinsics now work
 correctly with the updated nightly.

- Add #![cfg(target_arch = "hexagon")] crate-level gate
2026-02-15 07:01:00 -06:00
Brian Cain 5b7ab682b4 examples: Simplify gaussian.rs with cfg gate
Add `#![cfg(target_arch = "hexagon")]`

- Remove redundant #[cfg(target_arch = "hexagon")] from functions
- Simplify import and constant cfg conditions
- Remove non-Hexagon test code branch from main()
2026-02-12 11:41:57 -06:00
Brian Cain eb6bbfa830 examples: Fix rustfmt formatting in gaussian.rs 2026-02-12 07:47:01 -06:00
Brian Cain 736af97d6c examples: Add assertions to gaussian example
Replace print statements with assertions that verify the Gaussian 3x3
blur implementation against the Hexagon SDK reference algorithm.

- Port exact SDK Gaussian3x3u8 implementation from:
  /opt/Hexagon_SDK/.../Examples/HVX/gaussian/src/gaussian.c
- Verify specific output values [15, 16, 17, 18, 19, 20, 21, 22]
  for row 2, cols 1..9 with test pattern ((x + y*7) % 256)
- Assert byte-averaging approximation exactly matches SDK reference
- On Hexagon: verify HVX output matches both scalar approximation
  and SDK reference exactly
2026-02-12 07:33:16 -06:00
Brian Cain 2b710f1a45 Switched to 64b and 128b crate definitions 2026-02-12 07:33:16 -06:00
Brian Cain 0a662d0f72 arch: Add Hexagon HVX instructions 2026-02-12 07:33:16 -06:00
Tsukasa OI 05133f2115 examples: Make Clippy happy 2025-09-12 11:51:38 +00:00
Jakub Beránek 8f0ffa8125 Reformat code 2025-07-23 15:01:42 +02:00
Jakub Beránek 608297247a Remove std_detect from stdarch examples 2025-07-22 20:22:16 +02:00
Marijn Schouten beb1b7d1a8 connect5: clippy fixes 2025-07-11 16:54:07 +00:00
Amanieu d'Antras 68c0308cbe Stabilize AVX512 intrinsics
FCP completed in tracking issue rust-lang/rust#111137
2025-06-02 19:45:44 +00:00
Tsukasa OI c5693ed5e4 stdarch_examples: Modernization of the coding style
It modernizes the coding style of the crate stdarch_examples (an example
"connect5") by fixing Clippy warnings (except clippy::manual_range_contains
in which "fixing" the warning will complicate the code).

Clippy: rust version 1.89.0-nightly (6f6971078 2025-05-28)
Number of Fixed Warnings: 6/6
2025-05-31 09:38:49 +00:00
Folkert de Vries a850e8738a avx512_target_feature is now stable on nightly 2025-05-20 14:26:46 +00:00
Eduardo Sánchez Muñoz b8d25bdefa Remove some allow(unsafe_op_in_unsafe_fn)s and use target_feature 1.1 in examples 2025-02-25 01:11:47 +00:00
Eric Huss d9ec0157da Format with style edition 2024 2025-02-09 12:57:14 -08:00
Eric Huss 699a872630 Update all crates to Rust 2024 2025-02-09 12:31:33 -08:00
Eric Huss 844a604bf0 Allow unsafe_op_in_unsafe_fn
Because stdarch has a really large number of unsafe functions with
single-line calls, `unsafe_op_in_unsafe_fn` would end up adding a lot of
noise, so for now we will allow it to migrate to 2024.
2025-02-09 12:31:30 -08:00
Eric Huss 2d74744885 Apply unsafe_attr_outside_unsafe 2025-02-09 10:53:07 -08:00
Eric Huss 6040773b55 Apply keyword_idents_2024 2025-02-09 09:48:01 -08:00
Eduardo Sánchez Muñoz 21300c20e4 Simplify some code in examples 2024-11-29 23:37:33 +00:00
Yuri Astrakhan 442e492d1f Clean up examples, make it more "Rusty" 2024-10-01 04:40:25 -04:00
Amanieu d'Antras 76d52cdd68 Fix std_detect not being an unstable crate
More fallout from #1486
2024-01-05 11:14:38 +00:00
Eduardo Sánchez Muñoz 57479f8c9b Remove unneeded borrows 2023-11-18 20:28:46 -08:00
Amanieu d'Antras ea27e5cfcb Fix various compilation errors 2023-10-29 20:39:50 +01:00
Amanieu d'Antras b8ba57f310 Cleanup last uses of the stdsimd feature 2023-10-29 20:39:50 +01:00
Eduardo Sánchez Muñoz 217049ccce Bump rand to 0.8 2023-10-10 14:47:43 +01:00
Eduardo Sánchez Muñoz 3a24d406de Bump quickcheck to 1.0 2023-10-10 14:47:43 +01:00
Bruce Mitchener 5c4a950591 docs: Fix warnings and typos.
* Fix typo in HTML tag
* Mark some things with backticks to fix warnings about
  unescaped square brackets.
* Spell "initialize" correctly to fix typos.
2023-07-30 10:57:20 +01:00
Yuri Astrakhan 81c221f058 Edition 2021, apply clippy::uninlined_format_args fix (#1339) 2022-10-25 20:17:23 +01:00
Maybe Waffle 1a2eac5986 Replace some calls to pointer::offset with add and sub 2022-08-22 22:41:21 +02:00
Alex Crichton 79140b43ea wasm: Mark simd intrinsics as stable (#1179) 2021-06-10 20:32:39 +01:00
Alex Crichton 4d6fa80bb3 wasm: Add convenience aliases with unsigned names (#1174)
Naming right now for wasm simd intrinsics takes the signededness of the
instruction into account, but some operations are the same regardless of
signededness, such as `i32x4_add`. This commit adds aliases for all of
these operations under unsigned names as well (such as `u32x4_add`)
which are just a `pub use` to rename the item as two names. The goal of
this is to assist in reading code (no need to switch back and forth
between `i` and `u`) as well as writing code (no need to always remember
which operations are the same for signed/unsigned but only available
under the signed names).
2021-05-27 16:52:15 +01:00
Alex Crichton 3bbb381ac1 Tweak names of wasm SIMD intrinsics (#1096) 2021-03-25 15:11:30 +00:00
Alex Crichton e35da555f8 Update WebAssembly SIMD/Atomics (#1073) 2021-03-11 23:30:30 +00:00
minybot 981e250f89 Avx512vbmi (#977) 2021-01-04 00:35:51 +00:00
minybot 74c3d97374 avx512f example (#952) 2020-12-25 23:42:42 +00:00
Joshua Nelson 33355e69c2 Fix some clippy lints (#937) 2020-11-02 00:53:39 +00:00
Alex Crichton 770964adac Update and revamp wasm32 SIMD intrinsics (#874)
Lots of time and lots of things have happened since the simd128 support
was first added to this crate. Things are starting to settle down now so
this commit syncs the Rust intrinsic definitions with the current
specification (https://github.com/WebAssembly/simd). Unfortuantely not
everything can be enabled just yet but everything is in the pipeline for
getting enabled soon.

This commit also applies a major revamp to how intrinsics are tested.
The intention is that the setup should be much more lightweight and/or
easy to work with after this commit.

At a high-level, the changes here are:

* Testing with node.js and `#[wasm_bindgen]` has been removed. Instead
  intrinsics are tested with Wasmtime which has a nearly complete
  implementation of the SIMD spec (and soon fully complete!)

* Testing is switched to `wasm32-wasi` to make idiomatic Rust bits a bit
  easier to work with (e.g. `panic!)`

* Testing of this crate's simd128 feature for wasm is re-enabled. This
  will run on CI and both compile and execute intrinsics. This should
  bring wasm intrinsics to the same level of parity as x86 intrinsics,
  for example.

* New wasm intrinsics have been added:
  * `iNNxMM_loadAxA_{s,u}`
  * `vNNxMM_load_splat`
  * `v8x16_swizzle`
  * `v128_andnot`
  * `iNNxMM_abs`
  * `iNNxMM_narrow_*_{u,s}`
  * `iNNxMM_bitmask` - commented out until LLVM is updated to LLVM 11
  * `iNNxMM_widen_*_{u,s}` - commented out until
    bytecodealliance/wasmtime#1994 lands
  * `iNNxMM_{max,min}_{u,s}`
  * `iNNxMM_avgr_u`

* Some wasm intrinsics have been removed:
  * `i64x2_trunc_*`
  * `f64x2_convert_*`
  * `i8x16_mul`

* The `v8x16.shuffle` instruction is exposed. This is done through a
  `macro` (not `macro_rules!`, but `macro`). This is intended to be
  somewhat experimental and unstable until we decide otherwise. This
  instruction has 16 immediate-mode expressions and is as a result
  unsuited to the existing `constify_*` logic of this crate. I'm hoping
  that we can game out over time what a macro might look like and/or
  look for better solutions. For now, though, what's implemented is the
  first of its kind in this crate (an architecture-specific macro), so
  some extra scrutiny looking at it would be appreciated.

* Lots of `assert_instr` annotations have been fixed for wasm.

* All wasm simd128 tests are uncommented and passing now.

This is still missing tests for new intrinsics and it's also missing
tests for various corner cases. I hope to get to those later as the
upstream spec itself gets closer to stabilization.

In the meantime, however, I went ahead and updated the `hex.rs` example
with a wasm implementation using intrinsics. With it I got some very
impressive speedups using Wasmtime:

    test benches::large_default  ... bench:     213,961 ns/iter (+/- 5,108) = 4900 MB/s
    test benches::large_fallback ... bench:   3,108,434 ns/iter (+/- 75,730) = 337 MB/s
    test benches::small_default  ... bench:          52 ns/iter (+/- 0) = 2250 MB/s
    test benches::small_fallback ... bench:         358 ns/iter (+/- 0) = 326 MB/s

or otherwise using Wasmtime hex encoding using SIMD is 15x faster on 1MB
chunks or 7x faster on small <128byte chunks.

All of these intrinsics are still unstable and will continue to be so
presumably until the simd proposal in wasm itself progresses to a later
stage. Additionaly we'll still want to sync with clang on intrinsic
names (or decide not to) at some point in the future.

* wasm: Unconditionally expose SIMD functions

This commit unconditionally exposes SIMD functions from the `wasm32`
module. This is done in such a way that the standard library does not
need to be recompiled to access SIMD intrinsics and use them. This,
hopefully, is the long-term story for SIMD in WebAssembly in Rust.

It's unlikely that all WebAssembly runtimes will end up implementing
SIMD so the standard library is unlikely to use SIMD any time soon, but
we want to make sure it's easily available to folks! This commit enables
all this by ensuring that SIMD is available to the standard library,
regardless of compilation flags.

This'll come with the same caveats as x86 support, where it doesn't make
sense to call these functions unless you're enabling simd support one
way or another locally. Additionally, as with x86, if you don't call
these functions then the instructions won't show up in your binary.

While I was here I went ahead and expanded the WebAssembly-specific
documentation for the wasm32 module as well, ensuring that the current
state of SIMD/Atomics are documented.
2020-07-18 13:32:52 +01:00
Linus Färnstrand f14b746319 Replace all max/min_value() with MAX/MIN 2020-04-04 09:51:11 -07:00
gnzlbg 686b813f5d Update repo name 2019-07-09 01:37:07 +02:00
dependabot-preview[bot] deb328f6c6 Update rand requirement from 0.6 to 0.7
Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version.
- [Release notes](https://github.com/rust-random/rand/releases)
- [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-01 11:59:44 +02:00
gnzlbg 173dd11427 Merge imports 2019-04-19 11:34:01 +02:00
gnzlbg 459afa7a59 Fix clippy issues 2019-04-17 14:20:42 +02:00
gnzlbg d5ef055ba9 Fix building docs for all targets on docs.rs and re-export the arch module 2019-01-30 13:46:41 +01:00
gnzlbg 5f7006df5a Fix clippy issues 2019-01-22 19:23:32 +01:00
gnzlbg 11c624e488 Refactor stdsimd
This commit:

* renames `coresimd` to `core_arch` and `stdsimd` to `std_detect`

* `std_detect` does no longer depend on `core_arch` - it is a freestanding
  `no_std` library that only depends on `core` - it is renamed to `std_detect`

* moves the top-level coresimd and stdsimd directories into the appropriate
  crates/... directories - this simplifies creating crate.io releases of these crates

* moves the top-level `coresimd` and `stdsimd` sub-directories into their
  corresponding crates in `crates/{core_arch, std_detect}`.
2019-01-22 17:04:25 +01:00
Alex Crichton 5a45175fe1 Run rustfmt on stable, delete rustfmt.toml (#619)
This commit switches CI to running `rustfmt` on the stable compiler (as
rustfmt is stable now!). Additionally it deletes `rustfmt.toml` to
ensure we're following the same style as the rest of the ecosystem.
2018-12-13 17:26:22 -06:00
Alex Crichton 80a3099792 Another fix for wasm example 2018-12-12 13:02:58 -08:00