Skip to content

Commit 5cd2354

Browse files
committed
Some progress with dispatch coersion
1 parent 52f4ce2 commit 5cd2354

File tree

7 files changed

+64
-12
lines changed

7 files changed

+64
-12
lines changed

Cargo.lock

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

rustcoalescence/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@ edition = "2021"
1010
[features]
1111
default = []
1212

13+
necsim-partitioning-mpi = ["dep:necsim-partitioning-mpi"]
14+
15+
rustcoalescence-algorithms-gillespie = ["dep:rustcoalescence-algorithms-gillespie"]
16+
rustcoalescence-algorithms-independent = ["dep:rustcoalescence-algorithms-independent"]
17+
rustcoalescence-algorithms-cuda = ["dep:rustcoalescence-algorithms-cuda", "dep:necsim-impls-cuda", "dep:rust-cuda"]
18+
1319
[dependencies]
1420
necsim-core = { path = "../necsim/core" }
1521
necsim-core-bond = { path = "../necsim/core/bond" }
1622
necsim-impls-no-std = { path = "../necsim/impls/no-std" }
23+
necsim-impls-cuda = { path = "../necsim/impls/cuda", optional = true }
1724
necsim-impls-std = { path = "../necsim/impls/std" }
1825
necsim-plugins-core = { path = "../necsim/plugins/core", features = ["import"] }
1926
necsim-partitioning-core = { path = "../necsim/partitioning/core" }
@@ -28,6 +35,8 @@ rustcoalescence-algorithms-gillespie = { path = "algorithms/gillespie", optional
2835
rustcoalescence-algorithms-independent = { path = "algorithms/independent", optional = true }
2936
rustcoalescence-algorithms-cuda = { path = "algorithms/cuda", optional = true }
3037

38+
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "dd9507d", features = [], optional = true }
39+
3140
clap = { version = "4.0", features = ["derive"] }
3241
anyhow = "1.0"
3342
serde = { version = "1.0", features = ["derive"] }

rustcoalescence/algorithms/cuda/cpu-kernel/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![deny(clippy::pedantic)]
22
#![feature(c_str_literals)]
33
#![feature(min_specialization)]
4+
#![allow(long_running_const_eval)]
45
#![recursion_limit = "1024"]
56

67
use necsim_core::{

rustcoalescence/algorithms/cuda/cpu-kernel/src/patch.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ unsafe impl<
4848
simulate<M, H, G, S, X, D, C, T, N, E, I, A, ReportSpeciation, ReportDispersal>,
4949
> for SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, ReportSpeciation, ReportDispersal>
5050
where
51-
SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, False, False>:
52-
CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, False, False>>,
53-
SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, False, True>:
54-
CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, False, True>>,
55-
SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, True, False>:
56-
CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, True, False>>,
57-
SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, True, True>:
58-
CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, True, True>>,
51+
// SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, False, False>:
52+
// CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, False, False>>,
53+
// SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, False, True>:
54+
// CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, False, True>>,
55+
// SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, True, False>:
56+
// CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, True, False>>,
57+
// SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, True, True>:
58+
// CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, True, True>>,
5959
{
6060
default fn get_ptx() -> &'static CStr {
6161
unsafe { unreachable_cuda_simulation_linking_reporter() }

rustcoalescence/algorithms/cuda/gpu-kernel/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![feature(decl_macro)]
55
#![feature(c_str_literals)]
66
#![cfg_attr(target_os = "cuda", feature(abi_ptx))]
7+
#![cfg_attr(target_os = "cuda", feature(asm_experimental_arch))]
78
#![cfg_attr(target_os = "cuda", feature(alloc_error_handler))]
89
#![allow(long_running_const_eval)]
910
#![recursion_limit = "1024"]

rustcoalescence/algorithms/cuda/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ where
398398
_,
399399
_,
400400
_,
401-
<FixUpInitialiser<L> as CudaLineageStoreSampleInitialiser<_, _, O, _>>::ActiveLineageSampler<_, ExpEventTimeSampler>,
401+
<FixUpInitialiser<L> as CudaLineageStoreSampleInitialiser<_, _, O, _>>::ActiveLineageSampler<_, ConstEventTimeSampler>,
402402
_,
403403
_,
404404
>>(

rustcoalescence/src/cli/simulate/dispatch/valid/algorithm_scenario.rs

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ macro_rules! match_scenario_algorithm {
103103
}
104104

105105
#[allow(clippy::too_many_arguments)]
106+
#[allow(clippy::too_many_lines)] // FIXME
106107
pub(super) fn dispatch<'p, R: Reporter, P: LocalPartition<'p, R>>(
107108
local_partition: P,
108109

@@ -150,9 +151,47 @@ pub(super) fn dispatch<'p, R: Reporter, P: LocalPartition<'p, R>>(
150151
},
151152
#[cfg(feature = "rustcoalescence-algorithms-cuda")]
152153
AlgorithmArgs::Cuda(algorithm_args) => {
153-
rng::dispatch::<
154-
<CudaAlgorithm as AlgorithmDefaults>::MathsCore,
155-
CudaAlgorithm, _, R, P,
154+
fn coerce_cuda_dispatch<
155+
'p,
156+
M: necsim_core::cogs::MathsCore + Sync,
157+
O: Scenario<M, necsim_impls_cuda::cogs::rng::CudaRng<
158+
M, necsim_impls_no_std::cogs::rng::wyhash::WyHash<M>,
159+
>>,
160+
R: Reporter,
161+
P: LocalPartition<'p, R>,
162+
>(
163+
local_partition: P,
164+
165+
sample: crate::args::config::sample::Sample,
166+
algorithm_args: <CudaAlgorithm as rustcoalescence_algorithms::AlgorithmParamters>::Arguments,
167+
scenario: O,
168+
pause_before: Option<NonNegativeF64>,
169+
170+
ron_args: &str,
171+
normalised_args: &mut BufferingSimulateArgsBuilder,
172+
) -> anyhow::Result<SimulationOutcome> where
173+
O::Habitat: rust_cuda::lend::RustToCuda + Sync,
174+
O::DispersalSampler<
175+
necsim_impls_no_std::cogs::dispersal_sampler::in_memory::packed_alias::InMemoryPackedAliasDispersalSampler<
176+
M, O::Habitat, necsim_impls_cuda::cogs::rng::CudaRng<
177+
M, necsim_impls_no_std::cogs::rng::wyhash::WyHash<M>,
178+
>
179+
>
180+
>: rust_cuda::lend::RustToCuda + Sync,
181+
O::TurnoverRate: rust_cuda::lend::RustToCuda + Sync,
182+
O::SpeciationProbability: rust_cuda::lend::RustToCuda + Sync,
183+
{
184+
rng::dispatch::<
185+
M,
186+
CudaAlgorithm, _, R, P,
187+
>(
188+
local_partition, sample, algorithm_args, scenario,
189+
pause_before, ron_args, normalised_args,
190+
)
191+
}
192+
193+
coerce_cuda_dispatch::<
194+
<CudaAlgorithm as AlgorithmDefaults>::MathsCore, _, R, P,
156195
>(
157196
local_partition, sample, algorithm_args, scenario,
158197
pause_before, ron_args, normalised_args,

0 commit comments

Comments
 (0)