Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ca0f10f
Initial progress towards using rust-cuda with async
juntyr Jan 7, 2024
29b098e
Some progress
juntyr Jan 8, 2024
52f4ce2
Further async integration progress, rustcoalescence fails to compile
juntyr Jan 9, 2024
5cd2354
Some progress with dispatch coersion
juntyr Jan 10, 2024
65ed1c8
Small cleanup
juntyr Jan 10, 2024
b6dd445
Cleanup cuda algorithm coersion
juntyr Jan 11, 2024
775094a
Some more cleanup
juntyr Jan 11, 2024
352b4e7
Add back missing Backup for SeaHash and WyHash rngs
juntyr Jan 11, 2024
b24a056
Fix CUDA kernel extraneous pub exports
juntyr Jan 12, 2024
a632584
Minor improvement of the event buffer hack
juntyr Jan 12, 2024
8c2cc90
Remove unused control_flow_enum feature
juntyr Jan 12, 2024
7fbf443
Revert Copy for [Indexed]Location
juntyr Jan 12, 2024
be20a8d
Revert new clone
juntyr Jan 12, 2024
7d2633c
Update to rust-cuda with async kernel launch async return
juntyr Jan 13, 2024
10acf51
Update to latest rust-cuda
juntyr Jan 14, 2024
a809f61
Fix rustfmt
juntyr Jan 14, 2024
4e79d0c
Temporary fix to allow CUDA algorithm linking
juntyr Jan 16, 2024
4673ccf
Small cleanup, mostly of unused clippy allows
juntyr Jan 18, 2024
7a25f70
Small improvement to CUDA EventBuffer
juntyr Jan 18, 2024
387e4b6
Try trait-based kernel signature check
juntyr Jan 20, 2024
f5f490c
Update rust-toolchain
juntyr Jan 20, 2024
9db2ef5
Fix clippy lints
juntyr Jan 20, 2024
064d798
Try with const match instead
juntyr Jan 21, 2024
9705e28
Try with memcmp intrinsic
juntyr Jan 21, 2024
8306317
Try out experimental const-type-layout with compression
juntyr Feb 1, 2024
c650a4e
Try interning all const layout strings
juntyr Feb 2, 2024
ccb2b8a
Try check
juntyr Feb 5, 2024
d494d5c
Try check again
juntyr Feb 5, 2024
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
396 changes: 305 additions & 91 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions necsim/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ cuda = ["rust-cuda"]
necsim-core-maths = { path = "maths" }
necsim-core-bond = { path = "bond" }

const-type-layout = { version = "0.2.0", features = ["derive"] }
const-type-layout = { git = "https://github.com/juntyr/const-type-layout", branch = "compress", features = ["derive"] }
contracts = "0.6.3"
serde = { version = "1.0", default-features = false, features = ["derive"] }

[target.'cfg(target_os = "cuda")'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "6b53e88", features = ["derive"], optional = true }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "6311a6d4", features = ["derive"], optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "6b53e88", features = ["derive", "host"], optional = true }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "6311a6d4", features = ["derive", "host"], optional = true }
2 changes: 1 addition & 1 deletion necsim/core/bond/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ default = []
[dependencies]
necsim-core-maths = { path = "../maths" }

const-type-layout = { version = "0.2.0", features = ["derive"] }
const-type-layout = { git = "https://github.com/juntyr/const-type-layout", branch = "compress", features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }
1 change: 1 addition & 0 deletions necsim/core/bond/src/closed_open_unit_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl ClosedOpenUnitF64 {
}

impl PartialEq for ClosedOpenUnitF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
1 change: 1 addition & 0 deletions necsim/core/bond/src/closed_unit_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl From<ClosedOpenUnitF64> for ClosedUnitF64 {
}

impl PartialEq for ClosedUnitF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
1 change: 0 additions & 1 deletion necsim/core/bond/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#![feature(const_float_bits_conv)]
#![feature(const_float_classify)]
#![feature(const_type_name)]
#![feature(offset_of)]

#[macro_use]
extern crate const_type_layout;
Expand Down
1 change: 1 addition & 0 deletions necsim/core/bond/src/non_negative_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl From<ClosedOpenUnitF64> for NonNegativeF64 {
}

impl PartialEq for NonNegativeF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
1 change: 1 addition & 0 deletions necsim/core/bond/src/non_positive_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl NonPositiveF64 {
}

impl PartialEq for NonPositiveF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
1 change: 1 addition & 0 deletions necsim/core/bond/src/open_closed_unit_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl OpenClosedUnitF64 {
}

impl PartialEq for OpenClosedUnitF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
1 change: 1 addition & 0 deletions necsim/core/bond/src/positive_f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl From<NonZeroU64> for PositiveF64 {
}

impl PartialEq for PositiveF64 {
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
Expand Down
1 change: 1 addition & 0 deletions necsim/core/maths/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![deny(clippy::pedantic)]
#![no_std]
#![allow(internal_features)]
#![feature(core_intrinsics)]

pub trait MathsCore: 'static + Clone + core::fmt::Debug {
Expand Down
1 change: 0 additions & 1 deletion necsim/core/src/cogs/coalescence_sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub trait CoalescenceSampler<M: MathsCore, H: Habitat<M>, S: LineageStore<M, H>>
) -> (IndexedLocation, LineageInteraction);
}

#[allow(clippy::unsafe_derive_deserialize)]
#[derive(Debug, PartialEq, Serialize, Deserialize, TypeLayout)]
#[repr(transparent)]
pub struct CoalescenceRngSample(ClosedOpenUnitF64);
Expand Down
1 change: 0 additions & 1 deletion necsim/core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ pub struct Dispersal {
}

#[allow(clippy::module_name_repetitions)]
#[allow(clippy::unsafe_derive_deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, TypeLayout)]
#[repr(C)]
pub struct SpeciationEvent {
Expand Down
5 changes: 3 additions & 2 deletions necsim/core/src/landscape/extent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ use necsim_core_bond::OffByOneU32;

use super::Location;

#[allow(clippy::module_name_repetitions, clippy::unsafe_derive_deserialize)]
#[allow(clippy::module_name_repetitions)]
#[derive(PartialEq, Eq, Clone, Debug, serde::Deserialize, serde::Serialize, TypeLayout)]
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
#[cfg_attr(feature = "cuda", cuda(ignore))]
#[serde(rename = "Extent")]
#[serde(deny_unknown_fields)]
#[repr(C)]
pub struct LandscapeExtent {
x: u32,
y: u32,
Expand Down
14 changes: 9 additions & 5 deletions necsim/core/src/landscape/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ use serde::{Deserialize, Serialize};

use crate::cogs::Backup;

#[allow(clippy::unsafe_derive_deserialize)]
#[allow(clippy::module_name_repetitions)]
#[derive(
Eq, PartialEq, PartialOrd, Ord, Clone, Hash, Debug, Serialize, Deserialize, TypeLayout,
)]
#[serde(deny_unknown_fields)]
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
#[repr(C)]
#[cfg_attr(feature = "cuda", cuda(ignore))]
#[serde(deny_unknown_fields)]
pub struct Location {
x: u32,
y: u32,
Expand Down Expand Up @@ -46,10 +48,13 @@ impl From<IndexedLocation> for Location {
#[derive(
Eq, PartialEq, PartialOrd, Ord, Clone, Hash, Debug, Serialize, Deserialize, TypeLayout,
)]
#[allow(clippy::module_name_repetitions, clippy::unsafe_derive_deserialize)]
#[serde(from = "IndexedLocationRaw", into = "IndexedLocationRaw")]
#[allow(clippy::module_name_repetitions)]
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
#[repr(C)]
#[cfg_attr(feature = "cuda", cuda(ignore))]
#[serde(from = "IndexedLocationRaw", into = "IndexedLocationRaw")]
pub struct IndexedLocation {
#[cfg_attr(feature = "cuda", cuda(embed))]
location: Location,
index: u32,
}
Expand All @@ -74,7 +79,6 @@ impl IndexedLocation {
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
#[serde(rename = "IndexedLocation")]
#[repr(C)]
struct IndexedLocationRaw {
x: u32,
y: u32,
Expand Down
2 changes: 1 addition & 1 deletion necsim/core/src/landscape/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod extent;
mod location;

#[allow(clippy::useless_attribute, clippy::module_name_repetitions)]
#[allow(clippy::module_name_repetitions)]
pub use extent::{LandscapeExtent, LocationIterator};
pub use location::{IndexedLocation, Location};
2 changes: 0 additions & 2 deletions necsim/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![deny(clippy::pedantic)]
#![no_std]
#![feature(const_type_name)]
#![feature(offset_of)]
#![feature(control_flow_enum)]
#![feature(min_specialization)]

#[doc(hidden)]
Expand Down
13 changes: 11 additions & 2 deletions necsim/core/src/lineage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{
};

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, TypeLayout)]
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
#[repr(transparent)]
pub struct GlobalLineageReference(u64);

Expand Down Expand Up @@ -94,21 +95,29 @@ impl From<Option<GlobalLineageReference>> for LineageInteraction {
}
}

#[allow(clippy::unsafe_derive_deserialize)]
#[allow(clippy::module_name_repetitions)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TypeLayout)]
#[serde(deny_unknown_fields)]
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
#[repr(C)]
#[cfg_attr(feature = "cuda", cuda(ignore))]
#[serde(deny_unknown_fields)]
pub struct Lineage {
#[cfg_attr(feature = "cuda", cuda(embed))]
#[cfg_attr(feature = "cuda", cuda(ignore))]
#[serde(alias = "id", alias = "ref")]
pub global_reference: GlobalLineageReference,
#[cfg_attr(feature = "cuda", cuda(ignore))]
#[serde(alias = "time")]
pub last_event_time: NonNegativeF64,
#[cfg_attr(feature = "cuda", cuda(embed))]
#[cfg_attr(feature = "cuda", cuda(ignore))]
#[serde(alias = "loc")]
pub indexed_location: IndexedLocation,
}

impl Lineage {
#[must_use]
#[allow(clippy::no_effect_underscore_binding)]
#[debug_ensures(
ret.indexed_location == old(indexed_location.clone()),
"stores the indexed_location"
Expand Down
2 changes: 1 addition & 1 deletion necsim/core/src/reporter/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod private {
impl Sealed for super::False {}
}

pub trait Boolean: private::Sealed {
pub trait Boolean: 'static + private::Sealed {
const VALUE: bool;
}

Expand Down
6 changes: 3 additions & 3 deletions necsim/core/src/reporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use used::MaybeUsed;
pub mod boolean;
pub mod used;

#[allow(clippy::useless_attribute, clippy::module_name_repetitions)]
#[allow(clippy::module_name_repetitions)]
pub use combinator::ReporterCombinator;
#[allow(clippy::useless_attribute, clippy::module_name_repetitions)]
#[allow(clippy::module_name_repetitions)]
pub use filter::FilteredReporter;
#[allow(clippy::useless_attribute, clippy::module_name_repetitions)]
#[allow(clippy::module_name_repetitions)]
pub use null::NullReporter;

pub trait Reporter: core::fmt::Debug {
Expand Down
2 changes: 1 addition & 1 deletion necsim/core/src/simulation/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<
}

#[derive(Debug, TypeLayout)]
#[cfg_attr(feature = "cuda", derive(rust_cuda::common::LendRustToCuda))]
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
#[cfg_attr(feature = "cuda", cuda(free = "M"))]
#[repr(C)]
pub struct Simulation<
Expand Down
12 changes: 8 additions & 4 deletions necsim/core/src/simulation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
reporter::Reporter,
};

#[allow(clippy::useless_attribute, clippy::module_name_repetitions)]
#[allow(clippy::module_name_repetitions)]
pub use builder::{Simulation, SimulationBuilder};
use necsim_core_bond::{NonNegativeF64, PositiveF64};

Expand Down Expand Up @@ -51,7 +51,7 @@ impl<

#[inline]
pub fn simulate_incremental_early_stop<
F: FnMut(&Self, u64, PositiveF64) -> ControlFlow<(), ()>,
F: FnMut(&Self, u64, PositiveF64, &P) -> ControlFlow<(), ()>,
P: Reporter,
>(
&mut self,
Expand All @@ -69,13 +69,17 @@ impl<
.map(|lineage| (lineage.event_time, lineage.tie_breaker));

let self_ptr = self as *const Self;
let reporter_ptr = reporter as *const P;

let old_rng = unsafe { self.rng.backup_unchecked() };
let mut early_stop_flow = ControlFlow::Continue(());

let early_peek_stop = |next_event_time| {
// Safety: We are only passing in an immutable reference
early_stop_flow = early_stop(unsafe { &*self_ptr }, steps, next_event_time);
early_stop_flow =
early_stop(unsafe { &*self_ptr }, steps, next_event_time, unsafe {
&*reporter_ptr
});

if early_stop_flow.is_break() {
return ControlFlow::Break(());
Expand Down Expand Up @@ -131,6 +135,6 @@ impl<

#[inline]
pub fn simulate<P: Reporter>(mut self, reporter: &mut P) -> (NonNegativeF64, u64) {
self.simulate_incremental_early_stop(|_, _, _| ControlFlow::Continue(()), reporter)
self.simulate_incremental_early_stop(|_, _, _, _| ControlFlow::Continue(()), reporter)
}
}
6 changes: 3 additions & 3 deletions necsim/impls/cuda/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ edition = "2021"
[dependencies]
necsim-core = { path = "../../core", features = ["cuda"] }

const-type-layout = { version = "0.2.0", features = ["derive"] }
const-type-layout = { git = "https://github.com/juntyr/const-type-layout", branch = "compress", features = ["derive"] }
contracts = "0.6.3"
serde = { version = "1.0", default-features = false, features = ["derive"] }

[target.'cfg(target_os = "cuda")'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "6b53e88", features = ["derive"] }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "6311a6d4", features = ["derive"] }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "6b53e88", features = ["derive", "host"] }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "6311a6d4", features = ["derive", "host"] }
11 changes: 7 additions & 4 deletions necsim/impls/cuda/src/cogs/maths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ impl MathsCore for NvptxMathsCore {
}
#[cfg(not(target_os = "cuda"))]
{
extern "C" {
fn nvptx_maths_core_ln_on_cpu(_x: f64) -> !;
}
// extern "C" {
// fn nvptx_maths_core_ln_on_cpu(_x: f64) -> !;
// }

// unsafe { nvptx_maths_core_ln_on_cpu(x) }

unsafe { nvptx_maths_core_ln_on_cpu(x) }
// TODO: disallow using NvptxMathsCore::ln on CPU
unsafe { core::intrinsics::logf64(x) }
}
}

Expand Down
Loading