Skip to content

Commit 082a651

Browse files
Fix code in examples
1 parent cbee1bd commit 082a651

File tree

14 files changed

+27
-24
lines changed

14 files changed

+27
-24
lines changed

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/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/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/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,

0 commit comments

Comments
 (0)