Skip to content

Commit 1e870c2

Browse files
committed
Removed nightly feature flag now that neon intrinsics are (sort of) stable
Note, neon still requires a nightly compiler to enable, this just means we don't need an explicit flag to detect this. And this code should "just work" when neon becomes stable. The state of things is a bit confusing. SIMD in Rust: rust-lang/rust#48556 NEON in Rust: rust-lang/rust#90972
1 parent 83c44d3 commit 1e870c2

File tree

13 files changed

+46
-80
lines changed

13 files changed

+46
-80
lines changed

Cargo.toml

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@ description = "A Rust library containing Galois-field types and utilities"
44
authors = ["Christopher Haster <[email protected]>"]
55
repository = "https://github.com/geky/gf256"
66
version = "0.2.0"
7-
edition = "2018"
7+
edition = "2021"
88
license = "BSD-3-Clause"
99

1010
[features]
11-
# Enables features only found on a nightly compiler
12-
#
13-
# This is required to leverage pmull on aarch64, tracking issue:
14-
# https://github.com/rust-lang/rust/issues/48556
15-
#
16-
nightly = []
17-
1811
# Disable carry-less multiplication instructions, forcing the use
1912
# of naive bitwise implementations
2013
#

Makefile

+34-35
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,58 @@
22
override RUSTFLAGS += -Ctarget-cpu=native
33

44
# this indirection is so commands with env are easily copied on the terminal
5-
override ENV += RUSTFLAGS="$(RUSTFLAGS)"
5+
CARGO ?= RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly
66

77
.PHONY: all build
88
all build:
9-
$(ENV) cargo +nightly build --features nightly,thread-rng,lfsr,crc,shamir,raid,rs
9+
$(CARGO) build --features thread-rng,lfsr,crc,shamir,raid,rs
1010

1111
.PHONY: test
1212
test:
13-
$(ENV) cargo +nightly test --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --lib
14-
$(ENV) cargo +nightly test --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example find-p
15-
$(ENV) cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example find-p -- -w9 -n4 -m1 -q
16-
$(ENV) cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example lfsr
17-
$(ENV) cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example crc
18-
$(ENV) cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example shamir
19-
$(ENV) cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example raid
20-
$(ENV) cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example rs
13+
$(CARGO) test --features thread-rng,lfsr,crc,shamir,raid,rs --lib
14+
$(CARGO) test --features thread-rng,lfsr,crc,shamir,raid,rs --example find-p
15+
$(CARGO) run --features thread-rng,lfsr,crc,shamir,raid,rs --example find-p -- -w9 -n4 -m1 -q
16+
$(CARGO) run --features thread-rng,lfsr,crc,shamir,raid,rs --example lfsr
17+
$(CARGO) run --features thread-rng,lfsr,crc,shamir,raid,rs --example crc
18+
$(CARGO) run --features thread-rng,lfsr,crc,shamir,raid,rs --example shamir
19+
$(CARGO) run --features thread-rng,lfsr,crc,shamir,raid,rs --example raid
20+
$(CARGO) run --features thread-rng,lfsr,crc,shamir,raid,rs --example rs
2121

2222
.PHONY: test-configs
2323
test-configs:
24-
$(ENV) cargo test --lib
25-
$(ENV) cargo test --features thread-rng,lfsr,crc,shamir,raid,rs --lib
26-
$(ENV) cargo test --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --lib
27-
$(ENV) cargo test --features no-tables,thread-rng,lfsr,crc,shamir,raid,rs --lib
28-
$(ENV) cargo test --features small-tables,thread-rng,lfsr,crc,shamir,raid,rs --lib
29-
$(ENV) cargo +nightly test --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --lib
24+
$(CARGO) test --lib
25+
$(CARGO) test --features thread-rng,lfsr,crc,shamir,raid,rs --lib
26+
$(CARGO) test --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --lib
27+
$(CARGO) test --features no-tables,thread-rng,lfsr,crc,shamir,raid,rs --lib
28+
$(CARGO) test --features small-tables,thread-rng,lfsr,crc,shamir,raid,rs --lib
3029

3130
.PHONY: docs
3231
docs:
33-
$(ENV) cargo +nightly doc --no-deps --features nightly,thread-rng,lfsr,crc,shamir,raid,rs
34-
$(ENV) cargo +nightly test --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --doc
32+
$(CARGO) doc --no-deps --features thread-rng,lfsr,crc,shamir,raid,rs
33+
$(CARGO) test --features thread-rng,lfsr,crc,shamir,raid,rs --doc
3534

3635
.PHONY: bench
3736
bench:
38-
$(ENV) cargo +nightly bench --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --bench xmul -- --noplot
39-
$(ENV) cargo +nightly bench --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --bench gf -- --noplot
40-
$(ENV) cargo +nightly bench --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --bench find-p -- --noplot
41-
$(ENV) cargo +nightly bench --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --bench lfsr -- --noplot
42-
$(ENV) cargo +nightly bench --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --bench crc -- --noplot
43-
$(ENV) cargo +nightly bench --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --bench shamir -- --noplot
44-
$(ENV) cargo +nightly bench --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --bench raid -- --noplot
45-
$(ENV) cargo +nightly bench --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --bench rs -- --noplot
37+
$(CARGO) bench --features thread-rng,lfsr,crc,shamir,raid,rs --bench xmul -- --noplot
38+
$(CARGO) bench --features thread-rng,lfsr,crc,shamir,raid,rs --bench gf -- --noplot
39+
$(CARGO) bench --features thread-rng,lfsr,crc,shamir,raid,rs --bench find-p -- --noplot
40+
$(CARGO) bench --features thread-rng,lfsr,crc,shamir,raid,rs --bench lfsr -- --noplot
41+
$(CARGO) bench --features thread-rng,lfsr,crc,shamir,raid,rs --bench crc -- --noplot
42+
$(CARGO) bench --features thread-rng,lfsr,crc,shamir,raid,rs --bench shamir -- --noplot
43+
$(CARGO) bench --features thread-rng,lfsr,crc,shamir,raid,rs --bench raid -- --noplot
44+
$(CARGO) bench --features thread-rng,lfsr,crc,shamir,raid,rs --bench rs -- --noplot
4645

4746
.PHONY: bench-no-xmul
4847
bench-no-xmul:
49-
$(ENV) cargo +nightly bench --features nightly,no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench xmul -- --noplot
50-
$(ENV) cargo +nightly bench --features nightly,no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench gf -- --noplot
51-
$(ENV) cargo +nightly bench --features nightly,no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench find-p -- --noplot
52-
$(ENV) cargo +nightly bench --features nightly,no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench lfsr -- --noplot
53-
$(ENV) cargo +nightly bench --features nightly,no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench crc -- --noplot
54-
$(ENV) cargo +nightly bench --features nightly,no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench shamir -- --noplot
55-
$(ENV) cargo +nightly bench --features nightly,no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench raid -- --noplot
56-
$(ENV) cargo +nightly bench --features nightly,no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench rs -- --noplot
48+
$(CARGO) bench --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench xmul -- --noplot
49+
$(CARGO) bench --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench gf -- --noplot
50+
$(CARGO) bench --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench find-p -- --noplot
51+
$(CARGO) bench --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench lfsr -- --noplot
52+
$(CARGO) bench --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench crc -- --noplot
53+
$(CARGO) bench --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench shamir -- --noplot
54+
$(CARGO) bench --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench raid -- --noplot
55+
$(CARGO) bench --features no-xmul,thread-rng,lfsr,crc,shamir,raid,rs --bench rs -- --noplot
5756

5857
.PHONY: clean
5958
clean:
60-
$(ENV) cargo clean
59+
$(CARGO) clean

README.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ assert_ne!(a + a, gf256(2)*a);
151151
Finite-fields can be very useful for applying high-level math onto machine
152152
words, since machine words (`u8`, `u16`, `u32`, etc) are inherently finite.
153153
Normally we just ignore this until an integer overflow occurs and then we just
154-
waive our hands around wailing that math has failed us.
154+
wave our hands around wailing that math has failed us.
155155

156156
In Rust this has the fun side-effect that the Galois-field types are incapable
157157
of overflowing, so Galois-field types don't need the set of overflowing
@@ -331,8 +331,6 @@ Carry-less multiplication:
331331

332332
gf256 takes advantage of these instructions when possible. However, at the time
333333
of writing, `pmull` support in Rust is only available on [nightly][nightly].
334-
To take advantage of `pmull` on aarch64 you will need to use a nightly compiler
335-
and enable gf256's `nightly` feature ([tracking issue](https://github.com/rust-lang/rust/issues/48556)).
336334

337335
``` rust
338336
# use ::gf256::*;
@@ -358,7 +356,7 @@ let b = if gf256::HAS_XMUL {
358356
};
359357
```
360358

361-
gf256 also leverages the hardware accelrated [carry-less addition][xor]
359+
gf256 also leverages the hardware accelerated [carry-less addition][xor]
362360
instructions, sometimes called polynomial addition, or simply xor. But this
363361
is much less notable.
364362

@@ -445,10 +443,6 @@ evaluated before use, and you use this library at your own risk.
445443

446444
## Features
447445

448-
- `nightly` - Enable features only found on a nightly compiler
449-
450-
This is required to leverage `pmull` on aarch64 ([tracking issue](https://github.com/rust-lang/rust/issues/48556))
451-
452446
- `no-xmul` - Disables carry-less multiplication instructions, forcing the use
453447
of naive bitwise implementations
454448

@@ -459,7 +453,7 @@ evaluated before use, and you use this library at your own risk.
459453

460454
This may be useful on memory constrained devices
461455

462-
- `small-tables` - Limits lookup tables to "small tables", tables with <16
456+
- `small-tables` - Limits lookup tables to "small tables", tables with <=16
463457
elements
464458

465459
This provides a compromise between full 256-byte tables and no-tables,

gf256-macros/src/common.rs

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pub(crate) fn xmul_predicate() -> TokenStream {
3636
target_feature="pclmulqdq"
3737
),
3838
all(
39-
feature="nightly",
4039
target_arch="aarch64",
4140
target_feature="neon"
4241
)

src/crc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! [`examples/crc.rs`][crc-example]:
2222
//!
2323
//! ``` bash
24-
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example crc
24+
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo run --features thread-rng,lfsr,crc,shamir,raid,rs --example crc
2525
//!
2626
//! testing crc("Hello World!")
2727
//! naive_crc => 0x1c291ca3

src/gf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@
511511
//! bit-width. Note you need a 5-bit irreducible polynomial for a 4-bit field:
512512
//!
513513
//! ``` bash
514-
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo +nightly run --release --features nightly --example find-p -- --width=5 -m=1
514+
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo run --release --example find-p -- --width=5 -m=1
515515
//! polynomial=0x13, generator=0x2
516516
//! polynomial=0x19, generator=0x2
517517
//! polynomial=0x1f, generator=0x3
@@ -521,7 +521,7 @@
521521
//! their generators up to 65-bits:
522522
//!
523523
//! ``` bash
524-
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo +nightly run --release --features nightly --example find-p -- --width=65 -m=1 -n=1
524+
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo --release --example find-p -- --width=65 -m=1 -n=1
525525
//! polynomial=0x1000000000000001b, generator=0x2
526526
//! ```
527527
//!

src/lfsr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
//! [`examples/lfsr.rs`][lfsr-example]:
3030
//!
3131
//! ``` bash
32-
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example lfsr
32+
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo run --features thread-rng,lfsr,crc,shamir,raid,rs --example lfsr
3333
//!
3434
//! testing lfsr64
3535
//! lfsr64_naive => 0000000000000001000000000000001b00000000000001450000000000001db7

src/lib.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#![doc=include_str!("../README.md")]
22

33

4-
// Enable stdsimd for pmull on aarch64
5-
#![cfg_attr(
6-
all(not(feature="no-xmul"), feature="nightly", target_arch="aarch64"),
7-
feature(stdsimd)
8-
)]
9-
104
// We don't really need std
115
#![no_std]
126

src/p.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@
9696
//! implementation.
9797
//!
9898
//! Note that at the time of writing, aarch64 [`pmull`][pmull] support is only
99-
//! available on a [nightly][nightly] compiler, and requires gf256's `nightly`
100-
//! feature to be enabled ([tracking issue](https://github.com/rust-lang/rust/issues/48556)).
99+
//! available on a [nightly][nightly] compiler.
101100
//!
102101
//! gf256 also exposes the flag [`HAS_XMUL`], which can be used to choose
103102
//! algorithms based on whether or not hardware accelerated carry-less

src/raid.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
//! [`examples/raid.rs`][raid-example]:
4545
//!
4646
//! ``` bash
47-
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example raid
47+
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo run --features thread-rng,lfsr,crc,shamir,raid,rs --example raid
4848
//!
4949
//! testing raid5("Hello World?")
5050
//! format => Hello World?U)_< 48656c6c6f20576f726c643f55295f3c

src/rs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! [`examples/rs.rs`][rs-example]:
3434
//!
3535
//! ``` bash
36-
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example rs
36+
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo run --features thread-rng,lfsr,crc,shamir,raid,rs --example rs
3737
//!
3838
//! testing rs("Hello World!")
3939
//! dimension = (255,223), 16 errors, 32 erasures

src/shamir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
//! [`examples/shamir.rs`][shamir-example]:
2828
//!
2929
//! ``` bash
30-
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo +nightly run --features nightly,thread-rng,lfsr,crc,shamir,raid,rs --example shamir
30+
//! $ RUSTFLAGS="-Ctarget-cpu=native" cargo run --features thread-rng,lfsr,crc,shamir,raid,rs --example shamir
3131
//!
3232
//! testing shamir("Hello World!")
3333
//! generate share1 => .....uT4.z.O. 019ddb829d755434f77ae84ffd

src/xmul.rs

-12
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pub const HAS_XMUL: bool = {
3434
),
3535
all(
3636
not(feature="no-xmul"),
37-
feature="nightly",
3837
target_arch="aarch64",
3938
target_feature="neon"
4039
)
@@ -59,7 +58,6 @@ pub const HAS_XMUL: bool = {
5958
),
6059
all(
6160
not(feature="no-xmul"),
62-
feature="nightly",
6361
target_arch="aarch64",
6462
target_feature="neon"
6563
)
@@ -83,7 +81,6 @@ pub fn xmul8(a: u8, b: u8) -> (u8, u8) {
8381
}
8482
} else if #[cfg(all(
8583
not(feature="no-xmul"),
86-
feature="nightly",
8784
target_arch="aarch64",
8885
target_feature="neon"
8986
))] {
@@ -109,7 +106,6 @@ pub fn xmul8(a: u8, b: u8) -> (u8, u8) {
109106
),
110107
all(
111108
not(feature="no-xmul"),
112-
feature="nightly",
113109
target_arch="aarch64",
114110
target_feature="neon"
115111
)
@@ -133,7 +129,6 @@ pub fn xmul16(a: u16, b: u16) -> (u16, u16) {
133129
}
134130
} else if #[cfg(all(
135131
not(feature="no-xmul"),
136-
feature="nightly",
137132
target_arch="aarch64",
138133
target_feature="neon"
139134
))] {
@@ -159,7 +154,6 @@ pub fn xmul16(a: u16, b: u16) -> (u16, u16) {
159154
),
160155
all(
161156
not(feature="no-xmul"),
162-
feature="nightly",
163157
target_arch="aarch64",
164158
target_feature="neon"
165159
)
@@ -183,7 +177,6 @@ pub fn xmul32(a: u32, b: u32) -> (u32, u32) {
183177
}
184178
} else if #[cfg(all(
185179
not(feature="no-xmul"),
186-
feature="nightly",
187180
target_arch="aarch64",
188181
target_feature="neon"
189182
))] {
@@ -209,7 +202,6 @@ pub fn xmul32(a: u32, b: u32) -> (u32, u32) {
209202
),
210203
all(
211204
not(feature="no-xmul"),
212-
feature="nightly",
213205
target_arch="aarch64",
214206
target_feature="neon"
215207
)
@@ -234,7 +226,6 @@ pub fn xmul64(a: u64, b: u64) -> (u64, u64) {
234226
}
235227
} else if #[cfg(all(
236228
not(feature="no-xmul"),
237-
feature="nightly",
238229
target_arch="aarch64",
239230
target_feature="neon"
240231
))] {
@@ -260,7 +251,6 @@ pub fn xmul64(a: u64, b: u64) -> (u64, u64) {
260251
),
261252
all(
262253
not(feature="no-xmul"),
263-
feature="nightly",
264254
target_arch="aarch64",
265255
target_feature="neon"
266256
)
@@ -296,7 +286,6 @@ pub fn xmul128(a: u128, b: u128) -> (u128, u128) {
296286
}
297287
} else if #[cfg(all(
298288
not(feature="no-xmul"),
299-
feature="nightly",
300289
target_arch="aarch64",
301290
target_feature="neon"
302291
))] {
@@ -327,7 +316,6 @@ mod test {
327316
),
328317
all(
329318
not(feature="no-xmul"),
330-
feature="nightly",
331319
target_arch="aarch64",
332320
target_feature="neon"
333321
)

0 commit comments

Comments
 (0)