@@ -43,19 +43,21 @@ use necsim_core::cogs::{
4343 ActiveLineageSampler , CoalescenceSampler , DispersalSampler , EventSampler ,
4444 HabitatToU64Injection , IncoherentLineageStore , LineageReference , PrimeableRng ,
4545} ;
46- use necsim_core:: reporter:: NullReporter ;
4746use necsim_core:: simulation:: Simulation ;
4847use rust_cuda:: common:: RustToCuda ;
4948use rust_cuda:: device:: BorrowFromRust ;
5049use rustacuda_core:: DeviceCopy ;
5150
52- use necsim_impls_no_std:: cogs:: rng:: cuda:: CudaRng ;
51+ use necsim_impls_cuda:: cogs:: rng:: CudaRng ;
52+ use necsim_impls_cuda:: event_buffer:: common:: EventBufferCudaRepresentation ;
53+ use necsim_impls_cuda:: event_buffer:: device:: EventBufferDevice ;
5354
5455#[ no_mangle]
5556/// # Safety
5657/// This CUDA kernel is unsafe as it is called with raw pointers
5758pub unsafe extern "ptx-kernel" fn simulate (
5859 simulation_c_ptr : * mut core:: ffi:: c_void ,
60+ event_buffer_c_ptr : * mut core:: ffi:: c_void ,
5961 max_steps : usize ,
6062) {
6163 use necsim_impls_no_std:: cogs:: active_lineage_sampler:: independent:: IndependentActiveLineageSampler as ActiveLineageSampler ;
@@ -79,6 +81,7 @@ pub unsafe extern "ptx-kernel" fn simulate(
7981 EventSampler < _ , _ , _ , _ , _ > ,
8082 ActiveLineageSampler < _ , _ , _ , _ , _ > ,
8183 > as RustToCuda >:: CudaRepresentation ,
84+ event_buffer_c_ptr as * mut EventBufferCudaRepresentation < Habitat , LineageReference > ,
8285 max_steps,
8386 )
8487}
@@ -94,20 +97,21 @@ unsafe fn simulate_generic<
9497 A : ActiveLineageSampler < H , G , D , R , S , C , E > + RustToCuda ,
9598> (
9699 simulation_ptr : * mut <Simulation < H , G , D , R , S , C , E , A > as RustToCuda >:: CudaRepresentation ,
100+ event_buffer_ptr : * mut EventBufferCudaRepresentation < H , R > ,
97101 max_steps : usize ,
98102) {
99103 Simulation :: with_borrow_from_rust_mut ( simulation_ptr, |simulation| {
100- let mut reporter = NullReporter ;
104+ EventBufferDevice :: with_borrow_from_rust_mut ( event_buffer_ptr, |event_buffer_reporter| {
105+ let ( time, steps) = simulation. simulate_incremental ( max_steps, event_buffer_reporter) ;
101106
102- let ( time, steps) = simulation. simulate_incremental ( max_steps, & mut reporter) ;
103-
104- if utils:: thread_idx ( ) . as_id ( & utils:: block_dim ( ) ) == 0 {
105- println ! (
106- "index = {}, time = {:?}, steps = {}" ,
107- utils:: index( ) ,
108- F64 ( time) ,
109- steps
110- ) ;
111- }
107+ if utils:: thread_idx ( ) . as_id ( & utils:: block_dim ( ) ) == 0 {
108+ println ! (
109+ "index = {}, time = {:?}, steps = {}" ,
110+ utils:: index( ) ,
111+ F64 ( time) ,
112+ steps
113+ ) ;
114+ }
115+ } )
112116 } )
113117}
0 commit comments