Skip to content

Commit ca0f10f

Browse files
committed
Initial progress towards using rust-cuda with async
1 parent a9e2b3f commit ca0f10f

File tree

77 files changed

+490
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+490
-244
lines changed

Cargo.lock

Lines changed: 238 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

necsim/core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ contracts = "0.6.3"
2020
serde = { version = "1.0", default-features = false, features = ["derive"] }
2121

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

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

necsim/core/src/cogs/emigration_exit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ pub trait EmigrationExit<M: MathsCore, H: Habitat<M>, G: RngCore<M>, S: LineageS
2727
ret_event_time,
2828
)) => {
2929
ret_lineage_reference == &old(global_reference.clone()) &&
30-
ret_dispersal_origin == &old(dispersal_origin.clone()) &&
31-
ret_dispersal_target == &old(dispersal_target.clone()) &&
30+
ret_dispersal_origin == &old(dispersal_origin) &&
31+
ret_dispersal_target == &old(dispersal_target) &&
3232
ret_prior_time == &old(prior_time) &&
3333
ret_event_time == &old(event_time)
3434
},

necsim/core/src/cogs/lineage_store.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ pub trait LocallyCoherentLineageStore<M: MathsCore, H: Habitat<M>>:
4949
&ret
5050
).is_some(), "lineage was activated")]
5151
#[debug_ensures(
52-
self[&ret].indexed_location == old(lineage.indexed_location.clone()),
52+
self[&ret].indexed_location == old(lineage.indexed_location),
5353
"lineage was added to indexed_location"
5454
)]
5555
#[debug_ensures(
5656
self.get_global_lineage_reference_at_indexed_location(
57-
&old(lineage.indexed_location.clone()), old(habitat)
57+
&old(lineage.indexed_location), old(habitat)
5858
) == Some(&self[&ret].global_reference),
5959
"lineage is now indexed at indexed_location"
6060
)]
@@ -117,15 +117,15 @@ pub trait GloballyCoherentLineageStore<M: MathsCore, H: Habitat<M>>:
117117

118118
#[debug_ensures(
119119
self.get_local_lineage_references_at_location_unordered(
120-
&old(lineage.indexed_location.location().clone()), old(habitat)
120+
&old(*lineage.indexed_location.location()), old(habitat)
121121
).last() == Some(&ret),
122122
"lineage is now indexed unordered at indexed_location.location()"
123123
)]
124124
#[debug_ensures(
125125
old(self.get_local_lineage_references_at_location_unordered(
126126
lineage.indexed_location.location(), old(habitat)
127127
).len() + 1) == self.get_local_lineage_references_at_location_unordered(
128-
&old(lineage.indexed_location.location().clone()), old(habitat)
128+
&old(*lineage.indexed_location.location()), old(habitat)
129129
).len(),
130130
"unordered active lineage index at given location has grown by 1"
131131
)]

necsim/core/src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl From<SpeciationEvent> for PackedEvent {
108108
global_lineage_reference: event.global_lineage_reference.clone(),
109109
prior_time: event.prior_time.get().make_negative(),
110110
event_time: event.event_time.get(),
111-
origin: event.origin.clone(),
111+
origin: event.origin,
112112
target: event.origin,
113113
coalescence: event.global_lineage_reference,
114114
}

necsim/core/src/landscape/extent.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use necsim_core_bond::OffByOneU32;
33
use super::Location;
44

55
#[allow(clippy::module_name_repetitions, clippy::unsafe_derive_deserialize)]
6-
#[derive(PartialEq, Eq, Clone, Debug, serde::Deserialize, serde::Serialize, TypeLayout)]
6+
#[derive(PartialEq, Eq, Copy, Clone, Debug, serde::Deserialize, serde::Serialize, TypeLayout)]
77
#[serde(rename = "Extent")]
88
#[serde(deny_unknown_fields)]
99
#[repr(C)]
@@ -58,7 +58,7 @@ impl LandscapeExtent {
5858
LocationIterator {
5959
x: self.x,
6060
y: self.y,
61-
extent: self.clone(),
61+
extent: *self,
6262
first_y: true,
6363
}
6464
}
@@ -186,7 +186,7 @@ mod tests {
186186
LocationIterator {
187187
x: 0,
188188
y: 0,
189-
extent: extent.clone(),
189+
extent,
190190
first_y: true,
191191
}
192192
);
@@ -200,7 +200,7 @@ mod tests {
200200
LocationIterator {
201201
x: 0,
202202
y: 0,
203-
extent: extent.clone(),
203+
extent,
204204
first_y: false,
205205
}
206206
);
@@ -230,7 +230,7 @@ mod tests {
230230
LocationIterator {
231231
x: 1386,
232232
y: 6812,
233-
extent: extent.clone(),
233+
extent,
234234
first_y: true,
235235
}
236236
);
@@ -242,7 +242,7 @@ mod tests {
242242
LocationIterator {
243243
x: 0,
244244
y: 6812,
245-
extent: extent.clone(),
245+
extent,
246246
first_y: true,
247247
}
248248
);
@@ -255,7 +255,7 @@ mod tests {
255255
LocationIterator {
256256
x: 1386,
257257
y: 6813,
258-
extent: extent.clone(),
258+
extent,
259259
first_y: false,
260260
}
261261
);
@@ -269,7 +269,7 @@ mod tests {
269269
LocationIterator {
270270
x: 1386,
271271
y: 0,
272-
extent: extent.clone(),
272+
extent,
273273
first_y: false,
274274
}
275275
);
@@ -283,7 +283,7 @@ mod tests {
283283
LocationIterator {
284284
x: 1386,
285285
y: 6812,
286-
extent: extent.clone(),
286+
extent,
287287
first_y: false,
288288
}
289289
);

necsim/core/src/landscape/location.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use serde::{Deserialize, Serialize};
22

3-
use crate::cogs::Backup;
4-
53
#[allow(clippy::unsafe_derive_deserialize)]
64
#[derive(
7-
Eq, PartialEq, PartialOrd, Ord, Clone, Hash, Debug, Serialize, Deserialize, TypeLayout,
5+
Eq, PartialEq, PartialOrd, Ord, Clone, Copy, Hash, Debug, Serialize, Deserialize, TypeLayout,
86
)]
97
#[serde(deny_unknown_fields)]
108
#[repr(C)]
@@ -13,13 +11,6 @@ pub struct Location {
1311
y: u32,
1412
}
1513

16-
#[contract_trait]
17-
impl Backup for Location {
18-
unsafe fn backup_unchecked(&self) -> Self {
19-
self.clone()
20-
}
21-
}
22-
2314
impl Location {
2415
#[must_use]
2516
pub const fn new(x: u32, y: u32) -> Self {
@@ -44,7 +35,7 @@ impl From<IndexedLocation> for Location {
4435
}
4536

4637
#[derive(
47-
Eq, PartialEq, PartialOrd, Ord, Clone, Hash, Debug, Serialize, Deserialize, TypeLayout,
38+
Eq, PartialEq, PartialOrd, Ord, Clone, Copy, Hash, Debug, Serialize, Deserialize, TypeLayout,
4839
)]
4940
#[allow(clippy::module_name_repetitions, clippy::unsafe_derive_deserialize)]
5041
#[serde(from = "IndexedLocationRaw", into = "IndexedLocationRaw")]

necsim/core/src/lineage.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::{
1616
};
1717

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

@@ -94,23 +95,30 @@ impl From<Option<GlobalLineageReference>> for LineageInteraction {
9495
}
9596
}
9697

97-
#[allow(clippy::unsafe_derive_deserialize)]
98+
#[allow(clippy::unsafe_derive_deserialize, clippy::module_name_repetitions)]
9899
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, TypeLayout)]
99-
#[serde(deny_unknown_fields)]
100+
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
100101
#[repr(C)]
102+
#[cuda(ignore)]
103+
#[serde(deny_unknown_fields)]
101104
pub struct Lineage {
105+
#[cuda(embed)]
106+
#[cuda(ignore)]
102107
#[serde(alias = "id", alias = "ref")]
103108
pub global_reference: GlobalLineageReference,
109+
#[cuda(ignore)]
104110
#[serde(alias = "time")]
105111
pub last_event_time: NonNegativeF64,
112+
#[cuda(ignore)]
106113
#[serde(alias = "loc")]
107114
pub indexed_location: IndexedLocation,
108115
}
109116

110117
impl Lineage {
111118
#[must_use]
119+
#[allow(clippy::no_effect_underscore_binding)]
112120
#[debug_ensures(
113-
ret.indexed_location == old(indexed_location.clone()),
121+
ret.indexed_location == old(indexed_location),
114122
"stores the indexed_location"
115123
)]
116124
#[debug_ensures(ret.last_event_time == 0.0_f64, "starts at t_0 = 0.0")]
@@ -178,8 +186,8 @@ impl Backup for MigratingLineage {
178186
unsafe fn backup_unchecked(&self) -> Self {
179187
Self {
180188
global_reference: self.global_reference.backup_unchecked(),
181-
dispersal_origin: self.dispersal_origin.clone(),
182-
dispersal_target: self.dispersal_target.clone(),
189+
dispersal_origin: self.dispersal_origin,
190+
dispersal_target: self.dispersal_target,
183191
prior_time: self.prior_time,
184192
event_time: self.event_time,
185193
coalescence_rng_sample: self.coalescence_rng_sample.backup_unchecked(),

necsim/core/src/reporter/boolean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod private {
55
impl Sealed for super::False {}
66
}
77

8-
pub trait Boolean: private::Sealed {
8+
pub trait Boolean: 'static + private::Sealed {
99
const VALUE: bool;
1010
}
1111

necsim/core/src/simulation/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<
8686
}
8787

8888
#[derive(Debug, TypeLayout)]
89-
#[cfg_attr(feature = "cuda", derive(rust_cuda::common::LendRustToCuda))]
89+
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
9090
#[cfg_attr(feature = "cuda", cuda(free = "M"))]
9191
#[repr(C)]
9292
pub struct Simulation<

0 commit comments

Comments
 (0)