use anu::nam_args_api::{ArgDescriptor, ArgValue, GpuType, IngressContext};
use std::marker::PhantomData;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct GpuTileMem<T, const N: usize> {
_phantom: PhantomData<T>,
}
impl<T, const N: usize> GpuTileMem<T, N> {
#[inline(always)]
pub const fn new() -> Self {
Self {
_phantom: PhantomData,
}
}
#[inline(always)]
pub const fn len(&self) -> usize {
N
}
#[inline(always)]
pub const fn is_empty(&self) -> bool {
N == 0
}
}
impl<T: Copy + Send + Sync + 'static, const N: usize> GpuType for GpuTileMem<T, N> {
fn describe() -> ArgDescriptor {
ArgDescriptor::workgroup_scratchpad::<T, N>()
}
fn collect<'a>(&self, ctx: &mut IngressContext<'a>) {
let desc = Self::describe();
ctx.push_arg(ArgValue::ZeroFootprint, desc);
}
}
impl<T: Copy + Send + Sync + 'static, const N: usize> GpuType for &GpuTileMem<T, N> {
fn describe() -> ArgDescriptor {
ArgDescriptor::workgroup_scratchpad::<T, N>()
}
fn collect<'a>(&self, ctx: &mut IngressContext<'a>) {
GpuType::collect(*self, ctx);
}
}