Skip to content

Commit fdee059

Browse files
Add 'library/portable-simd/' from commit '1ce1c645cf27c4acdefe6ec8a11d1f0491954a99'
git-subtree-dir: library/portable-simd git-subtree-mainline: efd0483 git-subtree-split: 1ce1c64
2 parents efd0483 + 1ce1c64 commit fdee059

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+7502
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
name: Blank Issue
3+
about: Create a blank issue.
4+
---
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: Bug Report
3+
about: Create a bug report for Rust.
4+
labels: C-bug
5+
---
6+
<!--
7+
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
8+
along with any information you feel relevant to replicating the bug.
9+
-->
10+
11+
I tried this code:
12+
13+
```rust
14+
<code>
15+
```
16+
17+
I expected to see this happen: *explanation*
18+
19+
Instead, this happened: *explanation*
20+
21+
### Meta
22+
23+
`rustc --version --verbose`:
24+
```
25+
<version>
26+
```
27+
28+
29+
`crate version in Cargo.toml`:
30+
```toml
31+
[dependencies]
32+
stdsimd =
33+
```
34+
<!-- If this specifies the repo at HEAD, please include the latest commit. -->
35+
36+
37+
<!--
38+
If a backtrace is available, please include a backtrace in the code block by
39+
setting `RUST_BACKTRACE=1` in your environment. e.g.
40+
`RUST_BACKTRACE=1 cargo build`.
41+
-->
42+
<details><summary>Backtrace</summary>
43+
<p>
44+
45+
```
46+
<backtrace>
47+
```
48+
49+
</p>
50+
</details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This only controls whether a tiny, hard-to-find "open a blank issue" link appears at the end of
2+
# the template list.
3+
blank_issues_enabled: true
4+
contact_links:
5+
- name: Intrinsic Support
6+
url: https://github.com/rust-lang/stdarch/issues
7+
about: Please direct issues about Rust's support for vendor intrinsics to core::arch
8+
- name: Internal Compiler Error
9+
url: https://github.com/rust-lang/rust/issues
10+
about: Please report ICEs to the rustc repository
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Feature Request
3+
about: Request an addition to the core::simd API
4+
labels: C-feature-request
5+
---
6+
<!--
7+
Hello!
8+
9+
We are very interested in any feature requests you may have.
10+
11+
However, please be aware that core::simd exists to address concerns with creating a portable SIMD API for Rust.
12+
Requests for extensions to compiler features, such as `target_feature`, binary versioning for SIMD APIs, or
13+
improving specific compilation issues in general should be discussed at https://internals.rust-lang.org/
14+
-->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Hello, welcome to `std::simd`!
2+
3+
It seems this pull request template checklist was created while a lot of vector math ops were being implemented, and only really applies to ops. Feel free to delete everything here if it's not applicable, or ask for help if you're not sure what it means!
4+
5+
For a given vector math operation on TxN, please add tests for interactions with:
6+
- [ ] `T::MAX`
7+
- [ ] `T::MIN`
8+
- [ ] -1
9+
- [ ] 1
10+
- [ ] 0
11+
12+
13+
For a given vector math operation on TxN where T is a float, please add tests for test interactions with:
14+
- [ ] a really large number, larger than the mantissa
15+
- [ ] a really small "subnormal" number
16+
- [ ] NaN
17+
- [ ] Infinity
18+
- [ ] Negative Infinity
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
env:
10+
CARGO_NET_RETRY: 10
11+
RUSTUP_MAX_RETRIES: 10
12+
13+
jobs:
14+
rustfmt:
15+
name: "rustfmt"
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Setup Rust
21+
run: |
22+
rustup update nightly --no-self-update
23+
rustup default nightly
24+
rustup component add rustfmt
25+
- name: Run rustfmt
26+
run: cargo fmt --all -- --check
27+
28+
clippy:
29+
name: "clippy on ${{ matrix.target }}"
30+
runs-on: ubuntu-latest
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
target:
35+
# We shouldn't really have any OS-specific code, so think of this as a list of architectures
36+
- x86_64-unknown-linux-gnu
37+
- i686-unknown-linux-gnu
38+
- i586-unknown-linux-gnu
39+
- aarch64-unknown-linux-gnu
40+
- armv7-unknown-linux-gnueabihf
41+
- mips-unknown-linux-gnu
42+
- mips64-unknown-linux-gnuabi64
43+
- powerpc-unknown-linux-gnu
44+
- powerpc64-unknown-linux-gnu
45+
- riscv64gc-unknown-linux-gnu
46+
- s390x-unknown-linux-gnu
47+
- sparc64-unknown-linux-gnu
48+
- wasm32-unknown-unknown
49+
50+
steps:
51+
- uses: actions/checkout@v2
52+
- name: Setup Rust
53+
run: |
54+
rustup update nightly --no-self-update
55+
rustup default nightly
56+
rustup target add ${{ matrix.target }}
57+
rustup component add clippy
58+
- name: Run Clippy
59+
run: cargo clippy --all-targets --target ${{ matrix.target }}
60+
61+
x86-tests:
62+
name: "${{ matrix.target_feature }} on ${{ matrix.target }}"
63+
runs-on: ${{ matrix.os }}
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, i586-pc-windows-msvc, x86_64-unknown-linux-gnu, x86_64-apple-darwin]
68+
# `default` means we use the default target config for the target,
69+
# `native` means we run with `-Ctarget-cpu=native`, and anything else is
70+
# an arg to `-Ctarget-feature`
71+
target_feature: [default, native, +sse3, +ssse3, +sse4.1, +sse4.2, +avx, +avx2]
72+
73+
exclude:
74+
# The macos runners seem to only reliably support up to `avx`.
75+
- { target: x86_64-apple-darwin, target_feature: +avx2 }
76+
# These features are statically known to be present for all 64 bit
77+
# macs, and thus are covered by the `default` test
78+
- { target: x86_64-apple-darwin, target_feature: +sse3 }
79+
- { target: x86_64-apple-darwin, target_feature: +ssse3 }
80+
# -Ctarget-cpu=native sounds like bad-news if target != host
81+
- { target: i686-pc-windows-msvc, target_feature: native }
82+
- { target: i586-pc-windows-msvc, target_feature: native }
83+
84+
include:
85+
# Populate the `matrix.os` field
86+
- { target: x86_64-apple-darwin, os: macos-latest }
87+
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
88+
- { target: x86_64-pc-windows-msvc, os: windows-latest }
89+
- { target: i686-pc-windows-msvc, os: windows-latest }
90+
- { target: i586-pc-windows-msvc, os: windows-latest }
91+
92+
# These are globally available on all the other targets.
93+
- { target: i586-pc-windows-msvc, target_feature: +sse, os: windows-latest }
94+
- { target: i586-pc-windows-msvc, target_feature: +sse2, os: windows-latest }
95+
96+
# Annoyingly, the x86_64-unknown-linux-gnu runner *almost* always has
97+
# avx512vl, but occasionally doesn't. Maybe one day we can enable it.
98+
99+
steps:
100+
- uses: actions/checkout@v2
101+
- name: Setup Rust
102+
run: |
103+
rustup update nightly --no-self-update
104+
rustup default nightly
105+
rustup target add ${{ matrix.target }}
106+
107+
- name: Configure RUSTFLAGS
108+
shell: bash
109+
run: |
110+
case "${{ matrix.target_feature }}" in
111+
default)
112+
echo "RUSTFLAGS=-Dwarnings" >> $GITHUB_ENV;;
113+
native)
114+
echo "RUSTFLAGS=-Dwarnings -Ctarget-cpu=native" >> $GITHUB_ENV
115+
;;
116+
*)
117+
echo "RUSTFLAGS=-Dwarnings -Ctarget-feature=${{ matrix.target_feature }}" >> $GITHUB_ENV
118+
;;
119+
esac
120+
121+
# Super useful for debugging why a SIGILL occurred.
122+
- name: Dump target configuration and support
123+
run: |
124+
rustc -Vv
125+
126+
echo "Caveat: not all target features are expected to be logged"
127+
128+
echo "## Requested target configuration (RUSTFLAGS=$RUSTFLAGS)"
129+
rustc --print=cfg --target=${{ matrix.target }} $RUSTFLAGS
130+
131+
echo "## Supported target configuration for --target=${{ matrix.target }}"
132+
rustc --print=cfg --target=${{ matrix.target }} -Ctarget-cpu=native
133+
134+
echo "## Natively supported target configuration"
135+
rustc --print=cfg -Ctarget-cpu=native
136+
137+
- name: Test (debug)
138+
run: cargo test --verbose --target=${{ matrix.target }}
139+
140+
- name: Test (release)
141+
run: cargo test --verbose --target=${{ matrix.target }} --release
142+
143+
wasm-tests:
144+
name: "wasm (firefox, ${{ matrix.name }})"
145+
runs-on: ubuntu-latest
146+
strategy:
147+
matrix:
148+
include:
149+
- { name: default, RUSTFLAGS: "" }
150+
- { name: simd128, RUSTFLAGS: "-C target-feature=+simd128" }
151+
steps:
152+
- uses: actions/checkout@v2
153+
- name: Setup Rust
154+
run: |
155+
rustup update nightly --no-self-update
156+
rustup default nightly
157+
- name: Install wasm-pack
158+
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
159+
- name: Test (debug)
160+
run: wasm-pack test --firefox --headless crates/core_simd
161+
env:
162+
RUSTFLAGS: ${{ matrix.rustflags }}
163+
- name: Test (release)
164+
run: wasm-pack test --firefox --headless crates/core_simd --release
165+
env:
166+
RUSTFLAGS: ${{ matrix.rustflags }}
167+
168+
cross-tests:
169+
name: "${{ matrix.target }} (via cross)"
170+
runs-on: ubuntu-latest
171+
strategy:
172+
fail-fast: false
173+
# TODO: Sadly, we cant configure target-feature in a meaningful way
174+
# because `cross` doesn't tell qemu to enable any non-default cpu
175+
# features, nor does it give us a way to do so.
176+
#
177+
# Ultimately, we'd like to do something like [rust-lang/stdarch][stdarch].
178+
# This is a lot more complex... but in practice it's likely that we can just
179+
# snarf the docker config from around [here][1000-dockerfiles].
180+
#
181+
# [stdarch]: https://github.com/rust-lang/stdarch/blob/a5db4eaf/.github/workflows/main.yml#L67
182+
# [1000-dockerfiles]: https://github.com/rust-lang/stdarch/tree/a5db4eaf/ci/docker
183+
184+
matrix:
185+
target:
186+
- i586-unknown-linux-gnu
187+
# 32-bit arm has a few idiosyncracies like having subnormal flushing
188+
# to zero on by default. Ideally we'd set
189+
- armv7-unknown-linux-gnueabihf
190+
- aarch64-unknown-linux-gnu
191+
# Note: The issue above means neither of these mips targets will use
192+
# MSA (mips simd) but MIPS uses a nonstandard binary representation
193+
# for NaNs which makes it worth testing on despite that.
194+
- mips-unknown-linux-gnu
195+
- mips64-unknown-linux-gnuabi64
196+
- riscv64gc-unknown-linux-gnu
197+
# TODO this test works, but it appears to time out
198+
# - powerpc-unknown-linux-gnu
199+
# TODO this test is broken, but it appears to be a problem with QEMU, not us.
200+
# - powerpc64le-unknown-linux-gnu
201+
# TODO enable this once a new version of cross is released
202+
# - powerpc64-unknown-linux-gnu
203+
204+
steps:
205+
- uses: actions/checkout@v2
206+
- name: Setup Rust
207+
run: |
208+
rustup update nightly --no-self-update
209+
rustup default nightly
210+
rustup target add ${{ matrix.target }}
211+
rustup component add rust-src
212+
213+
- name: Install Cross
214+
# Equivalent to `cargo install cross`, but downloading a prebuilt
215+
# binary. Ideally we wouldn't hardcode a version, but the version number
216+
# being part of the tarball means we can't just use the download/latest
217+
# URL :(
218+
run: |
219+
CROSS_URL=https://github.com/rust-embedded/cross/releases/download/v0.2.1/cross-v0.2.1-x86_64-unknown-linux-gnu.tar.gz
220+
mkdir -p "$HOME/.bin"
221+
curl -sfSL --retry-delay 10 --retry 5 "${CROSS_URL}" | tar zxf - -C "$HOME/.bin"
222+
echo "$HOME/.bin" >> $GITHUB_PATH
223+
224+
- name: Test (debug)
225+
run: cross test --verbose --target=${{ matrix.target }}
226+
227+
- name: Test (release)
228+
run: cross test --verbose --target=${{ matrix.target }} --release
229+
230+
features:
231+
name: "Check cargo features (${{ matrix.simd }} × ${{ matrix.features }})"
232+
runs-on: ubuntu-latest
233+
strategy:
234+
fail-fast: false
235+
matrix:
236+
simd:
237+
- ""
238+
- "avx512"
239+
features:
240+
- ""
241+
- "--features std"
242+
- "--features generic_const_exprs"
243+
- "--features std --features generic_const_exprs"
244+
245+
steps:
246+
- uses: actions/checkout@v2
247+
- name: Setup Rust
248+
run: |
249+
rustup update nightly --no-self-update
250+
rustup default nightly
251+
- name: Detect AVX512
252+
run: echo "CPU_FEATURE=$(lscpu | grep -o avx512[a-z]* | sed s/avx/+avx/ | tr '\n' ',' )" >> $GITHUB_ENV
253+
- name: Check build
254+
if: ${{ matrix.simd == '' }}
255+
run: RUSTFLAGS="-Dwarnings" cargo check --all-targets --no-default-features ${{ matrix.features }}
256+
- name: Check AVX
257+
if: ${{ matrix.simd == 'avx512' && contains(env.CPU_FEATURE, 'avx512') }}
258+
run: |
259+
echo "Found AVX features: $CPU_FEATURE"
260+
RUSTFLAGS="-Dwarnings -Ctarget-feature=$CPU_FEATURE" cargo check --all-targets --no-default-features ${{ matrix.features }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
name: Deploy Documentation
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v1
16+
17+
- name: Setup Rust
18+
run: |
19+
rustup update nightly --no-self-update
20+
rustup default nightly
21+
22+
- name: Build Documentation
23+
run: cargo doc --no-deps
24+
25+
- name: Deploy Documentation
26+
uses: peaceiris/actions-gh-pages@v3
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
publish_branch: gh-pages
30+
publish_dir: ./target/doc

library/portable-simd/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
Cargo.lock

0 commit comments

Comments
 (0)