Skip to content

Commit 6140a1b

Browse files
Add documentation
1 parent 02ef136 commit 6140a1b

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

oneapi-rs/src/kernel.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use bytemuck::Pod;
1010
use oneapi_rs_sys::{kernel_bundle::ffi, types};
1111

12+
/// A kernel bundle which stores loaded SYCL source code.
1213
pub struct SourceKernelBundle(pub(crate) cxx::UniquePtr<types::ffi::SourceKernelBundle>);
1314

1415
impl 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.
2628
pub struct ExecutableKernelBundle(pub(crate) cxx::UniquePtr<types::ffi::ExecutableKernelBundle>);
2729

2830
impl From<cxx::UniquePtr<types::ffi::ExecutableKernelBundle>> for ExecutableKernelBundle {
@@ -37,6 +39,7 @@ impl ExecutableKernelBundle {
3739
}
3840
}
3941

42+
/// An executable SYCL kernel.
4043
pub struct Kernel(pub(crate) cxx::UniquePtr<types::ffi::Kernel>);
4144

4245
impl 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.
4852
pub 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.
5863
pub unsafe trait KernelArgumentList<const ARGC: usize> {
5964
unsafe fn as_raw_arg_list(&self) -> [&[u8]; ARGC];
6065
}

oneapi-rs/src/queue.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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>,

oneapi-rs/src/range.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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.
1719
pub 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.
1926
pub 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.
3341
pub trait ValidDimension {
3442
unsafe fn launch<const ARGC: usize>(
3543
&self,

0 commit comments

Comments
 (0)