diff --git a/necsim/impls/cuda/src/event_buffer.rs b/necsim/impls/cuda/src/event_buffer.rs index 2527ddef0..2fe7cb12a 100644 --- a/necsim/impls/cuda/src/event_buffer.rs +++ b/necsim/impls/cuda/src/event_buffer.rs @@ -1,4 +1,7 @@ -use core::fmt; +use core::{ + fmt, + ops::{Deref, DerefMut}, +}; use const_type_layout::TypeGraphLayout; #[cfg(not(target_os = "cuda"))] @@ -198,14 +201,14 @@ impl event: impl Into< as EventType>::Event>, ) { if let ([mask, mask_rest @ ..], [buffer, buffer_rest @ ..]) = ( - core::mem::take(&mut self.event_mask.0), - core::mem::take(&mut self.event_buffer.0), + core::mem::take(&mut *self.event_mask), + core::mem::take(&mut *self.event_buffer), ) { mask.write(true); buffer.write(MaybeSome::Some(event.into())); - self.event_mask.0 = mask_rest; - self.event_buffer.0 = buffer_rest; + *self.event_mask = mask_rest; + *self.event_buffer = buffer_rest; } } } @@ -225,7 +228,7 @@ impl Reporter impl Reporter for EventBuffer { impl_report!( #[debug_requires( - !self.event_buffer.0.is_empty(), + !self.event_buffer.is_empty(), "does not report extraneous dispersal events" )] dispersal(&mut self, event: Used) { @@ -238,14 +241,14 @@ impl Reporter for EventBuffer { impl Reporter for EventBuffer { impl_report!( #[debug_requires( - !self.event_buffer.0.is_empty(), + !self.event_buffer.is_empty(), "does not report extraneous speciation events" )] speciation(&mut self, event: Used) { self.report_event(event.clone()); - self.event_mask.0 = &mut []; - self.event_buffer.0 = &mut []; + *self.event_mask = &mut []; + *self.event_buffer = &mut []; } ); } @@ -254,20 +257,20 @@ impl Reporter for EventBuffer { impl Reporter for EventBuffer { impl_report!( #[debug_requires( - !self.event_buffer.0.is_empty(), + !self.event_buffer.is_empty(), "does not report extraneous speciation events" )] speciation(&mut self, event: Used) { self.report_event(event.clone()); - self.event_mask.0 = &mut []; - self.event_buffer.0 = &mut []; + *self.event_mask = &mut []; + *self.event_buffer = &mut []; } ); impl_report!( #[debug_requires( - !self.event_buffer.0.is_empty(), + !self.event_buffer.is_empty(), "does not report extraneous dispersal events" )] dispersal(&mut self, event: Used) { @@ -281,6 +284,24 @@ struct CudaExchangeSlice Deref + for CudaExchangeSlice +{ + type Target = &'static mut [T]; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut + for CudaExchangeSlice +{ + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + impl< T: 'static + StackOnly + PortableBitSemantics + TypeGraphLayout, const M2D: bool,