Skip to content

Commit c61141b

Browse files
Merge pull request #292 from workingjubilee/go-green
Clear stage 1
2 parents 065021d + 47de491 commit c61141b

Some content is hidden

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

57 files changed

+156
-141
lines changed

ci/all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ cargo_fmt() {
2121
}
2222

2323
cargo_clippy() {
24-
cargo clippy --all -- -D clippy::pedantic
24+
cargo clippy --all -- -D clippy::perf
2525
}
2626

2727
CMD="-1"

examples/aobench/benches/ambient_occlusion.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
use aobench_lib::*;
55
use criterion::*;
66
use intersection::Isect;
7-
use scene::Test;
7+
use aobench_lib::scene::Test;
88

99
fn hit_scalar(c: &mut Criterion) {
10-
let mut scene = Test::new();
10+
let mut scene = Test::default();
1111
c.bench(
1212
"scalar",
1313
Benchmark::new("ao_hit", move |b| {
@@ -24,7 +24,7 @@ fn hit_scalar(c: &mut Criterion) {
2424
}
2525

2626
fn hit_vector(c: &mut Criterion) {
27-
let mut scene = Test::new();
27+
let mut scene = Test::default();
2828

2929
c.bench(
3030
"vector",

examples/aobench/benches/isec_plane.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn hit_vector(c: &mut Criterion) {
132132
assert_eq!(v.hit.all(), true);
133133
})
134134
})
135-
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
135+
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
136136
);
137137
}
138138

@@ -175,7 +175,7 @@ fn miss_vector(c: &mut Criterion) {
175175
assert_eq!(v.hit.any(), false);
176176
})
177177
})
178-
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
178+
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
179179
);
180180
}
181181

examples/aobench/benches/isec_sphere.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::geometry::{f32xN, Ray, RayxN, Sphere, V3DxN, V3D};
55
use crate::intersection::{Intersect, Isect, IsectxN};
66
use aobench_lib::*;
77
use criterion::*;
8-
use test::*;
98

109
fn hit_scalar(c: &mut Criterion) {
1110
let mut s = Sphere {
@@ -121,7 +120,7 @@ fn hit_vector(c: &mut Criterion) {
121120
assert_eq!(v.hit.all(), true);
122121
})
123122
})
124-
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
123+
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
125124
);
126125
}
127126

@@ -160,7 +159,7 @@ fn miss_vector(c: &mut Criterion) {
160159
assert_eq!(v.hit.any(), false);
161160
})
162161
})
163-
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
162+
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
164163
);
165164
}
166165

examples/aobench/benches/random.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn random_vector(c: &mut Criterion) {
2727
black_box(rng.gen());
2828
})
2929
})
30-
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
30+
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
3131
);
3232
}
3333

examples/aobench/src/image.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Image utilities
22
33
use failure::Error;
4-
use png;
4+
#[allow(unused)]
5+
use png::{BitDepth, ColorType, Encoder};
56
use std::path::Path;
67

78
/// PNG image in RGB format
@@ -53,14 +54,14 @@ impl Image {
5354

5455
let file = File::create(output)?;
5556
let buf_writer = &mut BufWriter::new(file);
56-
let mut encoder = png::Encoder::new(
57+
let mut encoder = Encoder::new(
5758
buf_writer,
5859
self.width as u32,
5960
self.height as u32,
6061
);
6162

62-
encoder.set_color(png::ColorType::RGB);
63-
encoder.set_depth(png::BitDepth::Eight);
63+
encoder.set_color(ColorType::RGB);
64+
encoder.set_depth(BitDepth::Eight);
6465
let mut writer = encoder.write_header().unwrap();
6566

6667
if soa {

examples/aobench/src/intersection/ray_plane.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Intersect<Plane> for RayxN {
3838
let d = -plane.p.dot(plane.n);
3939
let v = ray.dir.dot(plane.n);
4040

41-
let old_isect = isect;
41+
let _old_isect = isect;
4242

4343
let m = v.abs().ge(f32xN::splat(1e-17));
4444
if m.any() {
@@ -58,10 +58,10 @@ impl Intersect<Plane> for RayxN {
5858
// Check that the vector and the scalar version produce the same results
5959
// for the same inputs in debug builds
6060
for i in 0..f32xN::lanes() {
61-
let old_isect_i = old_isect.get(i);
61+
let old_isect_i = _old_isect.get(i);
6262
let ray_i = self.get(i);
6363
let isect_i = ray_i.intersect(plane, old_isect_i);
64-
assert!(isect_i.almost_eq(&isect.get(i)), "{:?} !~= {:?}\n\nplane: {:?}\n\nold_isect: {:?}\n\nrays: {:?}\n\ni: {:?}\nold_isect_i: {:?}\nray_i: {:?}\n\n", isect_i, isect.get(i), plane, old_isect, self, i, old_isect_i, ray_i);
64+
assert!(isect_i.almost_eq(&isect.get(i)), "{:?} !~= {:?}\n\nplane: {:?}\n\nold_isect: {:?}\n\nrays: {:?}\n\ni: {:?}\nold_isect_i: {:?}\nray_i: {:?}\n\n", isect_i, isect.get(i), plane, _old_isect, self, i, old_isect_i, ray_i);
6565
}
6666
}
6767

examples/aobench/src/intersection/ray_sphere.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl Intersect<Sphere> for RayxN {
4343
let c = radius.mul_adde(-radius, rs.dot(rs));
4444
let d = b.mul_adde(b, -c);
4545

46-
let old_isect = isect;
46+
let _old_isect = isect;
4747

4848
let m = d.gt(f32xN::splat(0.));
4949
if m.any() {
@@ -64,10 +64,10 @@ impl Intersect<Sphere> for RayxN {
6464
// Check that the vector and the scalar version produce the same results
6565
// for the same inputs in debug builds
6666
for i in 0..f32xN::lanes() {
67-
let old_isect_i = old_isect.get(i);
67+
let old_isect_i = _old_isect.get(i);
6868
let ray_i = self.get(i);
6969
let isect_i = ray_i.intersect(sphere, old_isect_i);
70-
assert!(isect_i.almost_eq(&isect.get(i)), "{:?} !~= {:?}\n\nsphere: {:?}\n\nold_isect: {:?}\n\nrays: {:?}\n\ni: {:?}\nold_isect_i: {:?}\nray_i: {:?}\n\n", isect_i, isect.get(i), sphere, old_isect, self, i, old_isect_i, ray_i);
70+
assert!(isect_i.almost_eq(&isect.get(i)), "{:?} !~= {:?}\n\nsphere: {:?}\n\nold_isect: {:?}\n\nrays: {:?}\n\ni: {:?}\nold_isect_i: {:?}\nray_i: {:?}\n\n", isect_i, isect.get(i), sphere, _old_isect, self, i, old_isect_i, ray_i);
7171
}
7272
}
7373

examples/aobench/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
clippy::cast_sign_loss,
1414
clippy::identity_op,
1515
clippy::erasing_op,
16-
clippy::must_use_candidate
16+
clippy::must_use_candidate,
17+
clippy::float_cmp
1718
)]
1819

1920
pub mod ambient_occlusion;

examples/dot_product/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Vector dot product
22
#![deny(warnings, rust_2018_idioms)]
33
#![feature(custom_inner_attributes)]
4-
#![allow(clippy::must_use_candidate)]
4+
#![allow(clippy::must_use_candidate, clippy::float_cmp)]
55

66
pub mod scalar;
77
pub mod simd;

examples/fannkuch_redux/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
clippy::cast_possible_truncation,
88
clippy::cast_sign_loss,
99
clippy::cast_possible_wrap,
10-
clippy::must_use_candidate
10+
clippy::must_use_candidate,
11+
clippy::float_cmp
1112
)]
1213

1314
pub mod scalar;

examples/fannkuch_redux/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323
#[cfg(test)]
2424
mod tests {
2525
use super::*;
26-
static OUTPUT: &'static [u8] = include_bytes!("fannkuchredux-output.txt");
26+
static OUTPUT: &[u8] = include_bytes!("fannkuchredux-output.txt");
2727
#[test]
2828
fn verify_output_simd() {
2929
let mut out: Vec<u8> = Vec::new();

examples/mandelbrot/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ mod tests {
215215
}
216216

217217
fn verify_algo(algo: Algorithm) {
218-
static OUTPUT: &'static [u8] = include_bytes!("mandelbrot-output.txt");
218+
static OUTPUT: &[u8] = include_bytes!("mandelbrot-output.txt");
219219

220220
let (width, height) = (200, 200);
221221

@@ -231,7 +231,7 @@ mod tests {
231231
assert_eq!(out.len(), OUTPUT.len());
232232

233233
if out != OUTPUT {
234-
out.into_iter().zip(OUTPUT.into_iter()).enumerate().for_each(
234+
out.into_iter().zip(OUTPUT.iter()).enumerate().for_each(
235235
|(i, (a, &b))| {
236236
assert_eq!(
237237
a, b,

examples/matrix_inverse/src/scalar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Scalar implementation
2-
#![rustfmt::skip]
2+
#[rustfmt::skip]
33
use crate::*;
44

55
#[allow(clippy::too_many_lines)]

examples/nbody/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
#[cfg(test)]
3030
mod tests {
3131
use super::*;
32-
static OUTPUT: &'static [u8] = include_bytes!("nbody-output.txt");
32+
static OUTPUT: &[u8] = include_bytes!("nbody-output.txt");
3333
#[test]
3434
fn verify_output_simd() {
3535
let mut out: Vec<u8> = Vec::new();

examples/options_pricing/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
clippy::cast_possible_truncation,
88
clippy::cast_possible_wrap,
99
clippy::must_use_candidate,
10-
clippy::too_many_arguments
10+
clippy::too_many_arguments,
11+
clippy::float_cmp
1112
)]
1213

1314
use packed_simd::f32x8 as f32s;

examples/spectral_norm/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
#[cfg(test)]
2525
mod tests {
2626
use super::*;
27-
static OUTPUT: &'static [u8] = include_bytes!("spectralnorm-output.txt");
27+
static OUTPUT: &[u8] = include_bytes!("spectralnorm-output.txt");
2828
#[test]
2929
fn verify_output_simd() {
3030
let mut out: Vec<u8> = Vec::new();

examples/stencil/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Data {
9797
pub fn exec<F>(&mut self, f: F)
9898
where
9999
F: Fn(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
100-
&[f32; 4], &[f32], &mut [f32], &mut [f32]) -> (),
100+
&[f32; 4], &[f32], &mut [f32], &mut [f32]),
101101
{
102102
f(
103103
self.t.0, self.t.1,

examples/stencil/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::env;
88
fn run<F>(name: &str, f: F)
99
where
1010
F: Fn(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
11-
&[f32; 4], &[f32], &mut [f32], &mut [f32]) -> (),
11+
&[f32; 4], &[f32], &mut [f32], &mut [f32]),
1212
{
1313
let mut d = Data::benchmark();
1414
let t = time::Duration::span(move || d.exec(f));

examples/stencil/src/simd.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ pub(crate) fn step_x8(
3636

3737
let sum = {
3838
let i = i as i32;
39-
(a_cur!(i, 0, 0)
39+
a_cur!(i, 0, 0)
4040
+ a_cur!(-i, 0, 0)
4141
+ a_cur!(0, i, 0)
4242
+ a_cur!(0, -i, 0)
4343
+ a_cur!(0, 0, i)
44-
+ a_cur!(0, 0, -i))
44+
+ a_cur!(0, 0, -i)
4545
};
4646

4747
div = coef.mul_adde(sum, div);

examples/triangle_xform/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ mod tests {
7070
scalar_xformed.into_iter().zip(simd_xformed.into_iter()).for_each(
7171
|(a, b)| {
7272
if a != b {
73-
a.0.into_iter().zip(b.0.into_iter()).for_each(
73+
a.0.iter().zip(b.0.iter()).for_each(
7474
|(v1, v2)| {
75-
v1.into_iter().zip(v2.into_iter()).for_each(
75+
v1.iter().zip(v2.iter()).for_each(
7676
|(a, b)| {
7777
assert!(
7878
(a - b).abs() <= EPSILON,

src/api/bit_manip.rs

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ macro_rules! impl_bit_manip {
3737
paste::item_with_macros! {
3838
#[allow(overflowing_literals)]
3939
pub mod [<$id _bit_manip>] {
40+
#![allow(const_item_mutation)]
4041
use super::*;
4142

4243
const LANE_WIDTH: usize = mem::size_of::<$elem_ty>() * 8;

src/api/cast/v128.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! `FromCast` and `IntoCast` implementations for portable 128-bit wide vectors
2-
#![rustfmt::skip]
2+
#[rustfmt::skip]
33

44
use crate::*;
55

src/api/cast/v16.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! `FromCast` and `IntoCast` implementations for portable 16-bit wide vectors
2-
#![rustfmt::skip]
2+
#[rustfmt::skip]
33

44
use crate::*;
55

src/api/cast/v256.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! `FromCast` and `IntoCast` implementations for portable 256-bit wide vectors
2-
#![rustfmt::skip]
2+
#[rustfmt::skip]
33

44
use crate::*;
55

src/api/cast/v32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! `FromCast` and `IntoCast` implementations for portable 32-bit wide vectors
2-
#![rustfmt::skip]
2+
#[rustfmt::skip]
33

44
use crate::*;
55

src/api/cast/v512.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! `FromCast` and `IntoCast` implementations for portable 512-bit wide vectors
2-
#![rustfmt::skip]
2+
#[rustfmt::skip]
33

44
use crate::*;
55

src/api/cast/v64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! `FromCast` and `IntoCast` implementations for portable 64-bit wide vectors
2-
#![rustfmt::skip]
2+
#[rustfmt::skip]
33

44
use crate::*;
55

src/api/default.rs

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ macro_rules! impl_default {
1212
test_if!{
1313
$test_tt:
1414
paste::item! {
15+
// Comparisons use integer casts within mantissa^1 range.
16+
#[allow(clippy::float_cmp)]
1517
pub mod [<$id _default>] {
1618
use super::*;
1719
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]

src/api/from/from_array.rs

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ macro_rules! impl_from_array {
5656
test_if! {
5757
$test_tt:
5858
paste::item! {
59+
// Comparisons use integer casts within mantissa^1 range.
60+
#[allow(clippy::float_cmp)]
5961
mod [<$id _from>] {
6062
use super::*;
6163
#[test]

src/api/hash.rs

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ macro_rules! impl_hash {
3636
let mut v_hash = a_hash.clone();
3737
a.hash(&mut a_hash);
3838

39+
// Integer within mantissa^1 range.
40+
#[allow(clippy::float_cmp)]
3941
let v = $id::splat(42 as $elem_ty);
4042
v.hash(&mut v_hash);
4143
assert_eq!(a_hash.finish(), v_hash.finish());

src/api/into_bits/arch_specific.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! `FromBits` and `IntoBits` between portable vector types and the
22
//! architecture-specific vector types.
3-
#![rustfmt::skip]
3+
#[rustfmt::skip]
44

55
// FIXME: MIPS FromBits/IntoBits
66

@@ -84,7 +84,6 @@ macro_rules! impl_arch {
8484
// FIXME: 64-bit single element types
8585
// FIXME: arm/aarch float16x4_t missing
8686
impl_arch!(
87-
[x86["x86"]: __m64], [x86_64["x86_64"]: __m64],
8887
[arm["arm"]: int8x8_t, uint8x8_t, poly8x8_t, int16x4_t, uint16x4_t,
8988
poly16x4_t, int32x2_t, uint32x2_t, float32x2_t, int64x1_t,
9089
uint64x1_t],

src/api/into_bits/v128.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! `FromBits` and `IntoBits` implementations for portable 128-bit wide vectors
2-
#![rustfmt::skip]
2+
#[rustfmt::skip]
33

44
#[allow(unused)] // wasm_bindgen_test
55
use crate::*;

src/api/into_bits/v16.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! `FromBits` and `IntoBits` implementations for portable 16-bit wide vectors
2-
#![rustfmt::skip]
2+
#[rustfmt::skip]
33

44
#[allow(unused)] // wasm_bindgen_test
55
use crate::*;

0 commit comments

Comments
 (0)