rename to spacedog, remove unneccessary atomics
This commit is contained in:
parent
4ca8e55dab
commit
eb1efaf694
2 changed files with 11 additions and 16 deletions
|
@ -1,14 +1,13 @@
|
||||||
[package]
|
[package]
|
||||||
name = "spacebench"
|
name = "spacedog"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dev-dependencies]
|
||||||
clap = "4.5.49"
|
clap = "4.5.49"
|
||||||
criterion = "0.7.0"
|
criterion = "0.7.0"
|
||||||
rand = "0.9.2"
|
rand = "0.9.2"
|
||||||
rand_hc = "0.4.0"
|
rand_hc = "0.4.0"
|
||||||
rstar = "0.12.2"
|
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "benchmarks"
|
name = "benchmarks"
|
||||||
|
|
|
@ -11,15 +11,15 @@ struct Point2d {
|
||||||
y: f64,
|
y: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, Clone, Copy)]
|
||||||
struct PVal {
|
struct PVal {
|
||||||
point: usize,
|
point: usize,
|
||||||
val: AtomicU64,
|
val: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for PVal {
|
impl PartialEq for PVal {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.val.load(Relaxed) == other.val.load(Relaxed)
|
self.val == other.val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,15 +27,13 @@ impl Eq for PVal {}
|
||||||
|
|
||||||
impl PartialOrd for PVal {
|
impl PartialOrd for PVal {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
let a = f64::from_bits(self.val.load(Relaxed));
|
Some(self.cmp(other))
|
||||||
let b = f64::from_bits(other.val.load(Relaxed));
|
|
||||||
a.partial_cmp(&b)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ord for PVal {
|
impl Ord for PVal {
|
||||||
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
self.partial_cmp(other).unwrap()
|
self.val.partial_cmp(&other.val).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,12 +53,12 @@ impl Spindex2d {
|
||||||
for (i, point) in points.iter().enumerate() {
|
for (i, point) in points.iter().enumerate() {
|
||||||
let x = PVal {
|
let x = PVal {
|
||||||
point: i,
|
point: i,
|
||||||
val: AtomicU64::new(point.x.to_bits()),
|
val: point.x,
|
||||||
};
|
};
|
||||||
xs.push(x);
|
xs.push(x);
|
||||||
let y = PVal {
|
let y = PVal {
|
||||||
point: i,
|
point: i,
|
||||||
val: AtomicU64::new(point.y.to_bits()),
|
val: point.y,
|
||||||
};
|
};
|
||||||
ys.push(y);
|
ys.push(y);
|
||||||
|
|
||||||
|
@ -89,17 +87,15 @@ impl Spindex2d {
|
||||||
for (i, point) in points.iter().enumerate() {
|
for (i, point) in points.iter().enumerate() {
|
||||||
let xi = self.xpoints[i].load(Relaxed);
|
let xi = self.xpoints[i].load(Relaxed);
|
||||||
let yi = self.ypoints[i].load(Relaxed);
|
let yi = self.ypoints[i].load(Relaxed);
|
||||||
let x = point.x.to_bits();
|
|
||||||
let x = PVal {
|
let x = PVal {
|
||||||
point: i,
|
point: i,
|
||||||
val: x.into(),
|
val: point.x,
|
||||||
};
|
};
|
||||||
xs[xi] = x;
|
xs[xi] = x;
|
||||||
|
|
||||||
let y = point.y.to_bits();
|
|
||||||
let y = PVal {
|
let y = PVal {
|
||||||
point: i,
|
point: i,
|
||||||
val: y.into(),
|
val: point.y,
|
||||||
};
|
};
|
||||||
ys[yi] = y;
|
ys[yi] = y;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue