Skip to content

Commit

Permalink
expose kernel module for RawKernelDef
Browse files Browse the repository at this point in the history
  • Loading branch information
shiinamiyuki committed Oct 3, 2023
1 parent adb204b commit e89457b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
32 changes: 31 additions & 1 deletion luisa_compute/src/lang/soa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,36 @@ use crate::prelude::*;
/** A buffer with SOA layout.
*/
pub struct SoaBuffer<T: Value> {
inner: ByteBuffer,
storage: ByteBuffer,
view: SoaBufferView<'static, T>,
_marker: std::marker::PhantomData<T>,
}

pub struct SoaBufferView<'a, T: Value> {
inner: ByteBufferView<'a>,
_marker: std::marker::PhantomData<T>,
}

fn compute_number_of_32bits_buffers(ty: &Type) -> usize {
match ty {
Type::Void => unreachable!(),
Type::UserData => unreachable!(),
Type::Primitive(_) => todo!(),
Type::Vector(_) => todo!(),
Type::Matrix(_) => todo!(),
Type::Struct(_) => todo!(),
Type::Array(_) => todo!(),
Type::Opaque(_) => todo!(),
}
}

// impl<T> IndexRead for SoaBuffer<T>
// where
// T: Value,
// {
// type Element = T;
// fn read<I: super::index::IntoIndex>(&self, i: I) -> Expr<Self::Element> {
// let i = i.to_u64();
// todo!()
// }
// }
18 changes: 16 additions & 2 deletions luisa_compute/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,10 @@ impl Drop for StreamHandle {
/// To prevent a scope from synchronizing on drop, use [`Scope::detach`].Note this is only
/// available for `Scope<'static>` as certain commands such as `copy_to_async<'a>` requires
/// synchronization.
///
///
/// **WARNING**: attempting to circumvent `drop` on `Scope<'a>, 'a != 'static` can result in
/// undefined behavior.
///
///
pub struct Scope<'a> {
handle: Arc<StreamHandle>,
marker: PhantomData<&'a ()>,
Expand Down Expand Up @@ -1310,13 +1310,27 @@ pub struct RawKernelDef {
pub(crate) resource_tracker: ResourceTracker,
}

impl RawKernelDef {
#[doc(hidden)]
pub fn kernel_module(&self) -> &KernelModule {
self.module.as_ref()
}
}

/// A kernel definition
/// See [`Kernel<T>`] for more information
pub struct KernelDef<T: KernelSignature> {
pub(crate) inner: RawKernelDef,
pub(crate) _marker: PhantomData<T>,
}

impl<T: KernelSignature> KernelDef<T> {
#[doc(hidden)]
pub fn raw_def(&self) -> &RawKernelDef {
&self.inner
}
}

/// An executable kernel
/// Kernel creation can be done in multiple ways:
/// - Seperate recording and compilation:
Expand Down

0 comments on commit e89457b

Please sign in to comment.