11#![ deny( clippy:: pedantic) ]
2- #![ allow ( incomplete_features ) ]
3- #![ feature( specialization ) ]
2+ #![ feature ( c_str_literals ) ]
3+ #![ feature( min_specialization ) ]
44#![ recursion_limit = "1024" ]
55
66use necsim_core:: {
@@ -16,178 +16,25 @@ use necsim_impls_no_std::cogs::{
1616 event_sampler:: tracking:: MinSpeciationTrackingEventSampler ,
1717} ;
1818
19- use rust_cuda:: {
20- common:: RustToCuda ,
21- host:: { CudaDropWrapper , LaunchConfig , LaunchPackage , Launcher , TypedKernel } ,
22- rustacuda:: {
23- error:: CudaResult ,
24- function:: { BlockSize , Function , GridSize } ,
25- stream:: Stream ,
26- } ,
27- } ;
28-
29- use rustcoalescence_algorithms_cuda_gpu_kernel:: SimulatableKernel ;
19+ use rust_cuda:: lend:: RustToCuda ;
3020
3121mod link;
3222mod patch;
3323
34- pub type KernelCompilationCallback = dyn FnMut ( & Function ) -> CudaResult < ( ) > ;
35-
36- #[ allow( clippy:: module_name_repetitions) ]
37- pub struct SimulationKernel <
38- M : MathsCore ,
39- H : Habitat < M > + RustToCuda ,
40- G : PrimeableRng < M > + RustToCuda ,
41- S : LineageStore < M , H > + RustToCuda ,
42- X : EmigrationExit < M , H , G , S > + RustToCuda ,
43- D : DispersalSampler < M , H , G > + RustToCuda ,
44- C : CoalescenceSampler < M , H , S > + RustToCuda ,
45- T : TurnoverRate < M , H > + RustToCuda ,
46- N : SpeciationProbability < M , H > + RustToCuda ,
47- E : MinSpeciationTrackingEventSampler < M , H , G , S , X , D , C , T , N > + RustToCuda ,
48- I : ImmigrationEntry < M > + RustToCuda ,
49- A : SingularActiveLineageSampler < M , H , G , S , X , D , C , T , N , E , I > + RustToCuda ,
24+ #[ allow( clippy:: type_complexity) ]
25+ pub struct SimulationKernelPtx <
26+ M : MathsCore + Sync ,
27+ H : Habitat < M > + RustToCuda + Sync ,
28+ G : PrimeableRng < M > + RustToCuda + Sync ,
29+ S : LineageStore < M , H > + RustToCuda + Sync ,
30+ X : EmigrationExit < M , H , G , S > + RustToCuda + Sync ,
31+ D : DispersalSampler < M , H , G > + RustToCuda + Sync ,
32+ C : CoalescenceSampler < M , H , S > + RustToCuda + Sync ,
33+ T : TurnoverRate < M , H > + RustToCuda + Sync ,
34+ N : SpeciationProbability < M , H > + RustToCuda + Sync ,
35+ E : MinSpeciationTrackingEventSampler < M , H , G , S , X , D , C , T , N > + RustToCuda + Sync ,
36+ I : ImmigrationEntry < M > + RustToCuda + Sync ,
37+ A : SingularActiveLineageSampler < M , H , G , S , X , D , C , T , N , E , I > + RustToCuda + Sync ,
5038 ReportSpeciation : Boolean ,
5139 ReportDispersal : Boolean ,
52- > {
53- #[ allow( clippy:: type_complexity) ]
54- kernel : TypedKernel <
55- dyn SimulatableKernel <
56- M ,
57- H ,
58- G ,
59- S ,
60- X ,
61- D ,
62- C ,
63- T ,
64- N ,
65- E ,
66- I ,
67- A ,
68- ReportSpeciation ,
69- ReportDispersal ,
70- > ,
71- > ,
72- stream : CudaDropWrapper < Stream > ,
73- grid : GridSize ,
74- block : BlockSize ,
75- ptx_jit : bool ,
76- watcher : Box < KernelCompilationCallback > ,
77- }
78-
79- impl <
80- M : MathsCore ,
81- H : Habitat < M > + RustToCuda ,
82- G : PrimeableRng < M > + RustToCuda ,
83- S : LineageStore < M , H > + RustToCuda ,
84- X : EmigrationExit < M , H , G , S > + RustToCuda ,
85- D : DispersalSampler < M , H , G > + RustToCuda ,
86- C : CoalescenceSampler < M , H , S > + RustToCuda ,
87- T : TurnoverRate < M , H > + RustToCuda ,
88- N : SpeciationProbability < M , H > + RustToCuda ,
89- E : MinSpeciationTrackingEventSampler < M , H , G , S , X , D , C , T , N > + RustToCuda ,
90- I : ImmigrationEntry < M > + RustToCuda ,
91- A : SingularActiveLineageSampler < M , H , G , S , X , D , C , T , N , E , I > + RustToCuda ,
92- ReportSpeciation : Boolean ,
93- ReportDispersal : Boolean ,
94- > SimulationKernel < M , H , G , S , X , D , C , T , N , E , I , A , ReportSpeciation , ReportDispersal >
95- {
96- /// # Errors
97- ///
98- /// Returns a `CudaError` if loading the CUDA kernel failed.
99- pub fn try_new (
100- stream : Stream ,
101- grid : GridSize ,
102- block : BlockSize ,
103- ptx_jit : bool ,
104- on_compile : Box < KernelCompilationCallback > ,
105- ) -> CudaResult < Self >
106- where
107- Self : SimulatableKernel <
108- M ,
109- H ,
110- G ,
111- S ,
112- X ,
113- D ,
114- C ,
115- T ,
116- N ,
117- E ,
118- I ,
119- A ,
120- ReportSpeciation ,
121- ReportDispersal ,
122- > ,
123- {
124- let stream = CudaDropWrapper :: from ( stream) ;
125- let kernel = Self :: new_kernel ( ) ?;
126-
127- Ok ( Self {
128- kernel,
129- stream,
130- grid,
131- block,
132- ptx_jit,
133- watcher : on_compile,
134- } )
135- }
136- }
137-
138- impl <
139- M : MathsCore ,
140- H : Habitat < M > + RustToCuda ,
141- G : PrimeableRng < M > + RustToCuda ,
142- S : LineageStore < M , H > + RustToCuda ,
143- X : EmigrationExit < M , H , G , S > + RustToCuda ,
144- D : DispersalSampler < M , H , G > + RustToCuda ,
145- C : CoalescenceSampler < M , H , S > + RustToCuda ,
146- T : TurnoverRate < M , H > + RustToCuda ,
147- N : SpeciationProbability < M , H > + RustToCuda ,
148- E : MinSpeciationTrackingEventSampler < M , H , G , S , X , D , C , T , N > + RustToCuda ,
149- I : ImmigrationEntry < M > + RustToCuda ,
150- A : SingularActiveLineageSampler < M , H , G , S , X , D , C , T , N , E , I > + RustToCuda ,
151- ReportSpeciation : Boolean ,
152- ReportDispersal : Boolean ,
153- > Launcher
154- for SimulationKernel < M , H , G , S , X , D , C , T , N , E , I , A , ReportSpeciation , ReportDispersal >
155- {
156- type CompilationWatcher = Box < KernelCompilationCallback > ;
157- type KernelTraitObject = dyn SimulatableKernel <
158- M ,
159- H ,
160- G ,
161- S ,
162- X ,
163- D ,
164- C ,
165- T ,
166- N ,
167- E ,
168- I ,
169- A ,
170- ReportSpeciation ,
171- ReportDispersal ,
172- > ;
173-
174- fn get_launch_package ( & mut self ) -> LaunchPackage < Self > {
175- LaunchPackage {
176- config : LaunchConfig {
177- grid : self . grid . clone ( ) ,
178- block : self . block . clone ( ) ,
179- shared_memory_size : 0_u32 ,
180- ptx_jit : self . ptx_jit ,
181- } ,
182-
183- kernel : & mut self . kernel ,
184- stream : & mut self . stream ,
185-
186- watcher : & mut self . watcher ,
187- }
188- }
189-
190- fn on_compile ( kernel : & Function , watcher : & mut Self :: CompilationWatcher ) -> CudaResult < ( ) > {
191- ( watcher) ( kernel)
192- }
193- }
40+ > ( std:: marker:: PhantomData < ( M , H , G , S , X , D , C , T , N , E , I , A , ReportSpeciation , ReportDispersal ) > ) ;
0 commit comments