pub struct ParallelOperation<'c> { /* private fields */ }
Expand description

A parallel operation. Parallel for operation.

The “scf.parallel” operation represents a loop nest taking 4 groups of SSA values as operands that represent the lower bounds, upper bounds, steps and initial values, respectively. The operation defines a variadic number of SSA values for its induction variables. It has one region capturing the loop body. The induction variables are represented as an argument of this region. These SSA values always have type index, which is the size of the machine word. The steps are values of type index, required to be positive. The lower and upper bounds specify a half-open range: the range includes the lower bound but does not include the upper bound. The initial values have the same types as results of “scf.parallel”. If there are no results, the keyword init can be omitted.

Semantically we require that the iteration space can be iterated in any order, and the loop body can be executed in parallel. If there are data races, the behavior is undefined.

The parallel loop operation supports reduction of values produced by individual iterations into a single result. This is modeled using the scf.reduce operation (see scf.reduce for details). Each result of a scf.parallel operation is associated with an initial value operand and reduce operation that is an immediate child. Reductions are matched to result and initial values in order of their appearance in the body. Consequently, we require that the body region has the same number of results and initial values as it has reduce operations.

The body region must contain exactly one block that terminates with “scf.yield” without operands. Parsing ParallelOp will create such a region and insert the terminator when it is absent from the custom format.

Example:

%init = arith.constant 0.0 : f32
scf.parallel (%iv) = (%lb) to (%ub) step (%step) init (%init) -> f32 {
  %elem_to_reduce = load %buffer[%iv] : memref<100xf32>
  scf.reduce(%elem_to_reduce) : f32 {
    ^bb0(%lhs : f32, %rhs: f32):
      %res = arith.addf %lhs, %rhs : f32
      scf.reduce.return %res : f32
  }
}

Implementations§

source§

impl<'c> ParallelOperation<'c>

source

pub fn name() -> &'static str

Returns a name.

source

pub fn as_operation(&self) -> &Operation<'c>

Returns a generic operation.

source

pub fn builder( context: &'c Context, location: Location<'c> ) -> ParallelOperationBuilder<'c, Unset, Unset, Unset, Unset, Unset, Unset>

Creates a builder.

source

pub fn results(&self) -> impl Iterator<Item = OperationResult<'c, '_>>

source

pub fn lower_bound(&self) -> Result<impl Iterator<Item = Value<'c, '_>>, Error>

source

pub fn upper_bound(&self) -> Result<impl Iterator<Item = Value<'c, '_>>, Error>

source

pub fn step(&self) -> Result<impl Iterator<Item = Value<'c, '_>>, Error>

source

pub fn init_vals(&self) -> Result<impl Iterator<Item = Value<'c, '_>>, Error>

source

pub fn region(&self) -> Result<RegionRef<'c, '_>, Error>

Trait Implementations§

source§

impl<'c> From<ParallelOperation<'c>> for Operation<'c>

source§

fn from(operation: ParallelOperation<'c>) -> Self

Converts to this type from the input type.
source§

impl<'c> TryFrom<Operation<'c>> for ParallelOperation<'c>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(operation: Operation<'c>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'c> RefUnwindSafe for ParallelOperation<'c>

§

impl<'c> !Send for ParallelOperation<'c>

§

impl<'c> !Sync for ParallelOperation<'c>

§

impl<'c> Unpin for ParallelOperation<'c>

§

impl<'c> UnwindSafe for ParallelOperation<'c>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.