diff --git a/necsim/impls/no-std/src/parallelisation/independent/individuals.rs b/necsim/impls/no-std/src/parallelisation/independent/individuals.rs index 024314c28..6182e0947 100644 --- a/necsim/impls/no-std/src/parallelisation/independent/individuals.rs +++ b/necsim/impls/no-std/src/parallelisation/independent/individuals.rs @@ -141,9 +141,8 @@ pub fn simulate< proxy.local_partition().report_progress_sync(0_u64); - let (global_time, global_steps) = proxy - .local_partition() - .reduce_global_time_steps(max_time, total_steps); + let local_time = max_time; + let local_steps = total_steps; - (Status::Done, global_time, global_steps, lineages) + (Status::Done, local_time, local_steps, lineages) } diff --git a/necsim/impls/no-std/src/parallelisation/independent/landscape.rs b/necsim/impls/no-std/src/parallelisation/independent/landscape.rs index 4bf298dd5..2a28c8ea3 100644 --- a/necsim/impls/no-std/src/parallelisation/independent/landscape.rs +++ b/necsim/impls/no-std/src/parallelisation/independent/landscape.rs @@ -221,9 +221,8 @@ pub fn simulate< proxy.local_partition().report_progress_sync(0_u64); - let (global_time, global_steps) = proxy - .local_partition() - .reduce_global_time_steps(max_time, total_steps); + let local_time = max_time; + let local_steps = total_steps; - (Status::Done, global_time, global_steps, lineages) + (Status::Done, local_time, local_steps, lineages) } diff --git a/necsim/impls/no-std/src/parallelisation/independent/monolithic/mod.rs b/necsim/impls/no-std/src/parallelisation/independent/monolithic/mod.rs index 615a12f29..6bc67feaa 100644 --- a/necsim/impls/no-std/src/parallelisation/independent/monolithic/mod.rs +++ b/necsim/impls/no-std/src/parallelisation/independent/monolithic/mod.rs @@ -262,9 +262,9 @@ pub fn simulate< ); let status = Status::paused(local_partition.reduce_vote_any(!slow_lineages.is_empty())); - let (global_time, global_steps) = - local_partition.reduce_global_time_steps(max_time, total_steps); + let local_time = max_time; + let local_steps = total_steps; let lineages = slow_lineages.into_iter().map(|(lineage, _)| lineage); - (status, global_time, global_steps, lineages) + (status, local_time, local_steps, lineages) } diff --git a/necsim/impls/no-std/src/parallelisation/monolithic/averaging.rs b/necsim/impls/no-std/src/parallelisation/monolithic/averaging.rs index 85e81e901..b255c2ab0 100644 --- a/necsim/impls/no-std/src/parallelisation/monolithic/averaging.rs +++ b/necsim/impls/no-std/src/parallelisation/monolithic/averaging.rs @@ -138,10 +138,8 @@ pub fn simulate< local_partition.report_progress_sync(0_u64); - let (global_time, global_steps) = local_partition.reduce_global_time_steps( - simulation.active_lineage_sampler().get_last_event_time(), - total_steps, - ); + let local_time = simulation.active_lineage_sampler().get_last_event_time(); + let local_steps = total_steps; - (Status::Done, global_time, global_steps) + (Status::Done, local_time, local_steps) } diff --git a/necsim/impls/no-std/src/parallelisation/monolithic/lockstep.rs b/necsim/impls/no-std/src/parallelisation/monolithic/lockstep.rs index c9459ced5..f1ff75edc 100644 --- a/necsim/impls/no-std/src/parallelisation/monolithic/lockstep.rs +++ b/necsim/impls/no-std/src/parallelisation/monolithic/lockstep.rs @@ -137,10 +137,8 @@ pub fn simulate< local_partition.report_progress_sync(0_u64); - let (global_time, global_steps) = local_partition.reduce_global_time_steps( - simulation.active_lineage_sampler().get_last_event_time(), - total_steps, - ); + let local_time = simulation.active_lineage_sampler().get_last_event_time(); + let local_steps = total_steps; - (Status::Done, global_time, global_steps) + (Status::Done, local_time, local_steps) } diff --git a/necsim/impls/no-std/src/parallelisation/monolithic/monolithic.rs b/necsim/impls/no-std/src/parallelisation/monolithic/monolithic.rs index f13d990af..86c1f2418 100644 --- a/necsim/impls/no-std/src/parallelisation/monolithic/monolithic.rs +++ b/necsim/impls/no-std/src/parallelisation/monolithic/monolithic.rs @@ -87,7 +87,8 @@ pub fn simulate< local_partition .reduce_vote_any(simulation.active_lineage_sampler().number_active_lineages() > 0), ); - let (global_time, global_steps) = local_partition.reduce_global_time_steps(time, steps); + let local_time = time; + let local_steps = steps; - (status, global_time, global_steps) + (status, local_time, local_steps) } diff --git a/necsim/impls/no-std/src/parallelisation/monolithic/optimistic.rs b/necsim/impls/no-std/src/parallelisation/monolithic/optimistic.rs index 0f865b8a0..ee9a55a49 100644 --- a/necsim/impls/no-std/src/parallelisation/monolithic/optimistic.rs +++ b/necsim/impls/no-std/src/parallelisation/monolithic/optimistic.rs @@ -173,10 +173,8 @@ pub fn simulate< proxy.local_partition().report_progress_sync(0_u64); - let (global_time, global_steps) = proxy.local_partition().reduce_global_time_steps( - simulation.active_lineage_sampler().get_last_event_time(), - total_steps, - ); + let local_time = simulation.active_lineage_sampler().get_last_event_time(); + let local_steps = total_steps; - (Status::Done, global_time, global_steps) + (Status::Done, local_time, local_steps) } diff --git a/necsim/impls/no-std/src/parallelisation/monolithic/optimistic_lockstep.rs b/necsim/impls/no-std/src/parallelisation/monolithic/optimistic_lockstep.rs index f3ce7df36..d9cdab94d 100644 --- a/necsim/impls/no-std/src/parallelisation/monolithic/optimistic_lockstep.rs +++ b/necsim/impls/no-std/src/parallelisation/monolithic/optimistic_lockstep.rs @@ -169,10 +169,8 @@ pub fn simulate< local_partition.report_progress_sync(0_u64); - let (global_time, global_steps) = local_partition.reduce_global_time_steps( - simulation.active_lineage_sampler().get_last_event_time(), - total_steps, - ); + let local_time = simulation.active_lineage_sampler().get_last_event_time(); + let local_steps = total_steps; - (Status::Done, global_time, global_steps) + (Status::Done, local_time, local_steps) } diff --git a/necsim/partitioning/core/src/lib.rs b/necsim/partitioning/core/src/lib.rs index 54a934d29..ccf8d5746 100644 --- a/necsim/partitioning/core/src/lib.rs +++ b/necsim/partitioning/core/src/lib.rs @@ -12,7 +12,7 @@ use necsim_core::{ lineage::MigratingLineage, reporter::{boolean::Boolean, Reporter}, }; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; pub mod context; pub mod iterator; @@ -86,12 +86,6 @@ pub trait LocalPartition<'p, R: Reporter>: Sized { fn wait_for_termination(&mut self) -> ControlFlow<(), ()>; - fn reduce_global_time_steps( - &mut self, - local_time: NonNegativeF64, - local_steps: u64, - ) -> (NonNegativeF64, u64); - fn report_progress_sync(&mut self, remaining: u64); fn finalise_reporting(self); diff --git a/necsim/partitioning/monolithic/src/lib.rs b/necsim/partitioning/monolithic/src/lib.rs index 1a29426b5..6975454b6 100644 --- a/necsim/partitioning/monolithic/src/lib.rs +++ b/necsim/partitioning/monolithic/src/lib.rs @@ -13,7 +13,7 @@ use necsim_core::{ lineage::MigratingLineage, reporter::{boolean::True, Reporter}, }; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; use necsim_partitioning_core::{ context::ReporterContext, @@ -164,19 +164,6 @@ impl<'p, R: Reporter> LocalPartition<'p, R> for MonolithicLocalPartition { } } - fn reduce_global_time_steps( - &mut self, - local_time: NonNegativeF64, - local_steps: u64, - ) -> (NonNegativeF64, u64) { - match self { - Self::Live(partition) => partition.reduce_global_time_steps(local_time, local_steps), - Self::Recorded(partition) => { - partition.reduce_global_time_steps(local_time, local_steps) - }, - } - } - fn report_progress_sync(&mut self, remaining: u64) { match self { Self::Live(partition) => partition.report_progress_sync(remaining), diff --git a/necsim/partitioning/monolithic/src/live.rs b/necsim/partitioning/monolithic/src/live.rs index 369a71b30..023087357 100644 --- a/necsim/partitioning/monolithic/src/live.rs +++ b/necsim/partitioning/monolithic/src/live.rs @@ -4,7 +4,7 @@ use necsim_core::{ lineage::MigratingLineage, reporter::{boolean::True, FilteredReporter, Reporter}, }; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; use necsim_partitioning_core::{ context::ReporterContext, iterator::ImmigrantPopIterator, partition::Partition, LocalPartition, @@ -87,14 +87,6 @@ impl<'p, R: Reporter> LocalPartition<'p, R> for LiveMonolithicLocalPartition } } - fn reduce_global_time_steps( - &mut self, - local_time: NonNegativeF64, - local_steps: u64, - ) -> (NonNegativeF64, u64) { - (local_time, local_steps) - } - fn report_progress_sync(&mut self, remaining: u64) { self.reporter.report_progress(&remaining.into()); } diff --git a/necsim/partitioning/monolithic/src/recorded.rs b/necsim/partitioning/monolithic/src/recorded.rs index 72e8e3324..dfd0c2ded 100644 --- a/necsim/partitioning/monolithic/src/recorded.rs +++ b/necsim/partitioning/monolithic/src/recorded.rs @@ -10,7 +10,7 @@ use necsim_core::{ FilteredReporter, Reporter, }, }; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; use necsim_impls_std::event_log::recorder::EventLogRecorder; @@ -97,14 +97,6 @@ impl<'p, R: Reporter> LocalPartition<'p, R> for RecordedMonolithicLocalPartition } } - fn reduce_global_time_steps( - &mut self, - local_time: NonNegativeF64, - local_steps: u64, - ) -> (NonNegativeF64, u64) { - (local_time, local_steps) - } - fn report_progress_sync(&mut self, remaining: u64) { self.reporter.report_progress(&remaining.into()); } diff --git a/necsim/partitioning/mpi/src/partition/common.rs b/necsim/partitioning/mpi/src/partition/common.rs index c4d3c3cc9..6c274d73e 100644 --- a/necsim/partitioning/mpi/src/partition/common.rs +++ b/necsim/partitioning/mpi/src/partition/common.rs @@ -13,7 +13,7 @@ use mpi::{ }; use necsim_core::lineage::MigratingLineage; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; use necsim_partitioning_core::{ iterator::ImmigrantPopIterator, @@ -292,28 +292,4 @@ impl<'p> MpiCommonPartition<'p> { ControlFlow::Break(()) } } - - #[must_use] - pub fn reduce_global_time_steps( - &mut self, - local_time: NonNegativeF64, - local_steps: u64, - ) -> (NonNegativeF64, u64) { - let mut global_time_max = 0.0_f64; - let mut global_steps_sum = 0_u64; - - self.world.all_reduce_into( - &local_time.get(), - &mut global_time_max, - SystemOperation::max(), - ); - self.world - .all_reduce_into(&local_steps, &mut global_steps_sum, SystemOperation::sum()); - - // Safety: `global_time_max` is the max of multiple `NonNegativeF64`s - // communicated through MPI - let global_time_max = unsafe { NonNegativeF64::new_unchecked(global_time_max) }; - - (global_time_max, global_steps_sum) - } } diff --git a/necsim/partitioning/mpi/src/partition/mod.rs b/necsim/partitioning/mpi/src/partition/mod.rs index 8637758d6..6d584f236 100644 --- a/necsim/partitioning/mpi/src/partition/mod.rs +++ b/necsim/partitioning/mpi/src/partition/mod.rs @@ -5,7 +5,7 @@ use necsim_core::{ lineage::MigratingLineage, reporter::{boolean::False, Reporter}, }; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; use necsim_partitioning_core::{ iterator::ImmigrantPopIterator, partition::Partition, LocalPartition, MigrationMode, @@ -95,19 +95,6 @@ impl<'p, R: Reporter> LocalPartition<'p, R> for MpiLocalPartition<'p, R> { } } - fn reduce_global_time_steps( - &mut self, - local_time: NonNegativeF64, - local_steps: u64, - ) -> (NonNegativeF64, u64) { - match self { - Self::Root(partition) => partition.reduce_global_time_steps(local_time, local_steps), - Self::Parallel(partition) => { - partition.reduce_global_time_steps(local_time, local_steps) - }, - } - } - fn report_progress_sync(&mut self, remaining: u64) { match self { Self::Root(partition) => partition.report_progress_sync(remaining), diff --git a/necsim/partitioning/mpi/src/partition/parallel.rs b/necsim/partitioning/mpi/src/partition/parallel.rs index 6cbad3a66..dfb5775d2 100644 --- a/necsim/partitioning/mpi/src/partition/parallel.rs +++ b/necsim/partitioning/mpi/src/partition/parallel.rs @@ -17,7 +17,7 @@ use necsim_core::{ Reporter, }, }; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; use necsim_impls_std::event_log::recorder::EventLogRecorder; use necsim_partitioning_core::{ @@ -127,15 +127,6 @@ impl<'p, R: Reporter> LocalPartition<'p, R> for MpiParallelPartition<'p, R> { self.common.wait_for_termination() } - fn reduce_global_time_steps( - &mut self, - local_time: NonNegativeF64, - local_steps: u64, - ) -> (NonNegativeF64, u64) { - self.common - .reduce_global_time_steps(local_time, local_steps) - } - fn report_progress_sync(&mut self, remaining: u64) { let root_process = self .common diff --git a/necsim/partitioning/mpi/src/partition/root.rs b/necsim/partitioning/mpi/src/partition/root.rs index 7ba6be6c5..ca6dd68e2 100644 --- a/necsim/partitioning/mpi/src/partition/root.rs +++ b/necsim/partitioning/mpi/src/partition/root.rs @@ -18,7 +18,7 @@ use necsim_core::{ FilteredReporter, Reporter, }, }; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; use necsim_impls_std::event_log::recorder::EventLogRecorder; use necsim_partitioning_core::{ @@ -152,14 +152,6 @@ impl<'p, R: Reporter> LocalPartition<'p, R> for MpiRootPartition<'p, R> { result } - fn reduce_global_time_steps( - &mut self, - local_time: NonNegativeF64, - local_steps: u64, - ) -> (NonNegativeF64, u64) { - self.reduce_global_time_steps(local_time, local_steps) - } - fn report_progress_sync(&mut self, remaining: u64) { let root_process = self .common diff --git a/necsim/partitioning/threads/src/lib.rs b/necsim/partitioning/threads/src/lib.rs index 435655576..54ac2b7c5 100644 --- a/necsim/partitioning/threads/src/lib.rs +++ b/necsim/partitioning/threads/src/lib.rs @@ -13,7 +13,7 @@ use std::{ use anyhow::Context; use humantime_serde::re::humantime::format_duration; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; use serde::{ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer}; use thiserror::Error; @@ -129,7 +129,6 @@ impl Partitioning for ThreadsPartitioning { self.size } - #[allow(clippy::too_many_lines)] /// # Errors /// /// Returns `MissingEventLog` if the local partition is non-monolithic and @@ -165,8 +164,6 @@ impl Partitioning for ThreadsPartitioning { let vote_any = Vote::new(self.size.get() as usize); let vote_min_time = Vote::new_with_dummy(self.size.get() as usize, (PositiveF64::one(), 0)); - let vote_time_steps = - Vote::new_with_dummy(self.size.get() as usize, (NonNegativeF64::zero(), 0)); let vote_termination = AsyncVote::new_with_dummy(self.size.get() as usize, ControlFlow::Continue(())); @@ -200,7 +197,6 @@ impl Partitioning for ThreadsPartitioning { let result = std::thread::scope(|scope| { let vote_any = &vote_any; let vote_min_time = &vote_min_time; - let vote_time_steps = &vote_time_steps; let vote_termination = &vote_termination; let emigration_channels = emigration_channels.as_slice(); let sync_barrier = &sync_barrier; @@ -219,7 +215,6 @@ impl Partitioning for ThreadsPartitioning { partition, vote_any, vote_min_time, - vote_time_steps, vote_termination, emigration_channels, immigration_channel, diff --git a/necsim/partitioning/threads/src/partition.rs b/necsim/partitioning/threads/src/partition.rs index be6a92427..7b0221b94 100644 --- a/necsim/partitioning/threads/src/partition.rs +++ b/necsim/partitioning/threads/src/partition.rs @@ -18,7 +18,7 @@ use necsim_core::{ Reporter, }, }; -use necsim_core_bond::{NonNegativeF64, PositiveF64}; +use necsim_core_bond::PositiveF64; use necsim_impls_std::event_log::recorder::EventLogRecorder; use necsim_partitioning_core::{partition::Partition, LocalPartition, MigrationMode}; @@ -30,7 +30,6 @@ pub struct ThreadsLocalPartition<'p, R: Reporter> { partition: Partition, vote_any: Vote, vote_min_time: Vote<(PositiveF64, u32)>, - vote_time_steps: Vote<(NonNegativeF64, u64)>, vote_termination: AsyncVote>, emigration_buffers: Box<[Vec]>, emigration_channels: Box<[SyncSender>]>, @@ -61,7 +60,6 @@ impl<'p, R: Reporter> ThreadsLocalPartition<'p, R> { partition: Partition, vote_any: &Vote, vote_min_time: &Vote<(PositiveF64, u32)>, - vote_time_steps: &Vote<(NonNegativeF64, u64)>, vote_termination: &AsyncVote>, emigration_channels: &[SyncSender>], immigration_channel: Receiver>, @@ -84,7 +82,6 @@ impl<'p, R: Reporter> ThreadsLocalPartition<'p, R> { partition, vote_any: vote_any.clone(), vote_min_time: vote_min_time.clone(), - vote_time_steps: vote_time_steps.clone(), vote_termination: vote_termination.clone(), emigration_buffers: emigration_buffers.into_boxed_slice(), emigration_channels: Vec::from(emigration_channels).into_boxed_slice(), @@ -263,19 +260,6 @@ impl<'p, R: Reporter> LocalPartition<'p, R> for ThreadsLocalPartition<'p, R> { } } - fn reduce_global_time_steps( - &mut self, - local_time: NonNegativeF64, - local_steps: u64, - ) -> (NonNegativeF64, u64) { - self.vote_time_steps.vote(|acc| match acc { - None => (local_time, local_steps), - Some((global_time, global_steps)) => { - (local_time.max(*global_time), local_steps + (*global_steps)) - }, - }) - } - fn report_progress_sync(&mut self, remaining: u64) { if let Err(SendError(_)) = self .progress_channel diff --git a/rustcoalescence/algorithms/cuda/src/parallelisation/monolithic.rs b/rustcoalescence/algorithms/cuda/src/parallelisation/monolithic.rs index 4d6285577..b049d3d9d 100644 --- a/rustcoalescence/algorithms/cuda/src/parallelisation/monolithic.rs +++ b/rustcoalescence/algorithms/cuda/src/parallelisation/monolithic.rs @@ -341,13 +341,13 @@ pub fn simulate< local_partition.report_progress_sync(slow_lineages.len() as u64); let status = Status::paused(local_partition.reduce_vote_any(!slow_lineages.is_empty())); - let (global_time, global_steps) = - local_partition.reduce_global_time_steps(total_time_max, total_steps_sum); + let local_time = total_time_max; + let local_steps = total_steps_sum; let lineages = slow_lineages.into_iter().map(|(lineage, _)| lineage); // Note: The simulation requires no mutation, since all components are // either immutable or have singular swap states, and the list // of all lineages (which does change) is returned separately - Ok((status, global_time, global_steps, lineages)) + Ok((status, local_time, local_steps, lineages)) }