Skip to main content

ruprim/reduce/launch/
strategy.rs

1use ruda_kernel::dsl as kernel_dsl;
2use crate::reduce::routines::{
3    BlueprintStrategy, ruda::RudaRoutine, plane::PlaneRoutine, unit::UnitRoutine,
4};
5use ruda_kernel::dsl::ir::features::Plane;
6use ruda_kernel::dsl::prelude::*;
7
8#[derive(Debug, Clone)]
9pub struct ReduceStrategy {
10    pub routine: RoutineStrategy,
11    pub vectorization: VectorizationStrategy,
12}
13
14#[derive(Debug, Clone)]
15pub enum RoutineStrategy {
16    /// A unit is responsible to reduce a full vector.
17    Unit(BlueprintStrategy<UnitRoutine>),
18    /// A plane is responsible to reduce a full vector.
19    Plane(BlueprintStrategy<PlaneRoutine>),
20    /// A ruda is responsible to reduce a full vector.
21    Ruda(BlueprintStrategy<RudaRoutine>),
22}
23
24#[derive(Debug, Clone, Copy)]
25pub struct VectorizationStrategy {
26    /// When the vectorization is parallel, enable vectorization of the output so that each
27    /// unit can perform N reductions, where N is the output `vector_size`.
28    pub parallel_output_vectorization: bool,
29}
30
31pub(crate) fn support_plane<R: Runtime>(client: &ComputeClient<R>) -> bool {
32    client.properties().features.plane.contains(Plane::Ops)
33}