Skip to content

Commit

Permalink
Fix code in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed Sep 24, 2020
1 parent cbee1bd commit ed83bb8
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 24 deletions.
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
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/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
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

0 comments on commit ed83bb8

Please sign in to comment.