File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99use bytemuck:: Pod ;
1010use oneapi_rs_sys:: { kernel_bundle:: ffi, types} ;
1111
12+ /// A kernel bundle which stores loaded SYCL source code.
1213pub struct SourceKernelBundle ( pub ( crate ) cxx:: UniquePtr < types:: ffi:: SourceKernelBundle > ) ;
1314
1415impl From < cxx:: UniquePtr < types:: ffi:: SourceKernelBundle > > for SourceKernelBundle {
@@ -23,6 +24,7 @@ impl SourceKernelBundle {
2324 }
2425}
2526
27+ /// A kernel bundle which stores compiled SYCL kernels.
2628pub struct ExecutableKernelBundle ( pub ( crate ) cxx:: UniquePtr < types:: ffi:: ExecutableKernelBundle > ) ;
2729
2830impl From < cxx:: UniquePtr < types:: ffi:: ExecutableKernelBundle > > for ExecutableKernelBundle {
@@ -37,6 +39,7 @@ impl ExecutableKernelBundle {
3739 }
3840}
3941
42+ /// An executable SYCL kernel.
4043pub struct Kernel ( pub ( crate ) cxx:: UniquePtr < types:: ffi:: Kernel > ) ;
4144
4245impl From < cxx:: UniquePtr < types:: ffi:: Kernel > > for Kernel {
@@ -45,6 +48,7 @@ impl From<cxx::UniquePtr<types::ffi::Kernel>> for Kernel {
4548 }
4649}
4750
51+ /// Types which can be passed as SYCL kernel arguments.
4852pub unsafe trait KernelArgument {
4953 unsafe fn as_raw_arg ( & self ) -> & [ u8 ] ;
5054}
@@ -55,6 +59,7 @@ unsafe impl<T: Pod> KernelArgument for T {
5559 }
5660}
5761
62+ /// Types which describe an argument list for a SYCL kernel.
5863pub unsafe trait KernelArgumentList < const ARGC : usize > {
5964 unsafe fn as_raw_arg_list ( & self ) -> [ & [ u8 ] ; ARGC ] ;
6065}
Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ impl Queue {
134134 ffi:: wait ( & mut self . 0 ) ;
135135 }
136136
137+ /// Enqueues a kernel object to the queue an an ND-range kernel, using the number of work-items
138+ /// specified by the [`NdRange`] nd_range.
137139 pub unsafe fn launch < const ARGC : usize , const DIMENSIONS : usize > (
138140 & mut self ,
139141 nd_range : NdRange < DIMENSIONS > ,
Original file line number Diff line number Diff line change @@ -14,8 +14,15 @@ use crate::{
1414 queue:: Queue ,
1515} ;
1616
17+ /// `Range` is a 1D, 2D or 3D vector that defines the iteration domain of either a single work-group
18+ /// in a parallel dispatch, or the overall dimensions of the dispatch.
1719pub type Range < const DIMENSIONS : usize = 1 > = [ u64 ; DIMENSIONS ] ;
1820
21+ /// The `NdRange` struct defines the iteration domain of both the work-groups and the overall
22+ /// dispatch.
23+ ///
24+ /// An `NdRange` comprises two [`Range`] parameters: the whole range over which the kernel is to be
25+ /// executed and the range of each work group.
1926pub struct NdRange < const DIMENSIONS : usize = 1 > {
2027 pub group_size : Range < DIMENSIONS > ,
2128 pub local_size : Range < DIMENSIONS > ,
@@ -30,6 +37,7 @@ impl<const DIMENSIONS: usize> NdRange<DIMENSIONS> {
3037 }
3138}
3239
40+ /// [`NdRange`] types which are limited to 1, 2 or 3 dimensions.
3341pub trait ValidDimension {
3442 unsafe fn launch < const ARGC : usize > (
3543 & self ,
You can’t perform that action at this time.
0 commit comments