pub struct SubgroupReduceOperation<'c> { /* private fields */ }Expand description
A subgroup_reduce operation. Reduce values among subgroup..
The subgroup_reduce op reduces the values of lanes (work items) across a
subgroup.
The subgroup is divided into clusters starting at lane index 0. Within each
cluster, there are size lanes, and the lane index advances by stride.
A reduction is done for each cluster in parallel: every lane in the cluster
is reduced, and the result is equal for all lanes in the cluster. If size
is omitted, there is a single cluster covering the entire subgroup. If
stride is omitted, the stride is 1 (the cluster’s lanes are contiguous).
When the reduced value is of a vector type, each vector element is reduced independently. Only 1-d vector types are allowed.
Example:
%1 = gpu.subgroup_reduce add %a : (f32) -> f32
%2 = gpu.subgroup_reduce add %b : (vector<4xf16>) -> vector<4xf16>
%3 = gpu.subgroup_reduce add %c cluster(size = 4) : (f32) -> f32
%3 = gpu.subgroup_reduce add %c cluster(size = 4, stride = 2) : (f32) -> f32If uniform flag is set either none or all lanes of a subgroup need to execute
this op in convergence.
The reduction operation must be one of:
- Integer types:
add,mul,minui,minsi,maxui,maxsi,and,or,xor - Floating point types:
add,mul,minnumf,maxnumf,minimumf,maximumf
Implementations§
Source§impl<'c> SubgroupReduceOperation<'c>
impl<'c> SubgroupReduceOperation<'c>
Sourcepub fn as_operation(&self) -> &Operation<'c>
pub fn as_operation(&self) -> &Operation<'c>
Returns a generic operation.
Sourcepub fn builder(
context: &'c Context,
location: Location<'c>,
) -> SubgroupReduceOperationBuilder<'c, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c>, ) -> SubgroupReduceOperationBuilder<'c, Unset, Unset>
Creates a builder.
pub fn result(&self) -> Result<OperationResult<'c, '_>, Error>
pub fn value(&self) -> Result<Value<'c, '_>, Error>
pub fn op(&self) -> Result<Attribute<'c>, Error>
pub fn set_op(&mut self, value: Attribute<'c>)
pub fn uniform(&self) -> Result<Attribute<'c>, Error>
pub fn set_uniform(&mut self, value: Attribute<'c>)
pub fn remove_uniform(&mut self) -> Result<(), Error>
pub fn cluster_size(&self) -> Result<IntegerAttribute<'c>, Error>
pub fn set_cluster_size(&mut self, value: IntegerAttribute<'c>)
pub fn remove_cluster_size(&mut self) -> Result<(), Error>
pub fn cluster_stride(&self) -> Result<IntegerAttribute<'c>, Error>
pub fn set_cluster_stride(&mut self, value: IntegerAttribute<'c>)
pub fn remove_cluster_stride(&mut self) -> Result<(), Error>
Trait Implementations§
Source§impl<'c> Clone for SubgroupReduceOperation<'c>
impl<'c> Clone for SubgroupReduceOperation<'c>
Source§fn clone(&self) -> SubgroupReduceOperation<'c>
fn clone(&self) -> SubgroupReduceOperation<'c>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more