mod ptx;
mod wgsl;
use super::{
LZ4_HASH_BITS, LZ4_HASH_MULT, LZ4_HASH_SIZE, LZ4_MAX_OFFSET, LZ4_MIN_MATCH, PAGE_SIZE,
};
#[derive(Debug, Clone)]
pub struct Lz4WarpCompressKernel {
batch_size: u32,
}
impl Lz4WarpCompressKernel {
#[must_use]
pub fn new(batch_size: u32) -> Self {
Self { batch_size }
}
#[must_use]
pub fn batch_size(&self) -> u32 {
self.batch_size
}
#[must_use]
pub fn grid_dim(&self) -> (u32, u32, u32) {
let pages_per_block = 4;
let num_blocks = (self.batch_size + pages_per_block - 1) / pages_per_block;
(num_blocks, 1, 1)
}
#[must_use]
pub fn block_dim(&self) -> (u32, u32, u32) {
(128, 1, 1)
}
#[must_use]
pub fn shared_memory_bytes(&self) -> usize {
4 * (PAGE_SIZE as usize + LZ4_HASH_SIZE as usize * 2)
}
}
#[cfg(test)]
mod tests;