Skip to main content

oximedia_gpu/kernels/
mod.rs

1//! GPU compute kernels library
2//!
3//! This module provides a comprehensive library of GPU compute kernels
4//! for common image and signal processing operations.
5
6pub mod color;
7pub mod filter;
8pub mod reduce;
9pub mod resize;
10pub mod transform;
11
12pub use color::{ColorConversionKernel, ColorSpace as KernelColorSpace};
13pub use filter::{ConvolutionKernel, FilterKernel};
14pub use reduce::{ReduceKernel, ReduceOp};
15pub use resize::{ResizeFilter, ResizeKernel};
16pub use transform::{TransformKernel, TransformType};
17
18/// Kernel execution statistics
19#[derive(Debug, Clone, Copy, Default)]
20pub struct KernelStats {
21    /// Number of workgroups dispatched
22    pub workgroups: (u32, u32, u32),
23    /// Total number of threads
24    pub total_threads: u64,
25    /// Estimated FLOPS (floating-point operations)
26    pub estimated_flops: u64,
27}
28
29impl KernelStats {
30    /// Create new kernel statistics
31    #[must_use]
32    pub fn new(workgroups: (u32, u32, u32), threads_per_workgroup: u32) -> Self {
33        let total_threads = u64::from(workgroups.0)
34            * u64::from(workgroups.1)
35            * u64::from(workgroups.2)
36            * u64::from(threads_per_workgroup);
37
38        Self {
39            workgroups,
40            total_threads,
41            estimated_flops: 0,
42        }
43    }
44
45    /// Set the estimated FLOPS
46    #[must_use]
47    pub fn with_flops(mut self, flops: u64) -> Self {
48        self.estimated_flops = flops;
49        self
50    }
51}