cubecl_runtime/
feature_set.rs1use crate::memory_management::{HardwareProperties, MemoryDeviceProperties};
2use alloc::collections::BTreeSet;
3use cubecl_common::profile::TimingMethod;
4
5#[derive(Debug)]
8pub struct DeviceProperties<Feature: Ord + Copy> {
9 set: alloc::collections::BTreeSet<Feature>,
10 pub memory: MemoryDeviceProperties,
12 pub hardware: HardwareProperties,
14 pub timing_method: TimingMethod,
16}
17
18impl<Feature: Ord + Copy> DeviceProperties<Feature> {
19 pub fn new(
21 features: &[Feature],
22 memory_props: MemoryDeviceProperties,
23 hardware: HardwareProperties,
24 timing_method: TimingMethod,
25 ) -> Self {
26 let mut set = BTreeSet::new();
27 for feature in features {
28 set.insert(*feature);
29 }
30
31 DeviceProperties {
32 set,
33 memory: memory_props,
34 hardware,
35 timing_method,
36 }
37 }
38
39 pub fn feature_enabled(&self, feature: Feature) -> bool {
41 self.set.contains(&feature)
42 }
43
44 pub fn register_feature(&mut self, feature: Feature) -> bool {
48 self.set.insert(feature)
49 }
50
51 pub fn remove_feature(&mut self, feature: Feature) {
55 self.set.remove(&feature);
56 }
57}