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

A func operation. Function executable on a GPU.

Defines a function that can be executed on a GPU. This supports memory attribution and its body has a particular execution model.

GPU functions are either kernels (as indicated by the kernel attribute) or regular functions. The former can be launched from the host side, while the latter are device side only.

The memory attribution defines SSA values that correspond to memory buffers allocated in the memory hierarchy of the GPU (see below).

The operation has one attached region that corresponds to the body of the function. The region arguments consist of the function arguments without modification, followed by buffers defined in memory annotations. The body of a GPU function, when launched, is executed by multiple work items. There are no guarantees on the order in which work items execute, or on the connection between them. In particular, work items are not necessarily executed in lock-step. Synchronization ops such as “gpu.barrier” should be used to coordinate work items. Declarations of GPU functions, i.e. not having the body region, are not supported.

A function may optionally be annotated with the block and/or grid sizes that will be used when it is launched using the gpu.known_block_size and gpu.known_grid_size attributes, respectively. If set, these attributes must be arrays of three 32-bit integers giving the x, y, and z launch dimensions. Launching a kernel that has these annotations, or that calls a function with these annotations, using a block size or grid size other than what is specified is undefined behavior.

Syntax:

op ::= `gpu.func` symbol-ref-id `(` argument-list `)` (`->`
function-result-list)?
       memory-attribution `kernel`? function-attributes? region

memory-attribution ::= (`workgroup` `(` ssa-id-and-type-list `)`)?
                       (`private` `(` ssa-id-and-type-list `)`)?

Example:

gpu.func @foo(%arg0: index)
    workgroup(%workgroup: memref<32xf32, 3>)
    private(%private: memref<1xf32, 5>)
    kernel
    attributes {qux: "quux"} {
  gpu.return
}

The generic form illustrates the concept

"gpu.func"(%arg: index) {sym_name: "foo", kernel, qux: "quux"} ({
^bb0(%arg0: index, %workgroup: memref<32xf32, 3>,
     %private: memref<1xf32, 5>):
  "gpu.return"() : () -> ()
}) : (index) -> ()

Note the non-default memory spaces used in memref types in memory attribution.

Implementations§

source§

impl<'c> GPUFuncOperation<'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> ) -> GPUFuncOperationBuilder<'c, Unset, Unset>

Creates a builder.

source

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

source

pub fn function_type(&self) -> Result<TypeAttribute<'c>, Error>

source

pub fn set_function_type(&mut self, value: TypeAttribute<'c>)

source

pub fn arg_attrs(&self) -> Result<ArrayAttribute<'c>, Error>

source

pub fn set_arg_attrs(&mut self, value: ArrayAttribute<'c>)

source

pub fn remove_arg_attrs(&mut self) -> Result<(), Error>

source

pub fn res_attrs(&self) -> Result<ArrayAttribute<'c>, Error>

source

pub fn set_res_attrs(&mut self, value: ArrayAttribute<'c>)

source

pub fn remove_res_attrs(&mut self) -> Result<(), Error>

source

pub fn workgroup_attrib_attrs(&self) -> Result<ArrayAttribute<'c>, Error>

source

pub fn set_workgroup_attrib_attrs(&mut self, value: ArrayAttribute<'c>)

source

pub fn remove_workgroup_attrib_attrs(&mut self) -> Result<(), Error>

source

pub fn private_attrib_attrs(&self) -> Result<ArrayAttribute<'c>, Error>

source

pub fn set_private_attrib_attrs(&mut self, value: ArrayAttribute<'c>)

source

pub fn remove_private_attrib_attrs(&mut self) -> Result<(), Error>

Trait Implementations§

source§

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

source§

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

Converts to this type from the input type.
source§

impl<'c> TryFrom<Operation<'c>> for GPUFuncOperation<'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 GPUFuncOperation<'c>

§

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

§

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

§

impl<'c> Unpin for GPUFuncOperation<'c>

§

impl<'c> UnwindSafe for GPUFuncOperation<'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.