Skip to content

Commit

Permalink
Partially revert aa36dc9
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Jun 2, 2024
1 parent 121e0dc commit 2152b68
Show file tree
Hide file tree
Showing 51 changed files with 243 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use super::{reporter::IgnoreProgressReporterProxy, DedupCache};

#[allow(clippy::type_complexity)]
pub fn simulate<
'p,
M: MathsCore,
H: Habitat<M>,
G: PrimeableRng<M>,
Expand All @@ -56,7 +57,7 @@ pub fn simulate<
NeverImmigrationEntry,
>,
R: Reporter,
P: LocalPartition<R>,
P: LocalPartition<'p, R>,
L: IntoIterator<Item = Lineage>,
>(
simulation: &mut Simulation<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use super::{reporter::IgnoreProgressReporterProxy, DedupCache};

#[allow(clippy::type_complexity, clippy::too_many_lines)]
pub fn simulate<
'p,
M: MathsCore,
H: Habitat<M>,
C: Decomposition<M, H>,
Expand All @@ -61,7 +62,7 @@ pub fn simulate<
NeverImmigrationEntry,
>,
R: Reporter,
P: LocalPartition<R>,
P: LocalPartition<'p, R>,
L: IntoIterator<Item = Lineage>,
>(
simulation: &mut Simulation<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use reporter::{

#[allow(clippy::type_complexity, clippy::too_many_lines)]
pub fn simulate<
'p,
M: MathsCore,
H: Habitat<M>,
G: PrimeableRng<M>,
Expand All @@ -61,7 +62,7 @@ pub fn simulate<
NeverImmigrationEntry,
>,
R: Reporter,
P: LocalPartition<R>,
P: LocalPartition<'p, R>,
L: IntoIterator<Item = Lineage>,
>(
simulation: &mut Simulation<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ use necsim_partitioning_core::LocalPartition;
use super::WaterLevelReporterProxy;

#[allow(clippy::module_name_repetitions)]
pub struct LiveWaterLevelReporterProxy<'p, R: Reporter, P: LocalPartition<R>> {
pub struct LiveWaterLevelReporterProxy<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> {
water_level: NonNegativeF64,
slow_events: Vec<PackedEvent>,
fast_events: Vec<PackedEvent>,

local_partition: &'p mut P,
_marker: PhantomData<R>,
local_partition: &'l mut P,
_marker: PhantomData<(&'p (), R)>,
}

impl<'p, R: Reporter, P: LocalPartition<R>> fmt::Debug for LiveWaterLevelReporterProxy<'p, R, P> {
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> fmt::Debug
for LiveWaterLevelReporterProxy<'l, 'p, R, P>
{
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
struct EventBufferLen(usize);

Expand All @@ -40,7 +42,9 @@ impl<'p, R: Reporter, P: LocalPartition<R>> fmt::Debug for LiveWaterLevelReporte
}
}

impl<'p, R: Reporter, P: LocalPartition<R>> Reporter for LiveWaterLevelReporterProxy<'p, R, P> {
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> Reporter
for LiveWaterLevelReporterProxy<'l, 'p, R, P>
{
impl_report!(speciation(&mut self, speciation: MaybeUsed<R::ReportSpeciation>) {
if speciation.event_time < self.water_level {
self.slow_events.push(speciation.clone().into());
Expand All @@ -61,10 +65,10 @@ impl<'p, R: Reporter, P: LocalPartition<R>> Reporter for LiveWaterLevelReporterP
}

#[contract_trait]
impl<'p, R: Reporter, P: LocalPartition<R>> WaterLevelReporterProxy<'p, R, P>
for LiveWaterLevelReporterProxy<'p, R, P>
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> WaterLevelReporterProxy<'l, 'p, R, P>
for LiveWaterLevelReporterProxy<'l, 'p, R, P>
{
fn new(capacity: usize, local_partition: &'p mut P) -> Self {
fn new(capacity: usize, local_partition: &'l mut P) -> Self {
info!("Events will be reported using the live water-level algorithm ...");

Self {
Expand All @@ -73,7 +77,7 @@ impl<'p, R: Reporter, P: LocalPartition<R>> WaterLevelReporterProxy<'p, R, P>
fast_events: Vec::with_capacity(capacity),

local_partition,
_marker: PhantomData::<R>,
_marker: PhantomData::<(&'p (), R)>,
}
}

Expand Down Expand Up @@ -115,7 +119,9 @@ impl<'p, R: Reporter, P: LocalPartition<R>> WaterLevelReporterProxy<'p, R, P>
}
}

impl<'p, R: Reporter, P: LocalPartition<R>> Drop for LiveWaterLevelReporterProxy<'p, R, P> {
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> Drop
for LiveWaterLevelReporterProxy<'l, 'p, R, P>
{
fn drop(&mut self) {
// Report all events below the water level in sorted order
self.slow_events.sort_unstable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ mod recorded;
#[allow(clippy::inline_always, clippy::inline_fn_without_body)]
#[allow(clippy::no_effect_underscore_binding)]
#[contract_trait]
pub trait WaterLevelReporterProxy<'p, R: Reporter, P: LocalPartition<R>>:
pub trait WaterLevelReporterProxy<'l, 'p, R: Reporter, P: LocalPartition<'p, R>>:
Sized
+ Reporter<
ReportSpeciation = R::ReportSpeciation,
ReportDispersal = R::ReportDispersal,
ReportProgress = False,
>
{
fn new(capacity: usize, local_partition: &'p mut P) -> Self;
fn new(capacity: usize, local_partition: &'l mut P) -> Self;

fn water_level(&self) -> NonNegativeF64;

Expand All @@ -36,23 +36,24 @@ pub trait WaterLevelReporterProxy<'p, R: Reporter, P: LocalPartition<R>>:
pub enum WaterLevelReporterStrategy {}

pub trait WaterLevelReporterConstructor<
'l,
'p,
IsLive: Boolean,
R: Reporter,
P: 'p + LocalPartition<R, IsLive = IsLive>,
P: 'l + LocalPartition<'p, R, IsLive = IsLive>,
>
{
type WaterLevelReporter: WaterLevelReporterProxy<'p, R, P>;
type WaterLevelReporter: WaterLevelReporterProxy<'l, 'p, R, P>;
}

impl<'p, IsLive: Boolean, R: Reporter, P: 'p + LocalPartition<R, IsLive = IsLive>>
WaterLevelReporterConstructor<'p, IsLive, R, P> for WaterLevelReporterStrategy
impl<'l, 'p, IsLive: Boolean, R: Reporter, P: 'l + LocalPartition<'p, R, IsLive = IsLive>>
WaterLevelReporterConstructor<'l, 'p, IsLive, R, P> for WaterLevelReporterStrategy
{
default type WaterLevelReporter = live::LiveWaterLevelReporterProxy<'p, R, P>;
default type WaterLevelReporter = live::LiveWaterLevelReporterProxy<'l, 'p, R, P>;
}

impl<'p, R: Reporter, P: 'p + LocalPartition<R, IsLive = False>>
WaterLevelReporterConstructor<'p, False, R, P> for WaterLevelReporterStrategy
impl<'l, 'p, R: Reporter, P: 'l + LocalPartition<'p, R, IsLive = False>>
WaterLevelReporterConstructor<'l, 'p, False, R, P> for WaterLevelReporterStrategy
{
type WaterLevelReporter = recorded::RecordedWaterLevelReporterProxy<'p, R, P>;
type WaterLevelReporter = recorded::RecordedWaterLevelReporterProxy<'l, 'p, R, P>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use necsim_partitioning_core::LocalPartition;
use super::WaterLevelReporterProxy;

#[allow(clippy::module_name_repetitions)]
pub struct RecordedWaterLevelReporterProxy<'p, R: Reporter, P: LocalPartition<R>> {
pub struct RecordedWaterLevelReporterProxy<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> {
water_level: NonNegativeF64,

local_partition: &'p mut P,
_marker: PhantomData<R>,
local_partition: &'l mut P,
_marker: PhantomData<(&'p (), R)>,
}

impl<'p, R: Reporter, P: LocalPartition<R>> fmt::Debug
for RecordedWaterLevelReporterProxy<'p, R, P>
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> fmt::Debug
for RecordedWaterLevelReporterProxy<'l, 'p, R, P>
{
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct(stringify!(RecordedWaterLevelReporterProxy))
Expand All @@ -25,7 +25,9 @@ impl<'p, R: Reporter, P: LocalPartition<R>> fmt::Debug
}
}

impl<'p, R: Reporter, P: LocalPartition<R>> Reporter for RecordedWaterLevelReporterProxy<'p, R, P> {
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> Reporter
for RecordedWaterLevelReporterProxy<'l, 'p, R, P>
{
impl_report!(speciation(&mut self, speciation: MaybeUsed<R::ReportSpeciation>) {
self.local_partition.get_reporter().report_speciation(speciation.into());
});
Expand All @@ -38,17 +40,17 @@ impl<'p, R: Reporter, P: LocalPartition<R>> Reporter for RecordedWaterLevelRepor
}

#[contract_trait]
impl<'p, R: Reporter, P: LocalPartition<R>> WaterLevelReporterProxy<'p, R, P>
for RecordedWaterLevelReporterProxy<'p, R, P>
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> WaterLevelReporterProxy<'l, 'p, R, P>
for RecordedWaterLevelReporterProxy<'l, 'p, R, P>
{
fn new(_capacity: usize, local_partition: &'p mut P) -> Self {
fn new(_capacity: usize, local_partition: &'l mut P) -> Self {
info!("Events will be reported using the recorded water-level algorithm ...");

Self {
water_level: NonNegativeF64::zero(),

local_partition,
_marker: PhantomData::<R>,
_marker: PhantomData::<(&'p (), R)>,
}
}

Expand Down
24 changes: 14 additions & 10 deletions necsim/impls/no-std/src/parallelisation/independent/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,43 @@ use necsim_core::{impl_report, reporter::Reporter};

use necsim_partitioning_core::LocalPartition;

pub struct IgnoreProgressReporterProxy<'p, R: Reporter, P: LocalPartition<R>> {
local_partition: &'p mut P,
_marker: PhantomData<R>,
pub struct IgnoreProgressReporterProxy<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> {
local_partition: &'l mut P,
_marker: PhantomData<(&'p (), R)>,
}

impl<'p, R: Reporter, P: LocalPartition<R>> fmt::Debug for IgnoreProgressReporterProxy<'p, R, P> {
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> fmt::Debug
for IgnoreProgressReporterProxy<'l, 'p, R, P>
{
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct(stringify!(IgnoreProgressReporterProxy))
.finish()
}
}

impl<'p, R: Reporter, P: LocalPartition<R>> Reporter for IgnoreProgressReporterProxy<'p, R, P> {
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> Reporter
for IgnoreProgressReporterProxy<'l, 'p, R, P>
{
impl_report!(speciation(&mut self, speciation: MaybeUsed<
<<P as LocalPartition<R>>::Reporter as Reporter
<<P as LocalPartition<'p, R>>::Reporter as Reporter
>::ReportSpeciation>) {
self.local_partition.get_reporter().report_speciation(speciation.into());
});

impl_report!(dispersal(&mut self, dispersal: MaybeUsed<
<<P as LocalPartition<R>>::Reporter as Reporter
<<P as LocalPartition<'p, R>>::Reporter as Reporter
>::ReportDispersal>) {
self.local_partition.get_reporter().report_dispersal(dispersal.into());
});

impl_report!(progress(&mut self, _progress: Ignored) {});
}

impl<'p, R: Reporter, P: LocalPartition<R>> IgnoreProgressReporterProxy<'p, R, P> {
pub fn from(local_partition: &'p mut P) -> Self {
impl<'l, 'p, R: Reporter, P: LocalPartition<'p, R>> IgnoreProgressReporterProxy<'l, 'p, R, P> {
pub fn from(local_partition: &'l mut P) -> Self {
Self {
local_partition,
_marker: PhantomData::<R>,
_marker: PhantomData::<(&'p (), R)>,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::{

#[allow(clippy::type_complexity)]
pub fn simulate<
'p,
M: MathsCore,
H: Habitat<M>,
G: RngCore<M>,
Expand All @@ -47,7 +48,7 @@ pub fn simulate<
BufferedImmigrationEntry,
>,
P: Reporter,
L: LocalPartition<P>,
L: LocalPartition<'p, P>,
>(
simulation: &mut Simulation<
M,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::{

#[allow(clippy::type_complexity)]
pub fn simulate<
'p,
M: MathsCore,
H: Habitat<M>,
G: RngCore<M>,
Expand All @@ -47,7 +48,7 @@ pub fn simulate<
BufferedImmigrationEntry,
>,
P: Reporter,
L: LocalPartition<P>,
L: LocalPartition<'p, P>,
>(
simulation: &mut Simulation<
M,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::{

#[allow(clippy::type_complexity)]
pub fn simulate<
'p,
M: MathsCore,
H: Habitat<M>,
G: RngCore<M>,
Expand All @@ -33,7 +34,7 @@ pub fn simulate<
E: EventSampler<M, H, G, S, NeverEmigrationExit, D, C, T, N>,
A: ActiveLineageSampler<M, H, G, S, NeverEmigrationExit, D, C, T, N, E, NeverImmigrationEntry>,
P: Reporter,
L: LocalPartition<P>,
L: LocalPartition<'p, P>,
>(
simulation: &mut Simulation<
M,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use super::reporter::BufferingReporterProxy;

#[allow(clippy::type_complexity)]
pub fn simulate<
'p,
M: MathsCore,
H: Habitat<M>,
G: RngCore<M>,
Expand All @@ -52,7 +53,7 @@ pub fn simulate<
BufferedImmigrationEntry,
>,
P: Reporter,
L: LocalPartition<P>,
L: LocalPartition<'p, P>,
>(
simulation: &mut Simulation<
M,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::{

#[allow(clippy::type_complexity)]
pub fn simulate<
'p,
M: MathsCore,
H: Habitat<M>,
G: RngCore<M>,
Expand All @@ -47,7 +48,7 @@ pub fn simulate<
BufferedImmigrationEntry,
>,
P: Reporter,
L: LocalPartition<P>,
L: LocalPartition<'p, P>,
>(
simulation: &mut Simulation<
M,
Expand Down
Loading

0 comments on commit 2152b68

Please sign in to comment.