Skip to content

Commit

Permalink
Try with latest rust-cuda without TAIT
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Jan 10, 2024
1 parent 52f4ce2 commit 83371a5
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 52 deletions.
8 changes: 5 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions necsim/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ 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 = "dd9507d", features = ["derive"], optional = true }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["derive"], optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "dd9507d", features = ["derive", "host"], optional = true }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["derive", "host"], optional = true }
4 changes: 2 additions & 2 deletions necsim/impls/cuda/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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 = "dd9507d", features = ["derive"] }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["derive"] }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "dd9507d", features = ["derive", "host"] }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["derive", "host"] }
4 changes: 2 additions & 2 deletions necsim/impls/no-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fnv = { version = "1.0", default-features = false, features = [] }
rand_core = "0.6"

[target.'cfg(target_os = "cuda")'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "dd9507d", features = ["derive", "final"], optional = true }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["derive", "final"], optional = true }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "dd9507d", features = ["derive", "final", "host"], optional = true }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["derive", "final", "host"], optional = true }
9 changes: 9 additions & 0 deletions rustcoalescence/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ edition = "2021"
[features]
default = []

necsim-partitioning-mpi = ["dep:necsim-partitioning-mpi"]

rustcoalescence-algorithms-gillespie = ["dep:rustcoalescence-algorithms-gillespie"]
rustcoalescence-algorithms-independent = ["dep:rustcoalescence-algorithms-independent"]
rustcoalescence-algorithms-cuda = ["dep:rustcoalescence-algorithms-cuda", "dep:necsim-impls-cuda", "dep:rust-cuda"]

[dependencies]
necsim-core = { path = "../necsim/core" }
necsim-core-bond = { path = "../necsim/core/bond" }
necsim-impls-cuda = { path = "../necsim/impls/cuda", optional = true }
necsim-impls-no-std = { path = "../necsim/impls/no-std" }
necsim-impls-std = { path = "../necsim/impls/std" }
necsim-plugins-core = { path = "../necsim/plugins/core", features = ["import"] }
Expand All @@ -22,6 +29,8 @@ necsim-partitioning-monolithic = { path = "../necsim/partitioning/monolithic" }
rustcoalescence-scenarios = { path = "scenarios" }
rustcoalescence-algorithms = { path = "algorithms" }

rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = [], optional = true }

necsim-partitioning-mpi = { path = "../necsim/partitioning/mpi", optional = true }

rustcoalescence-algorithms-gillespie = { path = "algorithms/gillespie", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion rustcoalescence/algorithms/cuda/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ thiserror = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_state = "0.4"
serde_derive_state = "0.4"
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "dd9507d", features = ["host"] }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["host"] }
2 changes: 1 addition & 1 deletion rustcoalescence/algorithms/cuda/cpu-kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ necsim-impls-no-std = { path = "../../../../necsim/impls/no-std", features = ["c
necsim-impls-cuda = { path = "../../../../necsim/impls/cuda" }
rustcoalescence-algorithms-cuda-gpu-kernel = { path = "../gpu-kernel" }

rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "dd9507d", features = ["host"] }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["host"] }
50 changes: 34 additions & 16 deletions rustcoalescence/algorithms/cuda/cpu-kernel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ use necsim_impls_no_std::cogs::{

use rust_cuda::lend::RustToCuda;

use rustcoalescence_algorithms_cuda_gpu_kernel::simulate;

mod link;
mod patch;

#[allow(clippy::type_complexity)]
pub struct SimulationKernelPtx<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
M: MathsCore + Sync,
H: Habitat<M> + RustToCuda + Sync,
G: PrimeableRng<M> + RustToCuda + Sync,
Expand All @@ -38,20 +47,29 @@ pub struct SimulationKernelPtx<
ReportSpeciation: Boolean,
ReportDispersal: Boolean,
>(
std::marker::PhantomData<(
M,
H,
G,
S,
X,
D,
C,
T,
N,
E,
I,
A,
ReportSpeciation,
ReportDispersal,
)>,
std::marker::PhantomData<
simulate<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
M,
H,
G,
S,
X,
D,
C,
T,
N,
E,
I,
A,
ReportSpeciation,
ReportDispersal,
>,
>,
);
14 changes: 14 additions & 0 deletions rustcoalescence/algorithms/cuda/cpu-kernel/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ macro_rules! link_kernel {
$report_speciation:ty, $report_dispersal:ty
) => {
rustcoalescence_algorithms_cuda_gpu_kernel::link! { impl simulate<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
necsim_impls_cuda::cogs::maths::NvptxMathsCore,
$habitat,
necsim_impls_cuda::cogs::rng::CudaRng<
Expand Down Expand Up @@ -83,6 +90,13 @@ macro_rules! link_kernel {
> for SimulationKernelPtx }

rustcoalescence_algorithms_cuda_gpu_kernel::link! { impl simulate<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
necsim_impls_cuda::cogs::maths::NvptxMathsCore,
$habitat,
necsim_impls_cuda::cogs::rng::CudaRng<
Expand Down
143 changes: 133 additions & 10 deletions rustcoalescence/algorithms/cuda/cpu-kernel/src/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ extern "C" {

#[allow(clippy::trait_duplication_in_bounds)]
unsafe impl<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
M: MathsCore + Sync,
H: Habitat<M> + RustToCuda + Sync,
G: PrimeableRng<M> + RustToCuda + Sync,
Expand All @@ -45,17 +52,133 @@ unsafe impl<
ReportDispersal: Boolean,
>
CompiledKernelPtx<
simulate<M, H, G, S, X, D, C, T, N, E, I, A, ReportSpeciation, ReportDispersal>,
> for SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, ReportSpeciation, ReportDispersal>
simulate<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
M,
H,
G,
S,
X,
D,
C,
T,
N,
E,
I,
A,
ReportSpeciation,
ReportDispersal,
>,
>
for SimulationKernelPtx<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
M,
H,
G,
S,
X,
D,
C,
T,
N,
E,
I,
A,
ReportSpeciation,
ReportDispersal,
>
where
SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, False, False>:
CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, False, False>>,
SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, False, True>:
CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, False, True>>,
SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, True, False>:
CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, True, False>>,
SimulationKernelPtx<M, H, G, S, X, D, C, T, N, E, I, A, True, True>:
CompiledKernelPtx<simulate<M, H, G, S, X, D, C, T, N, E, I, A, True, True>>,
SimulationKernelPtx<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
M,
H,
G,
S,
X,
D,
C,
T,
N,
E,
I,
A,
False,
False,
>: CompiledKernelPtx<
simulate<'a, 'b, 'c, 'd, 'e, 'f, 'g, M, H, G, S, X, D, C, T, N, E, I, A, False, False>,
>,
SimulationKernelPtx<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
M,
H,
G,
S,
X,
D,
C,
T,
N,
E,
I,
A,
False,
True,
>: CompiledKernelPtx<
simulate<'a, 'b, 'c, 'd, 'e, 'f, 'g, M, H, G, S, X, D, C, T, N, E, I, A, False, True>,
>,
SimulationKernelPtx<
'a,
'b,
'c,
'd,
'e,
'f,
'g,
M,
H,
G,
S,
X,
D,
C,
T,
N,
E,
I,
A,
True,
False,
>: CompiledKernelPtx<
simulate<'a, 'b, 'c, 'd, 'e, 'f, 'g, M, H, G, S, X, D, C, T, N, E, I, A, True, False>,
>,
SimulationKernelPtx<'a, 'b, 'c, 'd, 'e, 'f, 'g, M, H, G, S, X, D, C, T, N, E, I, A, True, True>:
CompiledKernelPtx<
simulate<'a, 'b, 'c, 'd, 'e, 'f, 'g, M, H, G, S, X, D, C, T, N, E, I, A, True, True>,
>,
{
default fn get_ptx() -> &'static CStr {
unsafe { unreachable_cuda_simulation_linking_reporter() }
Expand Down
4 changes: 2 additions & 2 deletions rustcoalescence/algorithms/cuda/gpu-kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ necsim-impls-no-std = { path = "../../../../necsim/impls/no-std", features = ["c
necsim-impls-cuda = { path = "../../../../necsim/impls/cuda" }

[target.'cfg(target_os = "cuda")'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "dd9507d", features = ["derive", "device", "kernel"] }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["derive", "device", "kernel"] }

[target.'cfg(not(target_os = "cuda"))'.dependencies]
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "dd9507d", features = ["derive", "kernel"] }
rust-cuda = { git = "https://github.com/juntyr/rust-cuda", rev = "57ed62c", features = ["derive", "kernel"] }
Loading

0 comments on commit 83371a5

Please sign in to comment.