|
9 | 9 | use bytemuck::Pod; |
10 | 10 | use oneapi_rs_sys::{kernel_bundle::ffi, types}; |
11 | 11 |
|
12 | | -use crate::{event::Event, queue::Queue}; |
13 | | - |
14 | 12 | pub struct SourceKernelBundle(pub(crate) cxx::UniquePtr<types::ffi::SourceKernelBundle>); |
15 | 13 |
|
16 | 14 | impl From<cxx::UniquePtr<types::ffi::SourceKernelBundle>> for SourceKernelBundle { |
@@ -60,100 +58,3 @@ unsafe impl<T: Pod> KernelArgument for T { |
60 | 58 | pub unsafe trait KernelArgumentList<const ARGC: usize> { |
61 | 59 | unsafe fn as_raw_arg_list(&self) -> [&[u8]; ARGC]; |
62 | 60 | } |
63 | | - |
64 | | -pub type Range<const DIMENSIONS: usize = 1> = [u64; DIMENSIONS]; |
65 | | - |
66 | | -pub struct NdRange<const DIMENSIONS: usize = 1> { |
67 | | - pub group_size: Range<DIMENSIONS>, |
68 | | - pub local_size: Range<DIMENSIONS>, |
69 | | -} |
70 | | - |
71 | | -impl<const DIMENSIONS: usize> NdRange<DIMENSIONS> { |
72 | | - pub fn new(group_size: Range<DIMENSIONS>, local_size: Range<DIMENSIONS>) -> Self { |
73 | | - Self { |
74 | | - group_size, |
75 | | - local_size, |
76 | | - } |
77 | | - } |
78 | | -} |
79 | | - |
80 | | -pub trait ValidDimension { |
81 | | - unsafe fn launch<const ARGC: usize>( |
82 | | - &self, |
83 | | - queue: &mut Queue, |
84 | | - kernel: &Kernel, |
85 | | - args: impl KernelArgumentList<ARGC>, |
86 | | - ) -> Event; |
87 | | -} |
88 | | - |
89 | | -impl ValidDimension for NdRange<1> { |
90 | | - unsafe fn launch<const ARGC: usize>( |
91 | | - &self, |
92 | | - queue: &mut Queue, |
93 | | - kernel: &Kernel, |
94 | | - args: impl KernelArgumentList<ARGC>, |
95 | | - ) -> Event { |
96 | | - unsafe { |
97 | | - oneapi_rs_sys::queue::ffi::launch_1d( |
98 | | - &mut queue.0, |
99 | | - types::ffi::Range1 { |
100 | | - data: self.group_size, |
101 | | - }, |
102 | | - types::ffi::Range1 { |
103 | | - data: self.local_size, |
104 | | - }, |
105 | | - &kernel.0, |
106 | | - &args.as_raw_arg_list(), |
107 | | - ) |
108 | | - } |
109 | | - .into() |
110 | | - } |
111 | | -} |
112 | | - |
113 | | -impl ValidDimension for NdRange<2> { |
114 | | - unsafe fn launch<const ARGC: usize>( |
115 | | - &self, |
116 | | - queue: &mut Queue, |
117 | | - kernel: &Kernel, |
118 | | - args: impl KernelArgumentList<ARGC>, |
119 | | - ) -> Event { |
120 | | - unsafe { |
121 | | - oneapi_rs_sys::queue::ffi::launch_2d( |
122 | | - &mut queue.0, |
123 | | - types::ffi::Range2 { |
124 | | - data: self.group_size, |
125 | | - }, |
126 | | - types::ffi::Range2 { |
127 | | - data: self.local_size, |
128 | | - }, |
129 | | - &kernel.0, |
130 | | - &args.as_raw_arg_list(), |
131 | | - ) |
132 | | - } |
133 | | - .into() |
134 | | - } |
135 | | -} |
136 | | - |
137 | | -impl ValidDimension for NdRange<3> { |
138 | | - unsafe fn launch<const ARGC: usize>( |
139 | | - &self, |
140 | | - queue: &mut Queue, |
141 | | - kernel: &Kernel, |
142 | | - args: impl KernelArgumentList<ARGC>, |
143 | | - ) -> Event { |
144 | | - unsafe { |
145 | | - oneapi_rs_sys::queue::ffi::launch_3d( |
146 | | - &mut queue.0, |
147 | | - types::ffi::Range3 { |
148 | | - data: self.group_size, |
149 | | - }, |
150 | | - types::ffi::Range3 { |
151 | | - data: self.local_size, |
152 | | - }, |
153 | | - &kernel.0, |
154 | | - &args.as_raw_arg_list(), |
155 | | - ) |
156 | | - } |
157 | | - .into() |
158 | | - } |
159 | | -} |
0 commit comments