pub(crate) mod memory_pool;
mod base;
pub use base::*;
mod memory_manage;
use cubecl_common::CubeDim;
pub use memory_manage::*;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[derive(Debug, Clone)]
pub enum PoolType {
ExclusivePages {
max_alloc_size: u64,
},
SlicedPages {
page_size: u64,
max_slice_size: u64,
},
}
#[derive(Debug, Clone)]
pub struct MemoryPoolOptions {
pub pool_type: PoolType,
pub dealloc_period: Option<u64>,
}
#[derive(Clone, Debug)]
pub enum MemoryConfiguration {
#[cfg(not(exclusive_memory_only))]
SubSlices,
ExclusivePages,
Custom {
pool_options: Vec<MemoryPoolOptions>,
},
}
#[allow(clippy::derivable_impls)]
impl Default for MemoryConfiguration {
fn default() -> Self {
#[cfg(exclusive_memory_only)]
{
MemoryConfiguration::ExclusivePages
}
#[cfg(not(exclusive_memory_only))]
{
MemoryConfiguration::SubSlices
}
}
}
#[derive(Debug, Clone)]
pub struct MemoryDeviceProperties {
pub max_page_size: u64,
pub alignment: u64,
}
#[derive(Debug, Clone)]
pub struct HardwareProperties {
pub plane_size_min: u32,
pub plane_size_max: u32,
pub max_bindings: u32,
pub max_shared_memory_size: usize,
pub max_cube_count: CubeDim,
pub max_units_per_cube: u32,
pub max_cube_dim: CubeDim,
pub num_streaming_multiprocessors: Option<u32>,
pub num_tensor_cores: Option<u32>,
}
impl HardwareProperties {
pub fn defined_plane_size(&self) -> Option<u32> {
#[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
if self.plane_size_min == self.plane_size_max {
Some(self.plane_size_min)
} else {
None
}
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
{
Some(32)
}
}
}