Skip to content

Commit

Permalink
Switch to using the packed separable alias dispersal sampler, as it i…
Browse files Browse the repository at this point in the history
…s general and optimised for all cases
  • Loading branch information
juntyr committed May 28, 2024
1 parent 92b9269 commit 56c0bbc
Show file tree
Hide file tree
Showing 28 changed files with 158 additions and 113 deletions.
4 changes: 2 additions & 2 deletions rustcoalescence/algorithms/cuda/cpu-kernel/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ link_kernel!(
necsim_impls_no_std::cogs::habitat::in_memory::InMemoryHabitat<
necsim_impls_cuda::cogs::maths::NvptxMathsCore
>,
necsim_impls_no_std::cogs::dispersal_sampler::in_memory::packed_alias::InMemoryPackedAliasDispersalSampler<
necsim_impls_no_std::cogs::dispersal_sampler::in_memory::packed_separable_alias::InMemoryPackedSeparableAliasDispersalSampler<
necsim_impls_cuda::cogs::maths::NvptxMathsCore,
necsim_impls_no_std::cogs::habitat::in_memory::InMemoryHabitat<
necsim_impls_cuda::cogs::maths::NvptxMathsCore
Expand All @@ -346,7 +346,7 @@ link_kernel!(
necsim_impls_no_std::cogs::habitat::in_memory::InMemoryHabitat<
necsim_impls_cuda::cogs::maths::NvptxMathsCore
>,
necsim_impls_no_std::cogs::dispersal_sampler::in_memory::packed_alias::InMemoryPackedAliasDispersalSampler<
necsim_impls_no_std::cogs::dispersal_sampler::in_memory::packed_separable_alias::InMemoryPackedSeparableAliasDispersalSampler<
necsim_impls_cuda::cogs::maths::NvptxMathsCore,
necsim_impls_no_std::cogs::habitat::in_memory::InMemoryHabitat<
necsim_impls_cuda::cogs::maths::NvptxMathsCore
Expand Down
9 changes: 5 additions & 4 deletions rustcoalescence/algorithms/cuda/src/initialiser/fixup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use necsim_impls_no_std::cogs::{
resuming::lineage::{ExceptionalLineage, SplitExceptionalLineages},
},
dispersal_sampler::{
in_memory::packed_alias::InMemoryPackedAliasDispersalSampler,
in_memory::packed_separable_alias::InMemoryPackedSeparableAliasDispersalSampler,
trespassing::{
uniform::UniformAntiTrespassingDispersalSampler, TrespassingDispersalSampler,
},
Expand Down Expand Up @@ -48,7 +48,8 @@ impl<
> CudaLineageStoreSampleInitialiser<M, G, O, ResumeError<CudaError>> for FixUpInitialiser<L>
where
O::Habitat: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>>: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>>:
RustToCuda + Sync,
O::TurnoverRate: RustToCuda + Sync,
O::SpeciationProbability: RustToCuda + Sync,
{
Expand All @@ -71,7 +72,7 @@ where
M,
O::Habitat,
G,
O::DispersalSampler<InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>>,
O::DispersalSampler<InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>>,
UniformAntiTrespassingDispersalSampler<M, O::Habitat, G>,
>;

Expand All @@ -86,7 +87,7 @@ where
self,
origin_sampler: T,
dispersal_sampler: O::DispersalSampler<
InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>,
InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>,
>,
_event_time_sampler: J,
) -> Result<
Expand Down
9 changes: 5 additions & 4 deletions rustcoalescence/algorithms/cuda/src/initialiser/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use necsim_impls_no_std::cogs::{
active_lineage_sampler::independent::{
event_time_sampler::EventTimeSampler, IndependentActiveLineageSampler,
},
dispersal_sampler::in_memory::packed_alias::InMemoryPackedAliasDispersalSampler,
dispersal_sampler::in_memory::packed_separable_alias::InMemoryPackedSeparableAliasDispersalSampler,
lineage_store::independent::IndependentLineageStore,
origin_sampler::TrustedOriginSampler,
};
Expand All @@ -27,7 +27,8 @@ impl<M: MathsCore + Sync, G: PrimeableRng<M> + RustToCuda + Sync, O: Scenario<M,
CudaLineageStoreSampleInitialiser<M, G, O, CudaError> for GenesisInitialiser
where
O::Habitat: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>>: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>>:
RustToCuda + Sync,
O::TurnoverRate: RustToCuda + Sync,
O::SpeciationProbability: RustToCuda + Sync,
{
Expand All @@ -47,7 +48,7 @@ where
J,
>;
type DispersalSampler =
O::DispersalSampler<InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>>;
O::DispersalSampler<InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>>;

fn init<
'h,
Expand All @@ -60,7 +61,7 @@ where
self,
origin_sampler: T,
dispersal_sampler: O::DispersalSampler<
InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>,
InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>,
>,
event_time_sampler: J,
) -> Result<
Expand Down
7 changes: 4 additions & 3 deletions rustcoalescence/algorithms/cuda/src/initialiser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use necsim_impls_no_std::cogs::{
independent::event_time_sampler::EventTimeSampler, singular::SingularActiveLineageSampler,
},
coalescence_sampler::independent::IndependentCoalescenceSampler,
dispersal_sampler::in_memory::packed_alias::InMemoryPackedAliasDispersalSampler,
dispersal_sampler::in_memory::packed_separable_alias::InMemoryPackedSeparableAliasDispersalSampler,
event_sampler::independent::IndependentEventSampler,
immigration_entry::never::NeverImmigrationEntry,
lineage_store::independent::IndependentLineageStore,
Expand All @@ -33,7 +33,8 @@ pub trait CudaLineageStoreSampleInitialiser<
Error: From<CudaError>,
> where
O::Habitat: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>>: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>>:
RustToCuda + Sync,
O::TurnoverRate: RustToCuda + Sync,
O::SpeciationProbability: RustToCuda + Sync,
{
Expand Down Expand Up @@ -66,7 +67,7 @@ pub trait CudaLineageStoreSampleInitialiser<
self,
origin_sampler: T,
dispersal_sampler: O::DispersalSampler<
InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>,
InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>,
>,
event_time_sampler: J,
) -> Result<
Expand Down
9 changes: 5 additions & 4 deletions rustcoalescence/algorithms/cuda/src/initialiser/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use necsim_impls_no_std::cogs::{
independent::{event_time_sampler::EventTimeSampler, IndependentActiveLineageSampler},
resuming::lineage::ExceptionalLineage,
},
dispersal_sampler::in_memory::packed_alias::InMemoryPackedAliasDispersalSampler,
dispersal_sampler::in_memory::packed_separable_alias::InMemoryPackedSeparableAliasDispersalSampler,
lineage_store::independent::IndependentLineageStore,
origin_sampler::{resuming::ResumingOriginSampler, TrustedOriginSampler},
};
Expand Down Expand Up @@ -37,7 +37,8 @@ impl<
> CudaLineageStoreSampleInitialiser<M, G, O, ResumeError<CudaError>> for ResumeInitialiser<L>
where
O::Habitat: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>>: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>>:
RustToCuda + Sync,
O::TurnoverRate: RustToCuda + Sync,
O::SpeciationProbability: RustToCuda + Sync,
{
Expand All @@ -57,7 +58,7 @@ where
J,
>;
type DispersalSampler =
O::DispersalSampler<InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>>;
O::DispersalSampler<InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>>;

fn init<
'h,
Expand All @@ -70,7 +71,7 @@ where
self,
origin_sampler: T,
dispersal_sampler: O::DispersalSampler<
InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>,
InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>,
>,
event_time_sampler: J,
) -> Result<
Expand Down
7 changes: 4 additions & 3 deletions rustcoalescence/algorithms/cuda/src/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use necsim_impls_no_std::{
cogs::{
active_lineage_sampler::independent::event_time_sampler::exp::ExpEventTimeSampler,
coalescence_sampler::independent::IndependentCoalescenceSampler,
dispersal_sampler::in_memory::packed_alias::InMemoryPackedAliasDispersalSampler,
dispersal_sampler::in_memory::packed_separable_alias::InMemoryPackedSeparableAliasDispersalSampler,
emigration_exit::never::NeverEmigrationExit,
event_sampler::independent::IndependentEventSampler,
immigration_entry::never::NeverImmigrationEntry,
Expand Down Expand Up @@ -97,7 +97,8 @@ pub fn initialise_and_simulate<
) -> Result<SimulationOutcome<M, G>, Error>
where
O::Habitat: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>>: RustToCuda + Sync,
O::DispersalSampler<InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>>:
RustToCuda + Sync,
O::TurnoverRate: RustToCuda + Sync,
O::SpeciationProbability: RustToCuda + Sync,
{
Expand All @@ -108,7 +109,7 @@ where
speciation_probability,
origin_sampler_auxiliary,
decomposition_auxiliary,
) = scenario.build::<InMemoryPackedAliasDispersalSampler<M, O::Habitat, G>>();
) = scenario.build::<InMemoryPackedSeparableAliasDispersalSampler<M, O::Habitat, G>>();
let coalescence_sampler = IndependentCoalescenceSampler::default();
let event_sampler = IndependentEventSampler::default();

Expand Down
Loading

0 comments on commit 56c0bbc

Please sign in to comment.