Skip to content

Commit

Permalink
testsuite: update tests to not use math intrinsics directly
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed Apr 20, 2013
1 parent d9c54f8 commit c5baeb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/test/bench/shootout-nbody.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::from_str::FromStr;
use core::uint::range;
use core::unstable::intrinsics::sqrtf64;

static PI: f64 = 3.141592653589793;
static SOLAR_MASS: f64 = 4.0 * PI * PI;
Expand Down Expand Up @@ -88,7 +87,7 @@ fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: i32) {
d[2] = bodies[i].x[2] - bodies[j].x[2];

let d2 = d[0]*d[0] + d[1]*d[1] + d[2]*d[2];
let mag = dt / (d2 * sqrtf64(d2));
let mag = dt / (d2 * f64::sqrt(d2));

let a_mass = bodies[i].mass, b_mass = bodies[j].mass;
bodies[i].v[0] -= d[0] * b_mass * mag;
Expand Down Expand Up @@ -121,7 +120,7 @@ fn energy(bodies: &[Planet, ..N_BODIES]) -> f64 {
for range(0, 3) |k| {
d[k] = bodies[i].x[k] - bodies[j].x[k];
}
let dist = sqrtf64(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
let dist = f64::sqrt(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
e -= bodies[i].mass * bodies[j].mass / dist;
}
}
Expand All @@ -147,4 +146,3 @@ fn main() {

println(fmt!("%.9f", energy(&bodies) as float));
}

4 changes: 1 addition & 3 deletions src/test/bench/shootout-spectralnorm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::from_str::FromStr;
use core::iter::ExtendedMutableIter;
use core::unstable::intrinsics::sqrtf64;

#[inline]
fn A(i: i32, j: i32) -> i32 {
Expand Down Expand Up @@ -49,6 +48,5 @@ fn main() {
mult_AtAv(v, u, tmp);
}

println(fmt!("%.9f", sqrtf64(dot(u,v) / dot(v,v)) as float));
println(fmt!("%.9f", f64::sqrt(dot(u,v) / dot(v,v)) as float));
}

5 comments on commit c5baeb1

@bors
Copy link
Contributor

@bors bors commented on c5baeb1 Apr 20, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at huonw@c5baeb1

@bors
Copy link
Contributor

@bors bors commented on c5baeb1 Apr 20, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging huonw/rust/rustc-intrinsics-fixed-stack = c5baeb1 into auto

@bors
Copy link
Contributor

@bors bors commented on c5baeb1 Apr 20, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huonw/rust/rustc-intrinsics-fixed-stack = c5baeb1 merged ok, testing candidate = ae3b869

@bors
Copy link
Contributor

@bors bors commented on c5baeb1 Apr 20, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on c5baeb1 Apr 20, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = ae3b869

Please sign in to comment.