From aaf3bdf56175cdb8ae9cfdcb8e957c75efe75f3d Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Sat, 21 Sep 2024 12:55:56 -0700 Subject: [PATCH 1/3] Fix compilation error in benchmarks --- .github/workflows/ci.yml | 3 +++ benches/codec_benchmark.rs | 10 +++++----- benches/decode_benchmark.rs | 4 ++-- benches/encode_benchmark.rs | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f55e17d..ef6449c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,9 @@ jobs: - name: Run tests run: make test + - name: Compile benchmarks + run: cargo bench --features benchmarking --no-run + - name: Run tests (no-std) run: cargo test --no-default-features diff --git a/benches/codec_benchmark.rs b/benches/codec_benchmark.rs index 5cfa829..44761ea 100644 --- a/benches/codec_benchmark.rs +++ b/benches/codec_benchmark.rs @@ -78,7 +78,7 @@ fn criterion_benchmark(c: &mut Criterion) { Benchmark::new("", move |b| { b.iter(|| { let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1); - let encoder = SourceBlockEncoder::new2(1, &config, &encode_data); + let encoder = SourceBlockEncoder::new(1, &config, &encode_data); return encoder.source_packets(); }) }) @@ -91,8 +91,8 @@ fn criterion_benchmark(c: &mut Criterion) { Benchmark::new("", move |b| { b.iter(|| { let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1); - let encoder = SourceBlockEncoder::new2(1, &config, &roundtrip_data); - let mut decoder = SourceBlockDecoder::new2(1, &config, elements as u64); + let encoder = SourceBlockEncoder::new(1, &config, &roundtrip_data); + let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64); return decoder.decode(encoder.source_packets()); }) }) @@ -105,9 +105,9 @@ fn criterion_benchmark(c: &mut Criterion) { Benchmark::new("", move |b| { b.iter(|| { let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1); - let encoder = SourceBlockEncoder::new2(1, &config, &repair_data); + let encoder = SourceBlockEncoder::new(1, &config, &repair_data); let repair_packets = (elements / symbol_size as usize) as u32; - let mut decoder = SourceBlockDecoder::new2(1, &config, elements as u64); + let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64); return decoder.decode(encoder.repair_packets(0, repair_packets)); }) }) diff --git a/benches/decode_benchmark.rs b/benches/decode_benchmark.rs index 5307d56..bc278b8 100644 --- a/benches/decode_benchmark.rs +++ b/benches/decode_benchmark.rs @@ -22,12 +22,12 @@ fn benchmark(symbol_size: u16, overhead: f64) -> u64 { let iterations = TARGET_TOTAL_BYTES / elements; let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1); - let encoder = SourceBlockEncoder::new2(1, &config, &data); + let encoder = SourceBlockEncoder::new(1, &config, &data); let elements_and_overhead = (symbol_count as f64 * (1.0 + overhead)) as u32; let mut packets = encoder.repair_packets(0, iterations as u32 * elements_and_overhead); let now = Instant::now(); for _ in 0..iterations { - let mut decoder = SourceBlockDecoder::new2(1, &config, elements as u64); + let mut decoder = SourceBlockDecoder::new(1, &config, elements as u64); let start = packets.len() - elements_and_overhead as usize; if let Some(result) = decoder.decode(packets.drain(start..)) { black_box_value += result[0] as u64; diff --git a/benches/encode_benchmark.rs b/benches/encode_benchmark.rs index 148aedc..e09b5bb 100644 --- a/benches/encode_benchmark.rs +++ b/benches/encode_benchmark.rs @@ -31,9 +31,9 @@ fn benchmark(symbol_size: u16, pre_plan: bool) -> u64 { let config = ObjectTransmissionInformation::new(0, symbol_size, 0, 1, 1); for _ in 0..iterations { let encoder = if let Some(ref plan) = plan { - SourceBlockEncoder::with_encoding_plan2(1, &config, &data, plan) + SourceBlockEncoder::with_encoding_plan(1, &config, &data, plan) } else { - SourceBlockEncoder::new2(1, &config, &data) + SourceBlockEncoder::new(1, &config, &data) }; let packets = encoder.repair_packets(0, 1); black_box_value += packets[0].data()[0] as u64; From 2399eb9af7c1505eac9f340c725c62d49fc6a857 Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Sat, 21 Sep 2024 13:03:49 -0700 Subject: [PATCH 2/3] Update toolchain requirement to 1.66 Seems to be required by one of our deps on MacOS --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 5b6cd6b..9cf4011 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.65 +1.66 From a2b9368202d2328bde7c4cdc760603505e21b144 Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Sat, 21 Sep 2024 13:23:25 -0700 Subject: [PATCH 3/3] Fix compilation with no_std on arm --- src/octets.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/octets.rs b/src/octets.rs index a564571..6785e22 100644 --- a/src/octets.rs +++ b/src/octets.rs @@ -135,9 +135,8 @@ pub fn fused_addassign_mul_scalar_binary( } } -#[cfg(target_arch = "aarch64")] // TODO: enable when stable -// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"), feature = "std"))] // #[target_feature(enable = "neon")] unsafe fn fused_addassign_mul_scalar_binary_neon( octets: &mut [u8], @@ -290,9 +289,8 @@ fn mulassign_scalar_fallback(octets: &mut [u8], scalar: &Octet) { } } -#[cfg(target_arch = "aarch64")] // TODO: enable when stable -// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"), feature = "std"))] // #[target_feature(enable = "neon")] unsafe fn mulassign_scalar_neon(octets: &mut [u8], scalar: &Octet) { #[cfg(target_arch = "aarch64")] @@ -458,9 +456,8 @@ fn fused_addassign_mul_scalar_fallback(octets: &mut [u8], other: &[u8], scalar: } } -#[cfg(target_arch = "aarch64")] // TODO: enable when stable -// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"), feature = "std"))] // #[target_feature(enable = "neon")] unsafe fn fused_addassign_mul_scalar_neon(octets: &mut [u8], other: &[u8], scalar: &Octet) { #[cfg(target_arch = "aarch64")] @@ -671,15 +668,14 @@ fn add_assign_fallback(octets: &mut [u8], other: &[u8]) { } } -#[cfg(target_arch = "aarch64")] +#[cfg(all(target_arch = "aarch64", feature = "std"))] use std::arch::aarch64::uint8x16_t; // TODO: enable when stable // #[cfg(target_arch = "arm")] // use std::arch::arm::uint8x16_t; -#[cfg(target_arch = "aarch64")] // TODO: enable when stable -// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"), feature = "std"))] // #[target_feature(enable = "neon")] unsafe fn store_neon(ptr: *mut uint8x16_t, value: uint8x16_t) { #[cfg(target_arch = "aarch64")] @@ -695,9 +691,8 @@ unsafe fn store_neon(ptr: *mut uint8x16_t, value: uint8x16_t) { .write_unaligned(vgetq_lane_u64(reinterp, 1)); } -#[cfg(all(target_arch = "aarch64", feature = "std"))] // TODO: enable when stable -// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +#[cfg(all(any(target_arch = "arm", target_arch = "aarch64"), feature = "std"))] // #[target_feature(enable = "neon")] unsafe fn add_assign_neon(octets: &mut [u8], other: &[u8]) { #[cfg(target_arch = "aarch64")]