Gpu
gpu
¶
GPU = Dialect('gpu', [AllocOp, AllReduceOp, BarrierOp, BlockDimOp, BlockIdOp, DeallocOp, FuncOp, GlobalIdOp, GridDimOp, HostRegisterOp, HostUnregisterOp, LaneIdOp, LaunchOp, LaunchFuncOp, MemcpyOp, ModuleOp, NumSubgroupsOp, ReturnOp, SetDefaultDeviceOp, SubgroupIdOp, SubgroupSizeOp, TerminatorOp, ThreadIdOp, WaitOp, YieldOp], [AsyncTokenType, AllReduceOpAttr, DimensionAttr, ProcessorAttr, LoopDimMapAttr])
module-attribute
¶
AsyncTokenType
dataclass
¶
Bases: ParametrizedAttribute, TypeAttribute
Source code in xdsl/dialects/gpu.py
name = 'gpu.async.token'
class-attribute
instance-attribute
¶
AllReduceOpEnum
¶
Bases: StrEnum
Source code in xdsl/dialects/gpu.py
Add = auto()
class-attribute
instance-attribute
¶
And = auto()
class-attribute
instance-attribute
¶
Max = auto()
class-attribute
instance-attribute
¶
Min = auto()
class-attribute
instance-attribute
¶
Mul = auto()
class-attribute
instance-attribute
¶
Or = auto()
class-attribute
instance-attribute
¶
Xor = auto()
class-attribute
instance-attribute
¶
DimensionEnum
¶
ProcessorEnum
¶
Bases: StrEnum
Source code in xdsl/dialects/gpu.py
Sequential = auto()
class-attribute
instance-attribute
¶
Block_X = auto()
class-attribute
instance-attribute
¶
Block_Y = auto()
class-attribute
instance-attribute
¶
Block_Z = auto()
class-attribute
instance-attribute
¶
Thread_X = auto()
class-attribute
instance-attribute
¶
Thread_Y = auto()
class-attribute
instance-attribute
¶
Thread_Z = auto()
class-attribute
instance-attribute
¶
AllReduceOpAttr
dataclass
¶
Bases: EnumAttribute[AllReduceOpEnum], SpacedOpaqueSyntaxAttribute
Source code in xdsl/dialects/gpu.py
name = 'gpu.all_reduce_op'
class-attribute
instance-attribute
¶
DimensionAttr
dataclass
¶
Bases: EnumAttribute[DimensionEnum], SpacedOpaqueSyntaxAttribute
Source code in xdsl/dialects/gpu.py
name = 'gpu.dim'
class-attribute
instance-attribute
¶
ProcessorAttr
dataclass
¶
Bases: EnumAttribute[ProcessorEnum], SpacedOpaqueSyntaxAttribute
Source code in xdsl/dialects/gpu.py
name = 'gpu.processor'
class-attribute
instance-attribute
¶
LoopDimMapAttr
dataclass
¶
Bases: ParametrizedAttribute
Source code in xdsl/dialects/gpu.py
name = 'gpu.loop_dim_map'
class-attribute
instance-attribute
¶
processor: ProcessorAttr
instance-attribute
¶
map: AffineMapAttr
instance-attribute
¶
bound: AffineMapAttr
instance-attribute
¶
print_parameters(printer: Printer) -> None
¶
Source code in xdsl/dialects/gpu.py
parse_parameters(parser: AttrParser)
classmethod
¶
Source code in xdsl/dialects/gpu.py
AllocOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
name = 'gpu.alloc'
class-attribute
instance-attribute
¶
hostShared = opt_attr_def(UnitAttr)
class-attribute
instance-attribute
¶
asyncDependencies = var_operand_def(AsyncTokenType)
class-attribute
instance-attribute
¶
dynamicSizes = var_operand_def(IndexType)
class-attribute
instance-attribute
¶
symbolOperands = var_operand_def(IndexType)
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(as_property=True),)
class-attribute
instance-attribute
¶
result = result_def(memref.MemRefType)
class-attribute
instance-attribute
¶
asyncToken = opt_result_def(AsyncTokenType)
class-attribute
instance-attribute
¶
verify_() -> None
¶
Source code in xdsl/dialects/gpu.py
__init__(return_type: memref.MemRefType, dynamic_sizes: Sequence[SSAValue | Operation] | None = None, host_shared: bool = False, async_dependencies: Sequence[SSAValue | Operation] | None = None, is_async: bool = False)
¶
Source code in xdsl/dialects/gpu.py
AllReduceOp
dataclass
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
name = 'gpu.all_reduce'
class-attribute
instance-attribute
¶
op = opt_prop_def(AllReduceOpAttr)
class-attribute
instance-attribute
¶
uniform = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
operand = operand_def(Attribute)
class-attribute
instance-attribute
¶
result = result_def(Attribute)
class-attribute
instance-attribute
¶
body = region_def()
class-attribute
instance-attribute
¶
traits = traits_def(IsolatedFromAbove())
class-attribute
instance-attribute
¶
from_op(op: AllReduceOpAttr, operand: SSAValue | Operation, uniform: UnitAttr | None = None)
staticmethod
¶
Source code in xdsl/dialects/gpu.py
from_body(body: Region, operand: SSAValue | Operation, uniform: UnitAttr | None = None)
staticmethod
¶
Source code in xdsl/dialects/gpu.py
verify_() -> None
¶
Source code in xdsl/dialects/gpu.py
BarrierOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
BlockDimOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
BlockIdOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
DeallocOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
name = 'gpu.dealloc'
class-attribute
instance-attribute
¶
asyncDependencies = var_operand_def(AsyncTokenType)
class-attribute
instance-attribute
¶
buffer = operand_def(memref.MemRefType)
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(),)
class-attribute
instance-attribute
¶
asyncToken = opt_result_def(AsyncTokenType)
class-attribute
instance-attribute
¶
__init__(buffer: SSAValue | Operation, async_dependencies: Sequence[SSAValue | Operation] | None = None, is_async: bool = False)
¶
Source code in xdsl/dialects/gpu.py
MemcpyOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
name = 'gpu.memcpy'
class-attribute
instance-attribute
¶
asyncDependencies = var_operand_def(AsyncTokenType)
class-attribute
instance-attribute
¶
dst = operand_def(memref.MemRefType)
class-attribute
instance-attribute
¶
src = operand_def(memref.MemRefType)
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(),)
class-attribute
instance-attribute
¶
asyncToken = opt_result_def(AsyncTokenType)
class-attribute
instance-attribute
¶
__init__(source: SSAValue | Operation, destination: SSAValue | Operation, async_dependencies: Sequence[SSAValue | Operation] | None = None, is_async: bool = False)
¶
Source code in xdsl/dialects/gpu.py
ModuleOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
name = 'gpu.module'
class-attribute
instance-attribute
¶
body = region_def('single_block')
class-attribute
instance-attribute
¶
sym_name = prop_def(SymbolNameConstraint())
class-attribute
instance-attribute
¶
traits = traits_def(IsolatedFromAbove(), NoTerminator(), SymbolOpInterface(), SymbolTable())
class-attribute
instance-attribute
¶
FuncOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
name = 'gpu.func'
class-attribute
instance-attribute
¶
body = region_def()
class-attribute
instance-attribute
¶
sym_name = attr_def(SymbolNameConstraint())
class-attribute
instance-attribute
¶
function_type = prop_def(FunctionType)
class-attribute
instance-attribute
¶
kernel = opt_prop_def(UnitAttr)
class-attribute
instance-attribute
¶
known_block_size = opt_attr_def(DenseArrayBase.constr(i32), attr_name='gpu.known_block_size')
class-attribute
instance-attribute
¶
known_grid_size = opt_attr_def(DenseArrayBase.constr(i32), attr_name='gpu.known_grid_size')
class-attribute
instance-attribute
¶
traits = traits_def(IsolatedFromAbove(), HasParent(ModuleOp), SymbolOpInterface())
class-attribute
instance-attribute
¶
__init__(name: str, function_type: FunctionType | tuple[Sequence[Attribute], Sequence[Attribute]], region: Region | type[Region.DEFAULT] = Region.DEFAULT, kernel: bool | None = None, known_block_size: Sequence[int] | None = None, known_grid_size: Sequence[int] | None = None)
¶
Source code in xdsl/dialects/gpu.py
verify_()
¶
Source code in xdsl/dialects/gpu.py
GlobalIdOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
GridDimOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
HostRegisterOp
¶
Bases: IRDLOperation
This op maps the provided host buffer into the device address space.
This operation may not be supported in every environment, there is not yet a way to check at runtime whether this feature is supported. Writes from the host are guaranteed to be visible to device kernels that are launched afterwards. Writes from the device are guaranteed to be visible on the host after synchronizing with the device kernel completion.
Source code in xdsl/dialects/gpu.py
HostUnregisterOp
¶
Bases: IRDLOperation
Unregisters a memref for access from device.
Source code in xdsl/dialects/gpu.py
LaneIdOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
LaunchOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
name = 'gpu.launch'
class-attribute
instance-attribute
¶
asyncDependencies = var_operand_def(AsyncTokenType)
class-attribute
instance-attribute
¶
gridSizeX = operand_def(IndexType)
class-attribute
instance-attribute
¶
gridSizeY = operand_def(IndexType)
class-attribute
instance-attribute
¶
gridSizeZ = operand_def(IndexType)
class-attribute
instance-attribute
¶
blockSizeX = operand_def(IndexType)
class-attribute
instance-attribute
¶
blockSizeY = operand_def(IndexType)
class-attribute
instance-attribute
¶
blockSizeZ = operand_def(IndexType)
class-attribute
instance-attribute
¶
clusterSizeX = opt_operand_def(IndexType)
class-attribute
instance-attribute
¶
clusterSizeY = opt_operand_def(IndexType)
class-attribute
instance-attribute
¶
clusterSizeZ = opt_operand_def(IndexType)
class-attribute
instance-attribute
¶
dynamicSharedMemorySize = opt_operand_def(i32)
class-attribute
instance-attribute
¶
asyncToken = opt_result_def(AsyncTokenType)
class-attribute
instance-attribute
¶
body = region_def()
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(as_property=True),)
class-attribute
instance-attribute
¶
__init__(body: Region, gridSize: Sequence[SSAValue | Operation], blockSize: Sequence[SSAValue | Operation], clusterSize: Sequence[SSAValue | Operation] = [], async_launch: bool = False, asyncDependencies: Sequence[SSAValue | Operation] | None = None, dynamicSharedMemorySize: SSAValue | Operation | None = None)
¶
Source code in xdsl/dialects/gpu.py
verify_() -> None
¶
Source code in xdsl/dialects/gpu.py
LaunchFuncOp
¶
Bases: IRDLOperation
Launch a kernel function on the specified grid of thread blocks. gpu.launch operations are lowered to gpu.launch_func operations by outlining the kernel body into a function in a dedicated module, which reflects the separate compilation process. The kernel function is required to have the gpu.kernel attribute. The module containing the kernel function is required to be a gpu.module. And finally, the module containing the kernel module (which thus cannot be the top-level module) is required to have the gpu.container_module attribute. The gpu.launch_func operation has a symbol attribute named kernel to identify the fully specified kernel function to launch (both the gpu.module and func).
The gpu.launch_func supports async dependencies: the kernel does not start executing until the ops producing those async dependencies have completed.
By default, the host implicitly blocks until kernel execution has completed. If the async keyword is present, the host does not block but instead a !gpu.async.token is returned. Other async GPU ops can take this token as dependency.
The operation requires at least the grid and block sizes along the x,y,z dimensions as arguments. When a lower-dimensional kernel is required, unused sizes must be explicitly set to 1.
The remaining operands are optional. The first optional operand corresponds to the amount of dynamic shared memory a kernel's workgroup should be allocated; when this operand is not present, a zero size is assumed.
The remaining operands if present are passed as arguments to the kernel function.
Source code in xdsl/dialects/gpu.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
name = 'gpu.launch_func'
class-attribute
instance-attribute
¶
asyncDependencies = var_operand_def(AsyncTokenType)
class-attribute
instance-attribute
¶
gridSizeX = operand_def(AnyOf.get(IndexType, i32, i64))
class-attribute
instance-attribute
¶
gridSizeY = operand_def(AnyOf.get(IndexType, i32, i64))
class-attribute
instance-attribute
¶
gridSizeZ = operand_def(AnyOf.get(IndexType, i32, i64))
class-attribute
instance-attribute
¶
blockSizeX = operand_def(AnyOf.get(IndexType, i32, i64))
class-attribute
instance-attribute
¶
blockSizeY = operand_def(AnyOf.get(IndexType, i32, i64))
class-attribute
instance-attribute
¶
blockSizeZ = operand_def(AnyOf.get(IndexType, i32, i64))
class-attribute
instance-attribute
¶
clusterSizeX = opt_operand_def(AnyOf.get(IndexType, i32, i64))
class-attribute
instance-attribute
¶
clusterSizeY = opt_operand_def(AnyOf.get(IndexType, i32, i64))
class-attribute
instance-attribute
¶
clusterSizeZ = opt_operand_def(AnyOf.get(IndexType, i32, i64))
class-attribute
instance-attribute
¶
dynamicSharedMemorySize = opt_operand_def(i32)
class-attribute
instance-attribute
¶
kernelOperands = var_operand_def()
class-attribute
instance-attribute
¶
asyncObject = opt_operand_def()
class-attribute
instance-attribute
¶
asyncToken = opt_result_def(AsyncTokenType)
class-attribute
instance-attribute
¶
kernel = prop_def(SymbolRefAttr)
class-attribute
instance-attribute
¶
irdl_options = (AttrSizedOperandSegments(as_property=True),)
class-attribute
instance-attribute
¶
__init__(func: SymbolRefAttr, gridSize: Sequence[SSAValue | Operation], blockSize: Sequence[SSAValue | Operation], clusterSize: Sequence[SSAValue | Operation] | None = None, kernelOperands: Sequence[SSAValue | Operation] | None = None, async_launch: bool = False, asyncDependencies: Sequence[SSAValue | Operation] | None = None, dynamicSharedMemorySize: SSAValue | Operation | None = None)
¶
Source code in xdsl/dialects/gpu.py
NumSubgroupsOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
ReturnOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
SetDefaultDeviceOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
SubgroupIdOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
SubgroupSizeOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
TerminatorOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
ThreadIdOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
WaitOp
¶
Bases: IRDLOperation
Source code in xdsl/dialects/gpu.py
name = 'gpu.wait'
class-attribute
instance-attribute
¶
asyncDependencies = var_operand_def(AsyncTokenType)
class-attribute
instance-attribute
¶
asyncToken = opt_result_def(AsyncTokenType)
class-attribute
instance-attribute
¶
__init__(async_dependencies: Sequence[SSAValue | Operation] | None = None)
¶
YieldOp
¶
Bases: IRDLOperation