Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear stage 1 #292

Merged
merged 10 commits into from
Sep 24, 2020
2 changes: 1 addition & 1 deletion ci/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cargo_fmt() {
}

cargo_clippy() {
cargo clippy --all -- -D clippy::pedantic
cargo clippy --all -- -D clippy::perf
}

CMD="-1"
Expand Down
6 changes: 3 additions & 3 deletions examples/aobench/benches/ambient_occlusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
use aobench_lib::*;
use criterion::*;
use intersection::Isect;
use scene::Test;
use aobench_lib::scene::Test;

fn hit_scalar(c: &mut Criterion) {
let mut scene = Test::new();
let mut scene = Test::default();
c.bench(
"scalar",
Benchmark::new("ao_hit", move |b| {
Expand All @@ -24,7 +24,7 @@ fn hit_scalar(c: &mut Criterion) {
}

fn hit_vector(c: &mut Criterion) {
let mut scene = Test::new();
let mut scene = Test::default();

c.bench(
"vector",
Expand Down
4 changes: 2 additions & 2 deletions examples/aobench/benches/isec_plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn hit_vector(c: &mut Criterion) {
assert_eq!(v.hit.all(), true);
})
})
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
);
}

Expand Down Expand Up @@ -175,7 +175,7 @@ fn miss_vector(c: &mut Criterion) {
assert_eq!(v.hit.any(), false);
})
})
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
);
}

Expand Down
5 changes: 2 additions & 3 deletions examples/aobench/benches/isec_sphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::geometry::{f32xN, Ray, RayxN, Sphere, V3DxN, V3D};
use crate::intersection::{Intersect, Isect, IsectxN};
use aobench_lib::*;
use criterion::*;
use test::*;

fn hit_scalar(c: &mut Criterion) {
let mut s = Sphere {
Expand Down Expand Up @@ -121,7 +120,7 @@ fn hit_vector(c: &mut Criterion) {
assert_eq!(v.hit.all(), true);
})
})
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
);
}

Expand Down Expand Up @@ -160,7 +159,7 @@ fn miss_vector(c: &mut Criterion) {
assert_eq!(v.hit.any(), false);
})
})
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/aobench/benches/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn random_vector(c: &mut Criterion) {
black_box(rng.gen());
})
})
.throughput(Throughput::Elements(f32xN::lanes() as u32)),
.throughput(Throughput::Elements(f32xN::lanes() as u64)),
);
}

Expand Down
9 changes: 5 additions & 4 deletions examples/aobench/src/image.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Image utilities

use failure::Error;
use png;
#[allow(unused)]
use png::{BitDepth, ColorType, Encoder};
use std::path::Path;

/// PNG image in RGB format
Expand Down Expand Up @@ -53,14 +54,14 @@ impl Image {

let file = File::create(output)?;
let buf_writer = &mut BufWriter::new(file);
let mut encoder = png::Encoder::new(
let mut encoder = Encoder::new(
buf_writer,
self.width as u32,
self.height as u32,
);

encoder.set_color(png::ColorType::RGB);
encoder.set_depth(png::BitDepth::Eight);
encoder.set_color(ColorType::RGB);
encoder.set_depth(BitDepth::Eight);
let mut writer = encoder.write_header().unwrap();

if soa {
Expand Down
6 changes: 3 additions & 3 deletions examples/aobench/src/intersection/ray_plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Intersect<Plane> for RayxN {
let d = -plane.p.dot(plane.n);
let v = ray.dir.dot(plane.n);

let old_isect = isect;
let _old_isect = isect;

let m = v.abs().ge(f32xN::splat(1e-17));
if m.any() {
Expand All @@ -58,10 +58,10 @@ impl Intersect<Plane> for RayxN {
// Check that the vector and the scalar version produce the same results
// for the same inputs in debug builds
for i in 0..f32xN::lanes() {
let old_isect_i = old_isect.get(i);
let old_isect_i = _old_isect.get(i);
let ray_i = self.get(i);
let isect_i = ray_i.intersect(plane, old_isect_i);
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);
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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions examples/aobench/src/intersection/ray_sphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Intersect<Sphere> for RayxN {
let c = radius.mul_adde(-radius, rs.dot(rs));
let d = b.mul_adde(b, -c);

let old_isect = isect;
let _old_isect = isect;

let m = d.gt(f32xN::splat(0.));
if m.any() {
Expand All @@ -64,10 +64,10 @@ impl Intersect<Sphere> for RayxN {
// Check that the vector and the scalar version produce the same results
// for the same inputs in debug builds
for i in 0..f32xN::lanes() {
let old_isect_i = old_isect.get(i);
let old_isect_i = _old_isect.get(i);
let ray_i = self.get(i);
let isect_i = ray_i.intersect(sphere, old_isect_i);
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);
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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion examples/aobench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
clippy::cast_sign_loss,
clippy::identity_op,
clippy::erasing_op,
clippy::must_use_candidate
clippy::must_use_candidate,
clippy::float_cmp
)]

pub mod ambient_occlusion;
Expand Down
2 changes: 1 addition & 1 deletion examples/dot_product/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Vector dot product
#![deny(warnings, rust_2018_idioms)]
#![feature(custom_inner_attributes)]
#![allow(clippy::must_use_candidate)]
#![allow(clippy::must_use_candidate, clippy::float_cmp)]

pub mod scalar;
pub mod simd;
Expand Down
3 changes: 2 additions & 1 deletion examples/fannkuch_redux/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::cast_possible_wrap,
clippy::must_use_candidate
clippy::must_use_candidate,
clippy::float_cmp
)]

pub mod scalar;
Expand Down
2 changes: 1 addition & 1 deletion examples/fannkuch_redux/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() {
#[cfg(test)]
mod tests {
use super::*;
static OUTPUT: &'static [u8] = include_bytes!("fannkuchredux-output.txt");
static OUTPUT: &[u8] = include_bytes!("fannkuchredux-output.txt");
#[test]
fn verify_output_simd() {
let mut out: Vec<u8> = Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions examples/mandelbrot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ mod tests {
}

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

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

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

if out != OUTPUT {
out.into_iter().zip(OUTPUT.into_iter()).enumerate().for_each(
out.into_iter().zip(OUTPUT.iter()).enumerate().for_each(
|(i, (a, &b))| {
assert_eq!(
a, b,
Expand Down
2 changes: 1 addition & 1 deletion examples/matrix_inverse/src/scalar.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Scalar implementation
#![rustfmt::skip]
#[rustfmt::skip]
use crate::*;

#[allow(clippy::too_many_lines)]
Expand Down
2 changes: 1 addition & 1 deletion examples/nbody/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
#[cfg(test)]
mod tests {
use super::*;
static OUTPUT: &'static [u8] = include_bytes!("nbody-output.txt");
static OUTPUT: &[u8] = include_bytes!("nbody-output.txt");
#[test]
fn verify_output_simd() {
let mut out: Vec<u8> = Vec::new();
Expand Down
3 changes: 2 additions & 1 deletion examples/options_pricing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::must_use_candidate,
clippy::too_many_arguments
clippy::too_many_arguments,
clippy::float_cmp
)]

use packed_simd::f32x8 as f32s;
Expand Down
2 changes: 1 addition & 1 deletion examples/spectral_norm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() {
#[cfg(test)]
mod tests {
use super::*;
static OUTPUT: &'static [u8] = include_bytes!("spectralnorm-output.txt");
static OUTPUT: &[u8] = include_bytes!("spectralnorm-output.txt");
#[test]
fn verify_output_simd() {
let mut out: Vec<u8> = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion examples/stencil/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Data {
pub fn exec<F>(&mut self, f: F)
where
F: Fn(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
&[f32; 4], &[f32], &mut [f32], &mut [f32]) -> (),
&[f32; 4], &[f32], &mut [f32], &mut [f32]),
{
f(
self.t.0, self.t.1,
Expand Down
2 changes: 1 addition & 1 deletion examples/stencil/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::env;
fn run<F>(name: &str, f: F)
where
F: Fn(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
&[f32; 4], &[f32], &mut [f32], &mut [f32]) -> (),
&[f32; 4], &[f32], &mut [f32], &mut [f32]),
{
let mut d = Data::benchmark();
let t = time::Duration::span(move || d.exec(f));
Expand Down
4 changes: 2 additions & 2 deletions examples/stencil/src/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ pub(crate) fn step_x8(

let sum = {
let i = i as i32;
(a_cur!(i, 0, 0)
a_cur!(i, 0, 0)
+ a_cur!(-i, 0, 0)
+ a_cur!(0, i, 0)
+ a_cur!(0, -i, 0)
+ a_cur!(0, 0, i)
+ a_cur!(0, 0, -i))
+ a_cur!(0, 0, -i)
};

div = coef.mul_adde(sum, div);
Expand Down
4 changes: 2 additions & 2 deletions examples/triangle_xform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ mod tests {
scalar_xformed.into_iter().zip(simd_xformed.into_iter()).for_each(
|(a, b)| {
if a != b {
a.0.into_iter().zip(b.0.into_iter()).for_each(
a.0.iter().zip(b.0.iter()).for_each(
|(v1, v2)| {
v1.into_iter().zip(v2.into_iter()).for_each(
v1.iter().zip(v2.iter()).for_each(
|(a, b)| {
assert!(
(a - b).abs() <= EPSILON,
Expand Down
1 change: 1 addition & 0 deletions src/api/bit_manip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ macro_rules! impl_bit_manip {
paste::item_with_macros! {
#[allow(overflowing_literals)]
pub mod [<$id _bit_manip>] {
#![allow(const_item_mutation)]
use super::*;

const LANE_WIDTH: usize = mem::size_of::<$elem_ty>() * 8;
Expand Down
2 changes: 1 addition & 1 deletion src/api/cast/v128.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `FromCast` and `IntoCast` implementations for portable 128-bit wide vectors
#![rustfmt::skip]
#[rustfmt::skip]

use crate::*;

Expand Down
2 changes: 1 addition & 1 deletion src/api/cast/v16.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `FromCast` and `IntoCast` implementations for portable 16-bit wide vectors
#![rustfmt::skip]
#[rustfmt::skip]

use crate::*;

Expand Down
2 changes: 1 addition & 1 deletion src/api/cast/v256.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `FromCast` and `IntoCast` implementations for portable 256-bit wide vectors
#![rustfmt::skip]
#[rustfmt::skip]

use crate::*;

Expand Down
2 changes: 1 addition & 1 deletion src/api/cast/v32.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `FromCast` and `IntoCast` implementations for portable 32-bit wide vectors
#![rustfmt::skip]
#[rustfmt::skip]

use crate::*;

Expand Down
2 changes: 1 addition & 1 deletion src/api/cast/v512.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `FromCast` and `IntoCast` implementations for portable 512-bit wide vectors
#![rustfmt::skip]
#[rustfmt::skip]

use crate::*;

Expand Down
2 changes: 1 addition & 1 deletion src/api/cast/v64.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `FromCast` and `IntoCast` implementations for portable 64-bit wide vectors
#![rustfmt::skip]
#[rustfmt::skip]

use crate::*;

Expand Down
2 changes: 2 additions & 0 deletions src/api/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ macro_rules! impl_default {
test_if!{
$test_tt:
paste::item! {
// Comparisons use integer casts within mantissa^1 range.
#[allow(clippy::float_cmp)]
pub mod [<$id _default>] {
use super::*;
#[cfg_attr(not(target_arch = "wasm32"), test)] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
Expand Down
2 changes: 2 additions & 0 deletions src/api/from/from_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ macro_rules! impl_from_array {
test_if! {
$test_tt:
paste::item! {
// Comparisons use integer casts within mantissa^1 range.
#[allow(clippy::float_cmp)]
mod [<$id _from>] {
use super::*;
#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/api/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ macro_rules! impl_hash {
let mut v_hash = a_hash.clone();
a.hash(&mut a_hash);

// Integer within mantissa^1 range.
#[allow(clippy::float_cmp)]
let v = $id::splat(42 as $elem_ty);
v.hash(&mut v_hash);
assert_eq!(a_hash.finish(), v_hash.finish());
Expand Down
3 changes: 1 addition & 2 deletions src/api/into_bits/arch_specific.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! `FromBits` and `IntoBits` between portable vector types and the
//! architecture-specific vector types.
#![rustfmt::skip]
#[rustfmt::skip]

// FIXME: MIPS FromBits/IntoBits

Expand Down Expand Up @@ -84,7 +84,6 @@ macro_rules! impl_arch {
// FIXME: 64-bit single element types
// FIXME: arm/aarch float16x4_t missing
impl_arch!(
[x86["x86"]: __m64], [x86_64["x86_64"]: __m64],
[arm["arm"]: int8x8_t, uint8x8_t, poly8x8_t, int16x4_t, uint16x4_t,
poly16x4_t, int32x2_t, uint32x2_t, float32x2_t, int64x1_t,
uint64x1_t],
Expand Down
2 changes: 1 addition & 1 deletion src/api/into_bits/v128.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `FromBits` and `IntoBits` implementations for portable 128-bit wide vectors
#![rustfmt::skip]
#[rustfmt::skip]

#[allow(unused)] // wasm_bindgen_test
use crate::*;
Expand Down
2 changes: 1 addition & 1 deletion src/api/into_bits/v16.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `FromBits` and `IntoBits` implementations for portable 16-bit wide vectors
#![rustfmt::skip]
#[rustfmt::skip]

#[allow(unused)] // wasm_bindgen_test
use crate::*;
Expand Down
Loading