Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions Cargo.lock.patch

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
diff --git a/necsim-rust/Cargo.toml b/necsim-rust/Cargo.toml
--- a/necsim-rust/Cargo.toml
+++ b/necsim-rust/Cargo.toml
@@ -36,6 +36,13 @@ members = [
"rust-cuda",
"rust-cuda/rust-cuda-derive",

@@ -31,6 +31,13 @@ members = [
"rustcoalescence/algorithms/cuda",
"rustcoalescence/algorithms/cuda/gpu-kernel",
"rustcoalescence/algorithms/cuda/cpu-kernel",
+
+ "analysis/rng/randomness",
+ "analysis/rng/hash",
+ "analysis/rng/correlation",
+ "analysis/performance/exponential",
+ "analysis/performance/exponential/kernel",
+ "analysis/performance/reporting",
+
"third-party/array2d-no-std",
"third-party/contracts",
"third-party/float-next-after-no-std",
]

default-members = [
13 changes: 6 additions & 7 deletions analysis/performance/exponential/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
analysis-performance-exponential-kernel = { path = "kernel" }

necsim-core = { path = "../../../necsim/core", features = ["cuda"] }
necsim-core-bond = { path = "../../../necsim/core/bond", features = ["cuda"] }
necsim-core-bond = { path = "../../../necsim/core/bond" }
necsim-core-maths = { path = "../../../necsim/core/maths" }
necsim-impls-no-std = { path = "../../../necsim/impls/no-std" }

rust-cuda = { path = "../../../rust-cuda", features = ["host"] }

contracts = { path = "../../../third-party/contracts" }
structopt = "0.3.21"
rust-cuda = { git = "https://github.com/MomoLangenstein/rust-cuda", branch = "main", features = ["host"] }

[build-dependencies]
ptx-builder = { path = "../../../third-party/rust-ptx-builder" }
structopt = "0.3"
7 changes: 0 additions & 7 deletions analysis/performance/exponential/build.rs

This file was deleted.

2 changes: 1 addition & 1 deletion analysis/performance/exponential/kernel/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pipelining = false

[target.nvptx64-nvidia-cuda]
rustflags = ["-Clink-args=--arch sm_35", "-Cpanic=abort", "-Clto=no", "-Clink-arg=-Olto"]
rustflags = ["-Clink-args=--arch=sm_35", "-Cpanic=abort", "-Clinker-plugin-lto", "-Ccodegen-units=1", "-Clink-arg=-Olto"]

[unstable]
build-std = ["core", "alloc"]
Expand Down
9 changes: 6 additions & 3 deletions analysis/performance/exponential/kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ authors = ["Momo Langenstein <ml5717@ic.ac.uk>"]
license = "MIT OR Apache-2.0"
edition = "2018"

[lib]
crate-type = ["cdylib", "rlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
necsim-core = { path = "../../../../necsim/core", features = ["cuda"] }
necsim-core-bond = { path = "../../../../necsim/core/bond", features = ["cuda"] }
rust-cuda = { path = "../../../../rust-cuda", features = [] }
necsim-core-bond = { path = "../../../../necsim/core/bond" }
rust-cuda = { git = "https://github.com/MomoLangenstein/rust-cuda", branch = "main", features = [] }
necsim-impls-no-std = { path = "../../../../necsim/impls/no-std", features = ["cuda"] }
necsim-impls-cuda = { path = "../../../../necsim/impls/cuda" }
contracts = { path = "../../../../third-party/contracts" }
contracts = "0.6.3"
55 changes: 55 additions & 0 deletions analysis/performance/exponential/kernel/src/benchmark.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use core::{
num::NonZeroU32,
sync::atomic::{AtomicU64, Ordering},
};

use necsim_core::{
cogs::SeedableRng,
landscape::{IndexedLocation, Location},
};
use necsim_core_bond::{OffByOneU32, PositiveF64};

use necsim_impls_cuda::cogs::maths::NvptxMathsCore;
use necsim_impls_no_std::cogs::{
active_lineage_sampler::independent::event_time_sampler::EventTimeSampler,
habitat::non_spatial::NonSpatialHabitat, rng::wyhash::WyHash,
};

use crate::{sample, UniformTurnoverRate};

#[inline]
#[allow(dead_code)]
pub fn inter_event_times<
E: EventTimeSampler<
NvptxMathsCore,
NonSpatialHabitat<NvptxMathsCore>,
WyHash<NvptxMathsCore>,
UniformTurnoverRate,
>,
>(
event_time_sampler: E,
seed: u64,
lambda: PositiveF64,
limit: u128,
total_cycles_sum: &AtomicU64,
total_time_sum: &AtomicU64,
) {
let habitat = NonSpatialHabitat::new((OffByOneU32::one(), OffByOneU32::one()), unsafe {
NonZeroU32::new_unchecked(1)
});
let rng = WyHash::seed_from_u64(seed + (rust_cuda::device::utils::index() as u64));
let turnover_rate = UniformTurnoverRate::new(lambda);
let indexed_location = IndexedLocation::new(Location::new(0, 0), 0);

let (cycles, time) = sample::exponential_inter_event_times(
habitat,
rng,
turnover_rate,
event_time_sampler,
indexed_location,
limit,
);

total_cycles_sum.fetch_add(cycles, Ordering::Relaxed);
total_time_sum.fetch_add(time, Ordering::Relaxed);
}
17 changes: 17 additions & 0 deletions analysis/performance/exponential/kernel/src/clock.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// A predefined, read-only 64-bit unsigned cycle counter.
#[inline]
#[must_use]
pub fn counter() -> u64 {
let counter: u64;
unsafe { core::arch::asm!("mov.u64 {}, %clock64;", out(reg64) counter, options(nostack)) };
counter
}

/// A predefined, 64-bit global nanosecond timer.
#[inline]
#[must_use]
pub fn timer_ns() -> u64 {
let timer: u64;
unsafe { core::arch::asm!("mov.u64 {}, %globaltimer;", out(reg64) timer, options(nostack)) };
timer
}
Loading