Skip to content

Commit a1406b1

Browse files
GabrielMajerignzlbg
authored andcommitted
Ensure random generator functions get inlined
1 parent 23cbdf0 commit a1406b1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples/aobench/src/random.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub mod vector {
9191
RngT(z0, z1, z2, z3)
9292
}
9393

94-
#[inline]
94+
#[inline(always)]
9595
pub fn gen_u32(&mut self) -> u32xN {
9696
let mut b = ((self.0 << 6) ^ self.0) >> 13;
9797
self.0 = ((self.0 & u32xN::splat(4_294_967_294)) << 18) ^ b;
@@ -104,7 +104,7 @@ pub mod vector {
104104
self.0 ^ self.1 ^ self.2 ^ self.3
105105
}
106106

107-
#[inline]
107+
#[inline(always)]
108108
pub fn gen(&mut self) -> f32xN {
109109
let mut v = self.gen_u32();
110110
v &= u32xN::splat((1_u32 << 23) - 1);
@@ -121,7 +121,7 @@ pub mod vector {
121121
}
122122

123123
impl RngH {
124-
#[inline]
124+
#[inline(always)]
125125
pub fn gen(&mut self) -> f32xN {
126126
unsafe { (*self.rng.get()).gen() }
127127
}

examples/aobench/src/scene/random.rs

+4
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ impl Default for Random {
5555

5656
impl Scene for Random {
5757
const NAO_SAMPLES: usize = 8;
58+
#[inline(always)]
5859
fn rand(&mut self) -> f32 {
5960
::random::scalar::thread_rng().gen()
6061
}
62+
#[inline(always)]
6163
fn plane(&self) -> &Plane {
6264
&self.plane
6365
}
66+
#[inline(always)]
6467
fn spheres(&self) -> &[Sphere] {
6568
&self.spheres
6669
}
70+
#[inline(always)]
6771
fn rand_f32xN(&mut self) -> (f32xN, f32xN) {
6872
let mut rng = ::random::vector::thread_rng();
6973
(rng.gen(), rng.gen())

0 commit comments

Comments
 (0)