mirror of
https://github.com/cberner/raptorq.git
synced 2024-06-16 03:49:00 +00:00
Fix many Clippy warnings and errors
This commit is contained in:
parent
c8fd9bcbff
commit
7eb6542865
@ -1237,6 +1237,7 @@ impl Octet {
|
||||
impl Add for Octet {
|
||||
type Output = Octet;
|
||||
|
||||
#[allow(clippy::suspicious_arithmetic_impl)]
|
||||
fn add(self, other: Octet) -> Octet {
|
||||
Octet {
|
||||
// As defined in section 5.7.2, addition on octets is implemented as bitxor
|
||||
@ -1248,6 +1249,7 @@ impl Add for Octet {
|
||||
impl<'a, 'b> Add<&'b Octet> for &'a Octet {
|
||||
type Output = Octet;
|
||||
|
||||
#[allow(clippy::suspicious_arithmetic_impl)]
|
||||
fn add(self, other: &'b Octet) -> Octet {
|
||||
Octet {
|
||||
// As defined in section 5.7.2, addition on octets is implemented as bitxor
|
||||
@ -1257,12 +1259,14 @@ impl<'a, 'b> Add<&'b Octet> for &'a Octet {
|
||||
}
|
||||
|
||||
impl AddAssign for Octet {
|
||||
#[allow(clippy::suspicious_arithmetic_impl)]
|
||||
fn add_assign(&mut self, other: Octet) {
|
||||
self.value ^= other.value;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AddAssign<&'a Octet> for Octet {
|
||||
#[allow(clippy::suspicious_arithmetic_impl)]
|
||||
fn add_assign(&mut self, other: &'a Octet) {
|
||||
self.value ^= other.value;
|
||||
}
|
||||
@ -1271,6 +1275,7 @@ impl<'a> AddAssign<&'a Octet> for Octet {
|
||||
impl Sub for Octet {
|
||||
type Output = Octet;
|
||||
|
||||
#[allow(clippy::suspicious_arithmetic_impl)]
|
||||
fn sub(self, rhs: Octet) -> Octet {
|
||||
Octet {
|
||||
// As defined in section 5.7.2, subtraction on octets is implemented as bitxor
|
||||
@ -1290,6 +1295,7 @@ impl Mul for Octet {
|
||||
impl<'a, 'b> Mul<&'b Octet> for &'a Octet {
|
||||
type Output = Octet;
|
||||
|
||||
#[allow(clippy::suspicious_arithmetic_impl)]
|
||||
fn mul(self, other: &'b Octet) -> Octet {
|
||||
// As defined in section 5.7.2, multiplication is implemented via the tables above
|
||||
if self.value == 0 || other.value == 0 {
|
||||
@ -1319,6 +1325,7 @@ impl Div for Octet {
|
||||
impl<'a, 'b> Div<&'b Octet> for &'a Octet {
|
||||
type Output = Octet;
|
||||
|
||||
#[allow(clippy::suspicious_arithmetic_impl)]
|
||||
fn div(self, rhs: &'b Octet) -> Octet {
|
||||
assert_ne!(0, rhs.value);
|
||||
// As defined in section 5.7.2, division is implemented via the tables above
|
||||
|
@ -28,9 +28,16 @@ unsafe fn mulassign_scalar_avx2(octets: &mut [u8], scalar: &Octet) {
|
||||
|
||||
let low_mask = _mm256_set1_epi8(0x0F);
|
||||
let hi_mask = _mm256_set1_epi8(0xF0 as u8 as i8);
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory, and _mm256_storeu_si256
|
||||
// stores to unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let self_avx_ptr = octets.as_mut_ptr() as *mut __m256i;
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let low_table =
|
||||
_mm256_loadu_si256(OCTET_MUL_LOW_BITS[scalar.byte() as usize].as_ptr() as *const __m256i);
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let hi_table =
|
||||
_mm256_loadu_si256(OCTET_MUL_HI_BITS[scalar.byte() as usize].as_ptr() as *const __m256i);
|
||||
|
||||
@ -88,10 +95,19 @@ unsafe fn fused_addassign_mul_scalar_avx2(octets: &mut [u8], other: &[u8], scala
|
||||
|
||||
let low_mask = _mm256_set1_epi8(0x0F);
|
||||
let hi_mask = _mm256_set1_epi8(0xF0 as u8 as i8);
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory, and _mm256_storeu_si256
|
||||
// stores to unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let self_avx_ptr = octets.as_mut_ptr() as *mut __m256i;
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let other_avx_ptr = other.as_ptr() as *const __m256i;
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let low_table =
|
||||
_mm256_loadu_si256(OCTET_MUL_LOW_BITS[scalar.byte() as usize].as_ptr() as *const __m256i);
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let hi_table =
|
||||
_mm256_loadu_si256(OCTET_MUL_HI_BITS[scalar.byte() as usize].as_ptr() as *const __m256i);
|
||||
|
||||
@ -171,7 +187,12 @@ unsafe fn add_assign_avx2(octets: &mut [u8], other: &[u8]) {
|
||||
use std::arch::x86_64::*;
|
||||
|
||||
assert_eq!(octets.len(), other.len());
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory, and _mm256_storeu_si256
|
||||
// stores to unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let self_avx_ptr = octets.as_mut_ptr() as *mut __m256i;
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let other_avx_ptr = other.as_ptr() as *const __m256i;
|
||||
for i in 0..(octets.len() / 32) {
|
||||
let self_vec = _mm256_loadu_si256(self_avx_ptr.add(i));
|
||||
@ -215,6 +236,8 @@ unsafe fn count_ones_and_nonzeros_avx2(octets: &[u8]) -> (usize, usize) {
|
||||
|
||||
let avx_ones = _mm256_set1_epi8(1);
|
||||
let avx_zeros = _mm256_set1_epi8(0);
|
||||
// Safe because _mm256_loadu_si256 loads from unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let avx_ptr = octets.as_ptr() as *const __m256i;
|
||||
|
||||
let mut ones = 0;
|
||||
@ -240,6 +263,8 @@ unsafe fn count_ones_and_nonzeros_avx2(octets: &[u8]) -> (usize, usize) {
|
||||
remainder -= 16;
|
||||
let avx_ones = _mm_set1_epi8(1);
|
||||
let avx_zeros = _mm_set1_epi8(0);
|
||||
// Safe because _mm_lddqu_si128 loads from unaligned memory
|
||||
#[allow(clippy::cast_ptr_alignment)]
|
||||
let avx_ptr = octets.as_ptr().add((octets.len() / 32) * 32) as *const __m128i;
|
||||
|
||||
let vec = _mm_lddqu_si128(avx_ptr);
|
||||
|
@ -157,7 +157,7 @@ impl FirstPhaseRowSelectionStats {
|
||||
#[inline(never)]
|
||||
fn first_phase_graph_substep_build_adjacency<T: OctetMatrix>(
|
||||
&self,
|
||||
rows_with_two_ones: &Vec<usize>,
|
||||
rows_with_two_ones: &[usize],
|
||||
matrix: &T,
|
||||
) -> ArrayMap<Vec<(usize, usize)>> {
|
||||
let mut adjacent_nodes = ArrayMap::new(self.start_col, self.end_col);
|
||||
@ -210,7 +210,7 @@ impl FirstPhaseRowSelectionStats {
|
||||
&self,
|
||||
start_row: usize,
|
||||
end_row: usize,
|
||||
rows_with_two_ones: &Vec<usize>,
|
||||
rows_with_two_ones: &[usize],
|
||||
matrix: &T,
|
||||
) -> usize {
|
||||
let adjacent_nodes =
|
||||
@ -310,7 +310,7 @@ impl FirstPhaseRowSelectionStats {
|
||||
&self,
|
||||
start_row: usize,
|
||||
end_row: usize,
|
||||
rows_with_two_ones: &Vec<usize>,
|
||||
rows_with_two_ones: &[usize],
|
||||
) {
|
||||
for row in start_row..end_row {
|
||||
if self.non_zeros_per_row.get(row) == 2 {
|
||||
@ -329,7 +329,7 @@ impl FirstPhaseRowSelectionStats {
|
||||
matrix: &T,
|
||||
) -> (Option<usize>, Option<usize>) {
|
||||
let mut r = None;
|
||||
for i in 1..(self.end_col - self.start_col + 1) {
|
||||
for i in 1..=(self.end_col - self.start_col) {
|
||||
if self.non_zeros_histogram.get(i) > 0 {
|
||||
r = Some(i);
|
||||
break;
|
||||
@ -355,7 +355,7 @@ impl FirstPhaseRowSelectionStats {
|
||||
}
|
||||
|
||||
// See paragraph starting "If r = 2 and there is a row with exactly 2 ones in V..."
|
||||
if rows_with_two_ones.len() > 0 {
|
||||
if !rows_with_two_ones.is_empty() {
|
||||
#[cfg(debug_assertions)]
|
||||
self.first_phase_graph_substep_verify(start_row, end_row, &rows_with_two_ones);
|
||||
return (
|
||||
|
@ -1,5 +1,6 @@
|
||||
// As defined in section 5.5.1
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::unreadable_literal)]
|
||||
const V0: [u32; 256] = [
|
||||
251291136, 3952231631, 3370958628, 4070167936, 123631495,
|
||||
3351110283, 3218676425, 2011642291, 774603218, 2402805061,
|
||||
@ -56,6 +57,7 @@ const V0: [u32; 256] = [
|
||||
|
||||
// As defined in section 5.5.2
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::unreadable_literal)]
|
||||
const V1: [u32; 256] = [
|
||||
807385413, 2043073223, 3336749796, 1302105833, 2278607931,
|
||||
541015020, 1684564270, 372709334, 3508252125, 1768346005,
|
||||
@ -112,6 +114,7 @@ const V1: [u32; 256] = [
|
||||
|
||||
// As defined in section 5.5.3
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::unreadable_literal)]
|
||||
const V2: [u32; 256] = [
|
||||
1629829892, 282540176, 2794583710, 496504798, 2990494426,
|
||||
3070701851, 2575963183, 4094823972, 2775723650, 4079480416,
|
||||
@ -168,6 +171,7 @@ const V2: [u32; 256] = [
|
||||
|
||||
// As defined in section 5.5.4
|
||||
#[rustfmt::skip]
|
||||
#[allow(clippy::unreadable_literal)]
|
||||
const V3: [u32; 256] = [
|
||||
1191369816, 744902811, 2539772235, 3213192037, 3286061266,
|
||||
1200571165, 2463281260, 754888894, 714651270, 1968220972,
|
||||
|
Loading…
Reference in New Issue
Block a user