Skip to content

Omp

omp

OMP = Dialect('omp', [ParallelOp, TerminatorOp, WsLoopOp, LoopNestOp, YieldOp, TargetOp, MapBoundsOp, MapInfoOp, SimdOp, TeamsOp, DistributeOp, PrivateClauseOp, TargetEnterDataOp, TargetExitDataOp, TargetUpdateOp, TargetDataOp, DeclareReductionOp, TaskwaitOp, TaskyieldOp, SingleOp, TaskOp, TaskgroupOp, TaskloopOp, BarrierOp, FlushOp, MasterOp, MaskedOp, CancelOp, CancellationPointOp], [ClauseRequiresKindAttr, ClauseMapFlagsAttr, DataSharingClauseAttr, DeclareTargetAttr, DeclareTargetCaptureClauseAttr, DeclareTargetDeviceTypeAttr, OrderKindAttr, ProcBindKindAttr, ScheduleKindAttr, ScheduleModifierAttr, DependKindAttr, MapBoundsType, VariableCaptureKindAttr, VersionAttr, ReductionModifierAttr, OrderModifierAttr, GrainsizeTypeAttr, NumTasksTypeAttr, CancellationConstructTypeAttr]) module-attribute

OpenMPOffloadMappingFlags

Bases: IntFlag

Copied from OMPConstants.h

map_type attribute of omp.map.info is a 64 bit integer, with each bit specifying the flags described below. Flags can be combined with | (bitwise or) operator.

Source code in xdsl/dialects/omp.py
class OpenMPOffloadMappingFlags(IntFlag):
    """
    Copied from [OMPConstants.h](https://github.com/llvm/llvm-project/blob/daa2a587cc01c5656deecda7f768fed0afc1e515/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h#L198)


    `map_type` attribute of `omp.map.info` is a 64 bit integer, with each bit specifying the flags described below.
    Flags can be combined with `|` (bitwise or) operator.
    """

    NONE = 0x0
    """ No flags """
    TO = 0x01
    """ Allocate memory on the device and move data from host to device. """
    FROM = 0x02
    """ Allocate memory on the device and move data from device to host. """
    ALWAYS = 0x04
    """ Always perform the requested mapping action on the element, even if it was already mapped before. """
    DELETE = 0x08
    """ Delete the element from the device environment, ignoring the current reference count associated with the element. """
    PTR_AND_OBJ = 0x10
    """ The element being mapped is a pointer-pointee pair; both the pointer and the pointee should be mapped. """
    TARGET_PARAM = 0x20
    """ This flags signals that the base address of an entry should be passed to the target kernel as an argument. """
    RETURN_PARAM = 0x40
    """
    Signal that the runtime library has to return the device pointer in the current position for the data being mapped.
    Used when we have the use_device_ptr or use_device_addr clause.
    """
    PRIVATE = 0x80
    """ This flag signals that the reference being passed is a pointer to private data. """
    LITERAL = 0x100
    """ Pass the element to the device by value. """
    IMPLICIT = 0x200
    """ Implicit map """
    CLOSE = 0x400
    """ Close is a hint to the runtime to allocate memory close to the target device. """

    # 0x800 is reserved for compatibility with XLC.

    PRESENT = 0x1000
    """ Produce a runtime error if the data is not already allocated. """
    OMPX_HOLD = 0x2000
    """
    Increment and decrement a separate reference counter so that the data cannot be unmapped within the associated region.
    Thus, this flag is intended to be used on 'target' and 'target data' directives because they are inherently structured.
    It is not intended to be used on 'target enter data' and 'target exit data' directives because they are inherently dynamic.
    This is an OpenMP extension for the sake of OpenACC support.
    """
    NON_CONTIG = 0x100000000000
    """
    Signal that the runtime library should use args as an array of descriptor_dim pointers and use args_size as dims.
    Used when we have non-contiguous list items in target update directive
    """
    MEMBER_OF = 0xFFFF000000000000
    """ The 16 MSBs of the flags indicate whether the entry is member of some struct/class. """

    def __iter__(self):
        """
        available in the standard library since python 3.11
        """
        return (flag for flag in type(self) if self & flag)

NONE = 0 class-attribute instance-attribute

No flags

TO = 1 class-attribute instance-attribute

Allocate memory on the device and move data from host to device.

FROM = 2 class-attribute instance-attribute

Allocate memory on the device and move data from device to host.

ALWAYS = 4 class-attribute instance-attribute

Always perform the requested mapping action on the element, even if it was already mapped before.

DELETE = 8 class-attribute instance-attribute

Delete the element from the device environment, ignoring the current reference count associated with the element.

PTR_AND_OBJ = 16 class-attribute instance-attribute

The element being mapped is a pointer-pointee pair; both the pointer and the pointee should be mapped.

TARGET_PARAM = 32 class-attribute instance-attribute

This flags signals that the base address of an entry should be passed to the target kernel as an argument.

RETURN_PARAM = 64 class-attribute instance-attribute

Signal that the runtime library has to return the device pointer in the current position for the data being mapped. Used when we have the use_device_ptr or use_device_addr clause.

PRIVATE = 128 class-attribute instance-attribute

This flag signals that the reference being passed is a pointer to private data.

LITERAL = 256 class-attribute instance-attribute

Pass the element to the device by value.

IMPLICIT = 512 class-attribute instance-attribute

Implicit map

CLOSE = 1024 class-attribute instance-attribute

Close is a hint to the runtime to allocate memory close to the target device.

PRESENT = 4096 class-attribute instance-attribute

Produce a runtime error if the data is not already allocated.

OMPX_HOLD = 8192 class-attribute instance-attribute

Increment and decrement a separate reference counter so that the data cannot be unmapped within the associated region. Thus, this flag is intended to be used on 'target' and 'target data' directives because they are inherently structured. It is not intended to be used on 'target enter data' and 'target exit data' directives because they are inherently dynamic. This is an OpenMP extension for the sake of OpenACC support.

NON_CONTIG = 17592186044416 class-attribute instance-attribute

Signal that the runtime library should use args as an array of descriptor_dim pointers and use args_size as dims. Used when we have non-contiguous list items in target update directive

MEMBER_OF = 18446462598732840960 class-attribute instance-attribute

The 16 MSBs of the flags indicate whether the entry is member of some struct/class.

__iter__()

available in the standard library since python 3.11

Source code in xdsl/dialects/omp.py
def __iter__(self):
    """
    available in the standard library since python 3.11
    """
    return (flag for flag in type(self) if self & flag)

ClauseMapFlags

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class ClauseMapFlags(StrEnum):
    STORAGE = auto()
    TO = auto()
    FROM = auto()
    ALWAYS = auto()
    DELETE = "del"
    RETURN_PARAM = auto()
    PRIVATE = "priv"
    LITERAL = auto()
    IMPLICIT = auto()
    CLOSE = auto()
    PRESENT = auto()
    OMPX_HOLD = auto()
    ATTACH = auto()
    ATTACH_ALWAYS = auto()
    ATTACH_NONE = auto()
    ATTACH_AUTO = auto()
    REF_PTR = auto()
    REF_PTEE = auto()
    REF_PTR_PTEE = auto()
    IS_DEVICE_PTR = auto()

STORAGE = auto() class-attribute instance-attribute

TO = auto() class-attribute instance-attribute

FROM = auto() class-attribute instance-attribute

ALWAYS = auto() class-attribute instance-attribute

DELETE = 'del' class-attribute instance-attribute

RETURN_PARAM = auto() class-attribute instance-attribute

PRIVATE = 'priv' class-attribute instance-attribute

LITERAL = auto() class-attribute instance-attribute

IMPLICIT = auto() class-attribute instance-attribute

CLOSE = auto() class-attribute instance-attribute

PRESENT = auto() class-attribute instance-attribute

OMPX_HOLD = auto() class-attribute instance-attribute

ATTACH = auto() class-attribute instance-attribute

ATTACH_ALWAYS = auto() class-attribute instance-attribute

ATTACH_NONE = auto() class-attribute instance-attribute

ATTACH_AUTO = auto() class-attribute instance-attribute

REF_PTR = auto() class-attribute instance-attribute

REF_PTEE = auto() class-attribute instance-attribute

REF_PTR_PTEE = auto() class-attribute instance-attribute

IS_DEVICE_PTR = auto() class-attribute instance-attribute

ClauseMapFlagsAttr dataclass

Bases: BitEnumAttribute[ClauseMapFlags], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class ClauseMapFlagsAttr(BitEnumAttribute[ClauseMapFlags], SpacedOpaqueSyntaxAttribute):
    name = "omp.clause_map_flags"

    none_value = "none"
    separator_value = "|"
    delimiter_value = AttrParser.Delimiter.NONE

name = 'omp.clause_map_flags' class-attribute instance-attribute

none_value = 'none' class-attribute instance-attribute

separator_value = '|' class-attribute instance-attribute

delimiter_value = AttrParser.Delimiter.NONE class-attribute instance-attribute

ScheduleKind

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class ScheduleKind(StrEnum):
    STATIC = auto()
    DYNAMIC = auto()
    AUTO = auto()

STATIC = auto() class-attribute instance-attribute

DYNAMIC = auto() class-attribute instance-attribute

AUTO = auto() class-attribute instance-attribute

ScheduleModifier

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class ScheduleModifier(StrEnum):
    NONE = auto()
    MONOTONIC = auto()
    NONMONOTONIC = auto()
    SIMD = auto()

NONE = auto() class-attribute instance-attribute

MONOTONIC = auto() class-attribute instance-attribute

NONMONOTONIC = auto() class-attribute instance-attribute

SIMD = auto() class-attribute instance-attribute

OrderKind

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class OrderKind(StrEnum):
    CONCURRENT = auto()

CONCURRENT = auto() class-attribute instance-attribute

OrderModifier

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class OrderModifier(StrEnum):
    REPRODUCIBLE = auto()
    UNCONSTRAINED = auto()

REPRODUCIBLE = auto() class-attribute instance-attribute

UNCONSTRAINED = auto() class-attribute instance-attribute

DependKind

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class DependKind(StrEnum):
    TASKDEPENDIN = auto()
    TASKDEPENDOUT = auto()
    TASKDEPENDINOUT = auto()
    TASKDEPENDMUTEXINOUTSET = auto()
    TASKDEPENDINOUTSET = auto()

TASKDEPENDIN = auto() class-attribute instance-attribute

TASKDEPENDOUT = auto() class-attribute instance-attribute

TASKDEPENDINOUT = auto() class-attribute instance-attribute

TASKDEPENDMUTEXINOUTSET = auto() class-attribute instance-attribute

TASKDEPENDINOUTSET = auto() class-attribute instance-attribute

VariableCaptureKind

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class VariableCaptureKind(StrEnum):
    THIS = "This"
    BY_REF = "ByRef"
    BY_COPY = "ByCopy"
    VLA_TYPE = "VLAType"

THIS = 'This' class-attribute instance-attribute

BY_REF = 'ByRef' class-attribute instance-attribute

BY_COPY = 'ByCopy' class-attribute instance-attribute

VLA_TYPE = 'VLAType' class-attribute instance-attribute

DataSharingClauseKind

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class DataSharingClauseKind(StrEnum):
    PRIVATE = auto()
    FIRSTPRIVATE = auto()

PRIVATE = auto() class-attribute instance-attribute

FIRSTPRIVATE = auto() class-attribute instance-attribute

ClauseRequiresKind

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class ClauseRequiresKind(StrEnum):
    NONE = auto()
    REVERSE_OFFLOAD = auto()
    UNIFIED_ADDRESS = auto()
    UNIFIED_SHARED_MEMORY = auto()
    DYNAMIC_ALLOCATORS = auto()

NONE = auto() class-attribute instance-attribute

REVERSE_OFFLOAD = auto() class-attribute instance-attribute

UNIFIED_ADDRESS = auto() class-attribute instance-attribute

UNIFIED_SHARED_MEMORY = auto() class-attribute instance-attribute

DYNAMIC_ALLOCATORS = auto() class-attribute instance-attribute

DeclareTargetDeviceTypeKind

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class DeclareTargetDeviceTypeKind(StrEnum):
    ANY = auto()
    HOST = auto()
    NOHOST = auto()

ANY = auto() class-attribute instance-attribute

HOST = auto() class-attribute instance-attribute

NOHOST = auto() class-attribute instance-attribute

DeclareTargetCaptureClauseKind

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class DeclareTargetCaptureClauseKind(StrEnum):
    TO = auto()
    LINK = auto()
    ENTER = auto()

TO = auto() class-attribute instance-attribute

ENTER = auto() class-attribute instance-attribute

ReductionModifier

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class ReductionModifier(StrEnum):
    DEFAULTMOD = auto()
    INSCAN = auto()
    TASK = auto()

DEFAULTMOD = auto() class-attribute instance-attribute

INSCAN = auto() class-attribute instance-attribute

TASK = auto() class-attribute instance-attribute

GrainsizeType

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class GrainsizeType(StrEnum):
    STRICT = auto()

STRICT = auto() class-attribute instance-attribute

NumTasksType

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class NumTasksType(StrEnum):
    STRICT = auto()

STRICT = auto() class-attribute instance-attribute

CancellationConstructType

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class CancellationConstructType(StrEnum):
    PARALLEL = auto()
    LOOP = auto()
    SECTIONS = auto()
    TASKGROUP = auto()

PARALLEL = auto() class-attribute instance-attribute

LOOP = auto() class-attribute instance-attribute

SECTIONS = auto() class-attribute instance-attribute

TASKGROUP = auto() class-attribute instance-attribute

LoopWrapper dataclass

Bases: NoTerminator

Check that the omp operation is a loop wrapper as defined upstream.

See external documentation

Source code in xdsl/dialects/omp.py
class LoopWrapper(NoTerminator):
    """
    Check that the omp operation is a loop wrapper as defined upstream.

    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/#loop-associated-directives)
    """

    def verify(self, op: Operation) -> None:
        if (num_regions := len(op.regions)) != 1:
            raise VerifyException(
                f"{op.name} is not a LoopWrapper: has {num_regions} region, expected 1"
            )
        if (num_blocks := len(op.regions[0].blocks)) != 1:
            raise VerifyException(
                f"{op.name} is not a LoopWrapper: has {num_blocks} blocks, expected 1"
            )
        if (num_ops := len(op.regions[0].block.ops)) != 1:
            raise VerifyException(
                f"{op.name} is not a LoopWrapper: has {num_ops} ops, expected 1"
            )
        inner = op.regions[0].block.first_op
        assert inner is not None
        if not (inner.has_trait(LoopWrapper()) or isinstance(inner, LoopNestOp)):
            raise VerifyException(
                f"{op.name} is not a LoopWrapper: "
                f"should have a single operation which is either another LoopWrapper or {LoopNestOp.name}"
            )
        return super().verify(op)

verify(op: Operation) -> None

Source code in xdsl/dialects/omp.py
def verify(self, op: Operation) -> None:
    if (num_regions := len(op.regions)) != 1:
        raise VerifyException(
            f"{op.name} is not a LoopWrapper: has {num_regions} region, expected 1"
        )
    if (num_blocks := len(op.regions[0].blocks)) != 1:
        raise VerifyException(
            f"{op.name} is not a LoopWrapper: has {num_blocks} blocks, expected 1"
        )
    if (num_ops := len(op.regions[0].block.ops)) != 1:
        raise VerifyException(
            f"{op.name} is not a LoopWrapper: has {num_ops} ops, expected 1"
        )
    inner = op.regions[0].block.first_op
    assert inner is not None
    if not (inner.has_trait(LoopWrapper()) or isinstance(inner, LoopNestOp)):
        raise VerifyException(
            f"{op.name} is not a LoopWrapper: "
            f"should have a single operation which is either another LoopWrapper or {LoopNestOp.name}"
        )
    return super().verify(op)

BlockArgOpenMPOperation dataclass

Bases: IRDLOperation, ABC

Verifies that the operation has the appropriate number of block arguments corresponding to the following operands: host_eval_vars, in_reduction_vars, map_vars, private_vars, reduction_vars, task_reduction_vars, use_device_addr_vars and use_device_ptr_vars.

Source code in xdsl/dialects/omp.py
class BlockArgOpenMPOperation(IRDLOperation, ABC):
    """
    Verifies that the operation has the appropriate number of block arguments corresponding to the following operands:
    `host_eval_vars`, `in_reduction_vars`, `map_vars`, `private_vars`, `reduction_vars`,
    `task_reduction_vars`, `use_device_addr_vars` and `use_device_ptr_vars`.
    """

    def verify_(self) -> None:
        if len(self.regions) < 1:
            raise VerifyException(f"Expected {self.name} to have at least 1 region")
        if len(self.regions[0].blocks) < 1:
            raise VerifyException(
                f"Expected {self.name} to have at least 1 block in its first region"
            )
        expected = self.num_block_args()

        if (actual := len(self.regions[0].blocks[0].args)) < expected:
            raise VerifyException(
                f"{self.name} expected to have at least {expected} block argument(s), got {actual}"
            )

    @abstractmethod
    def num_block_args(self) -> int: ...

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    if len(self.regions) < 1:
        raise VerifyException(f"Expected {self.name} to have at least 1 region")
    if len(self.regions[0].blocks) < 1:
        raise VerifyException(
            f"Expected {self.name} to have at least 1 block in its first region"
        )
    expected = self.num_block_args()

    if (actual := len(self.regions[0].blocks[0].args)) < expected:
        raise VerifyException(
            f"{self.name} expected to have at least {expected} block argument(s), got {actual}"
        )

num_block_args() -> int abstractmethod

Source code in xdsl/dialects/omp.py
@abstractmethod
def num_block_args(self) -> int: ...

ScheduleKindAttr dataclass

Bases: EnumAttribute[ScheduleKind], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class ScheduleKindAttr(EnumAttribute[ScheduleKind], SpacedOpaqueSyntaxAttribute):
    name = "omp.schedulekind"

name = 'omp.schedulekind' class-attribute instance-attribute

ScheduleModifierAttr dataclass

Bases: EnumAttribute[ScheduleModifier], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class ScheduleModifierAttr(
    EnumAttribute[ScheduleModifier], SpacedOpaqueSyntaxAttribute
):
    name = "omp.sched_mod"

name = 'omp.sched_mod' class-attribute instance-attribute

DependKindAttr dataclass

Bases: EnumAttribute[DependKind], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class DependKindAttr(EnumAttribute[DependKind], SpacedOpaqueSyntaxAttribute):
    name = "omp.clause_task_depend"

    def print_parameter(self, printer: Printer) -> None:
        with printer.in_parens():
            printer.print_string(self.data)

    @classmethod
    def parse_parameter(cls, parser: AttrParser) -> DependKind:
        with parser.in_parens():
            return parser.parse_str_enum(DependKind)

name = 'omp.clause_task_depend' class-attribute instance-attribute

print_parameter(printer: Printer) -> None

Source code in xdsl/dialects/omp.py
def print_parameter(self, printer: Printer) -> None:
    with printer.in_parens():
        printer.print_string(self.data)

parse_parameter(parser: AttrParser) -> DependKind classmethod

Source code in xdsl/dialects/omp.py
@classmethod
def parse_parameter(cls, parser: AttrParser) -> DependKind:
    with parser.in_parens():
        return parser.parse_str_enum(DependKind)

OrderKindAttr dataclass

Bases: EnumAttribute[OrderKind], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class OrderKindAttr(EnumAttribute[OrderKind], SpacedOpaqueSyntaxAttribute):
    name = "omp.orderkind"

name = 'omp.orderkind' class-attribute instance-attribute

ReductionModifierAttr dataclass

Bases: EnumAttribute[ReductionModifier], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class ReductionModifierAttr(
    EnumAttribute[ReductionModifier], SpacedOpaqueSyntaxAttribute
):
    name = "omp.reduction_modifier"

    def print_parameter(self, printer: Printer) -> None:
        with printer.in_parens():
            printer.print_string(self.data)

    @classmethod
    def parse_parameter(cls, parser: AttrParser) -> ReductionModifier:
        with parser.in_parens():
            return parser.parse_str_enum(ReductionModifier)

name = 'omp.reduction_modifier' class-attribute instance-attribute

print_parameter(printer: Printer) -> None

Source code in xdsl/dialects/omp.py
def print_parameter(self, printer: Printer) -> None:
    with printer.in_parens():
        printer.print_string(self.data)

parse_parameter(parser: AttrParser) -> ReductionModifier classmethod

Source code in xdsl/dialects/omp.py
@classmethod
def parse_parameter(cls, parser: AttrParser) -> ReductionModifier:
    with parser.in_parens():
        return parser.parse_str_enum(ReductionModifier)

OrderModifierAttr dataclass

Bases: EnumAttribute[OrderModifier], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class OrderModifierAttr(EnumAttribute[OrderModifier], SpacedOpaqueSyntaxAttribute):
    name = "omp.order_mod"

name = 'omp.order_mod' class-attribute instance-attribute

GrainsizeTypeAttr dataclass

Bases: EnumAttribute[GrainsizeType], SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.grainsizetype See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class GrainsizeTypeAttr(EnumAttribute[GrainsizeType], SpacedOpaqueSyntaxAttribute):
    """
    Implementation of upstream omp.grainsizetype
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#grainsizetypeattr).
    """

    name = "omp.grainsizetype"

name = 'omp.grainsizetype' class-attribute instance-attribute

NumTasksTypeAttr dataclass

Bases: EnumAttribute[NumTasksType], SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.numtaskstype See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class NumTasksTypeAttr(EnumAttribute[NumTasksType], SpacedOpaqueSyntaxAttribute):
    """
    Implementation of upstream omp.numtaskstype
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#numtaskstypeattr).
    """

    name = "omp.numtaskstype"

name = 'omp.numtaskstype' class-attribute instance-attribute

CancellationConstructTypeAttr dataclass

Bases: EnumAttribute[CancellationConstructType], SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.cancellationconstructtype See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class CancellationConstructTypeAttr(
    EnumAttribute[CancellationConstructType], SpacedOpaqueSyntaxAttribute
):
    """
    Implementation of upstream omp.cancellationconstructtype
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#cancellationconstructtypeattr).
    """

    name = "omp.cancellationconstructtype"

name = 'omp.cancellationconstructtype' class-attribute instance-attribute

VariableCaptureKindAttr dataclass

Bases: EnumAttribute[VariableCaptureKind], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class VariableCaptureKindAttr(
    EnumAttribute[VariableCaptureKind], SpacedOpaqueSyntaxAttribute
):
    name = "omp.variable_capture_kind"

    def print_parameter(self, printer: Printer) -> None:
        with printer.in_parens():
            printer.print_string(self.data)

    @classmethod
    def parse_parameter(cls, parser: AttrParser) -> VariableCaptureKind:
        with parser.in_parens():
            return parser.parse_str_enum(VariableCaptureKind)

name = 'omp.variable_capture_kind' class-attribute instance-attribute

print_parameter(printer: Printer) -> None

Source code in xdsl/dialects/omp.py
def print_parameter(self, printer: Printer) -> None:
    with printer.in_parens():
        printer.print_string(self.data)

parse_parameter(parser: AttrParser) -> VariableCaptureKind classmethod

Source code in xdsl/dialects/omp.py
@classmethod
def parse_parameter(cls, parser: AttrParser) -> VariableCaptureKind:
    with parser.in_parens():
        return parser.parse_str_enum(VariableCaptureKind)

DeclareTargetDeviceTypeAttr dataclass

Bases: EnumAttribute[DeclareTargetDeviceTypeKind], SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.device_type See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class DeclareTargetDeviceTypeAttr(
    EnumAttribute[DeclareTargetDeviceTypeKind], SpacedOpaqueSyntaxAttribute
):
    """
    Implementation of upstream omp.device_type
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#declaretargetdevicetypeattr).
    """

    name = "omp.device_type"

    @classmethod
    def parse_parameter(cls, parser: AttrParser) -> DeclareTargetDeviceTypeKind:
        with parser.in_parens():
            return parser.parse_str_enum(DeclareTargetDeviceTypeKind)

    def print_parameter(self, printer: Printer) -> None:
        with printer.in_parens():
            printer.print_string(self.data)

name = 'omp.device_type' class-attribute instance-attribute

parse_parameter(parser: AttrParser) -> DeclareTargetDeviceTypeKind classmethod

Source code in xdsl/dialects/omp.py
@classmethod
def parse_parameter(cls, parser: AttrParser) -> DeclareTargetDeviceTypeKind:
    with parser.in_parens():
        return parser.parse_str_enum(DeclareTargetDeviceTypeKind)

print_parameter(printer: Printer) -> None

Source code in xdsl/dialects/omp.py
def print_parameter(self, printer: Printer) -> None:
    with printer.in_parens():
        printer.print_string(self.data)

DeclareTargetCaptureClauseAttr dataclass

Bases: EnumAttribute[DeclareTargetCaptureClauseKind], SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.capture_clause See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class DeclareTargetCaptureClauseAttr(
    EnumAttribute[DeclareTargetCaptureClauseKind], SpacedOpaqueSyntaxAttribute
):
    """
    Implementation of upstream omp.capture_clause
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#declaretargetcaptureclauseattr).
    """

    name = "omp.capture_clause"

    @classmethod
    def parse_parameter(cls, parser: AttrParser) -> DeclareTargetCaptureClauseKind:
        with parser.in_parens():
            return parser.parse_str_enum(DeclareTargetCaptureClauseKind)

    def print_parameter(self, printer: Printer) -> None:
        with printer.in_parens():
            printer.print_string(self.data)

name = 'omp.capture_clause' class-attribute instance-attribute

parse_parameter(parser: AttrParser) -> DeclareTargetCaptureClauseKind classmethod

Source code in xdsl/dialects/omp.py
@classmethod
def parse_parameter(cls, parser: AttrParser) -> DeclareTargetCaptureClauseKind:
    with parser.in_parens():
        return parser.parse_str_enum(DeclareTargetCaptureClauseKind)

print_parameter(printer: Printer) -> None

Source code in xdsl/dialects/omp.py
def print_parameter(self, printer: Printer) -> None:
    with printer.in_parens():
        printer.print_string(self.data)

DeclareTargetAttr dataclass

Bases: ParametrizedAttribute, SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.declaretarget See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class DeclareTargetAttr(ParametrizedAttribute, SpacedOpaqueSyntaxAttribute):
    """
    Implementation of upstream omp.declaretarget
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#declaretargetattr).
    """

    name = "omp.declaretarget"

    device_type: DeclareTargetDeviceTypeAttr | NoneAttr
    capture_clause: DeclareTargetCaptureClauseAttr | NoneAttr
    automap: BoolAttr | NoneAttr

    @classmethod
    def parse_parameters(cls, parser: AttrParser) -> list[Attribute]:
        fields = ("device_type", "capture_clause", "automap")

        def parse_field() -> tuple[str, Attribute]:
            key = parser.parse_keyword_in(fields)
            parser.parse_punctuation("=")
            match key:
                case "device_type":
                    return key, DeclareTargetDeviceTypeAttr(
                        DeclareTargetDeviceTypeAttr.parse_parameter(parser)
                    )
                case "capture_clause":
                    return key, DeclareTargetCaptureClauseAttr(
                        DeclareTargetCaptureClauseAttr.parse_parameter(parser)
                    )
                case _:
                    return key, IntegerAttr.from_bool(parser.parse_boolean())

        seen: dict[str, Attribute] = {}
        for key, value in parser.parse_comma_separated_list(
            AttrParser.Delimiter.ANGLE, parse_field
        ):
            if key in seen:
                parser.raise_error(f"duplicate struct parameter name: {key}")
            seen[key] = value
        return [seen.get(name, NoneAttr()) for name in fields]

    def print_parameters(self, printer: Printer):
        with printer.in_angle_brackets():
            separator = ""
            if not isinstance(self.device_type, NoneAttr):
                printer.print_string("device_type = ")
                self.device_type.print_parameter(printer)
                separator = ", "
            if not isinstance(self.capture_clause, NoneAttr):
                printer.print_string(f"{separator}capture_clause = ")
                self.capture_clause.print_parameter(printer)
                separator = ", "
            if not isinstance(self.automap, NoneAttr):
                printer.print_string(f"{separator}automap = ")
                printer.print_string("true" if self.automap.value.data else "false")

name = 'omp.declaretarget' class-attribute instance-attribute

device_type: DeclareTargetDeviceTypeAttr | NoneAttr instance-attribute

capture_clause: DeclareTargetCaptureClauseAttr | NoneAttr instance-attribute

automap: BoolAttr | NoneAttr instance-attribute

parse_parameters(parser: AttrParser) -> list[Attribute] classmethod

Source code in xdsl/dialects/omp.py
@classmethod
def parse_parameters(cls, parser: AttrParser) -> list[Attribute]:
    fields = ("device_type", "capture_clause", "automap")

    def parse_field() -> tuple[str, Attribute]:
        key = parser.parse_keyword_in(fields)
        parser.parse_punctuation("=")
        match key:
            case "device_type":
                return key, DeclareTargetDeviceTypeAttr(
                    DeclareTargetDeviceTypeAttr.parse_parameter(parser)
                )
            case "capture_clause":
                return key, DeclareTargetCaptureClauseAttr(
                    DeclareTargetCaptureClauseAttr.parse_parameter(parser)
                )
            case _:
                return key, IntegerAttr.from_bool(parser.parse_boolean())

    seen: dict[str, Attribute] = {}
    for key, value in parser.parse_comma_separated_list(
        AttrParser.Delimiter.ANGLE, parse_field
    ):
        if key in seen:
            parser.raise_error(f"duplicate struct parameter name: {key}")
        seen[key] = value
    return [seen.get(name, NoneAttr()) for name in fields]

print_parameters(printer: Printer)

Source code in xdsl/dialects/omp.py
def print_parameters(self, printer: Printer):
    with printer.in_angle_brackets():
        separator = ""
        if not isinstance(self.device_type, NoneAttr):
            printer.print_string("device_type = ")
            self.device_type.print_parameter(printer)
            separator = ", "
        if not isinstance(self.capture_clause, NoneAttr):
            printer.print_string(f"{separator}capture_clause = ")
            self.capture_clause.print_parameter(printer)
            separator = ", "
        if not isinstance(self.automap, NoneAttr):
            printer.print_string(f"{separator}automap = ")
            printer.print_string("true" if self.automap.value.data else "false")

ClauseRequiresKindAttr dataclass

Bases: EnumAttribute[ClauseRequiresKind], SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.clause_requires See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class ClauseRequiresKindAttr(
    EnumAttribute[ClauseRequiresKind], SpacedOpaqueSyntaxAttribute
):
    """
    Implementation of upstream omp.clause_requires
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#clauserequiresattr).
    """

    name = "omp.clause_requires"

name = 'omp.clause_requires' class-attribute instance-attribute

DataSharingClauseAttr dataclass

Bases: EnumAttribute[DataSharingClauseKind], SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.data_sharing_type See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class DataSharingClauseAttr(
    EnumAttribute[DataSharingClauseKind], SpacedOpaqueSyntaxAttribute
):
    """
    Implementation of upstream omp.data_sharing_type
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#datasharingclausetypeattr).
    """

    name = "omp.data_sharing_type"

    @classmethod
    def parse_parameter(cls, parser: AttrParser) -> DataSharingClauseKind:
        with parser.in_braces():
            parser.parse_keyword("type")
            parser.parse_punctuation("=")
            return parser.parse_str_enum(DataSharingClauseKind)

    def print_parameter(self, printer: Printer) -> None:
        with printer.in_braces():
            printer.print_string("type = ")
            printer.print_string(self.data)

name = 'omp.data_sharing_type' class-attribute instance-attribute

parse_parameter(parser: AttrParser) -> DataSharingClauseKind classmethod

Source code in xdsl/dialects/omp.py
@classmethod
def parse_parameter(cls, parser: AttrParser) -> DataSharingClauseKind:
    with parser.in_braces():
        parser.parse_keyword("type")
        parser.parse_punctuation("=")
        return parser.parse_str_enum(DataSharingClauseKind)

print_parameter(printer: Printer) -> None

Source code in xdsl/dialects/omp.py
def print_parameter(self, printer: Printer) -> None:
    with printer.in_braces():
        printer.print_string("type = ")
        printer.print_string(self.data)

VersionAttr dataclass

Bases: ParametrizedAttribute, SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.version See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class VersionAttr(ParametrizedAttribute, SpacedOpaqueSyntaxAttribute):
    """
    Implementation of upstream omp.version
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#versionattr).
    """

    name = "omp.version"

    version: IntAttr

    @classmethod
    def parse_parameters(cls, parser: AttrParser) -> list[Attribute]:
        with parser.in_angle_brackets():
            parser.parse_keyword("version")
            parser.parse_punctuation("=")
            version = parser.parse_integer(allow_boolean=False)
            return [IntAttr(version)]

    def print_parameters(self, printer: Printer):
        with printer.in_angle_brackets():
            printer.print_string("version = ")
            printer.print_int(self.version.data)

name = 'omp.version' class-attribute instance-attribute

version: IntAttr instance-attribute

parse_parameters(parser: AttrParser) -> list[Attribute] classmethod

Source code in xdsl/dialects/omp.py
@classmethod
def parse_parameters(cls, parser: AttrParser) -> list[Attribute]:
    with parser.in_angle_brackets():
        parser.parse_keyword("version")
        parser.parse_punctuation("=")
        version = parser.parse_integer(allow_boolean=False)
        return [IntAttr(version)]

print_parameters(printer: Printer)

Source code in xdsl/dialects/omp.py
def print_parameters(self, printer: Printer):
    with printer.in_angle_brackets():
        printer.print_string("version = ")
        printer.print_int(self.version.data)

MapBoundsType dataclass

Bases: ParametrizedAttribute, TypeAttribute

Source code in xdsl/dialects/omp.py
@irdl_attr_definition
class MapBoundsType(ParametrizedAttribute, TypeAttribute):
    name = "omp.map_bounds_ty"

name = 'omp.map_bounds_ty' class-attribute instance-attribute

LoopNestOp dataclass

Bases: IRDLOperation

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class LoopNestOp(IRDLOperation):
    name = "omp.loop_nest"

    lowerBound = var_operand_def(IntegerType | IndexType)
    upperBound = var_operand_def(IntegerType | IndexType)
    step = var_operand_def(IntegerType | IndexType)

    collapse_num_loops = opt_prop_def(IntegerAttr)
    loop_inclusive = opt_prop_def(UnitAttr)

    body = region_def("single_block")

    irdl_options = (SameVariadicOperandSize(),)

    traits = traits_def(RecursiveMemoryEffect())

name = 'omp.loop_nest' class-attribute instance-attribute

lowerBound = var_operand_def(IntegerType | IndexType) class-attribute instance-attribute

upperBound = var_operand_def(IntegerType | IndexType) class-attribute instance-attribute

step = var_operand_def(IntegerType | IndexType) class-attribute instance-attribute

collapse_num_loops = opt_prop_def(IntegerAttr) class-attribute instance-attribute

loop_inclusive = opt_prop_def(UnitAttr) class-attribute instance-attribute

body = region_def('single_block') class-attribute instance-attribute

irdl_options = (SameVariadicOperandSize(),) class-attribute instance-attribute

traits = traits_def(RecursiveMemoryEffect()) class-attribute instance-attribute

WsLoopOp dataclass

Bases: BlockArgOpenMPOperation

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class WsLoopOp(BlockArgOpenMPOperation):
    name = "omp.wsloop"

    LINEAR_COUNT: ClassVar = IntVarConstraint("LINEAR_COUNT", AnyInt())
    REDUCTION_COUNT: ClassVar = IntVarConstraint("REDUCTION_COUNT", AnyInt())

    allocate_vars = var_operand_def()
    allocator_vars = var_operand_def()
    linear_vars = var_operand_def(AnyRange().of_length(LINEAR_COUNT))
    linear_step_vars = var_operand_def(RangeOf.get(i32).of_length(LINEAR_COUNT))
    private_vars = var_operand_def()
    # TODO: this is constrained to OpenMP_PointerLikeTypeInterface upstream
    # Relatively shallow interface with just `getElementType`
    reduction_vars = var_operand_def(AnyRange().of_length(REDUCTION_COUNT))
    schedule_chunk = opt_operand_def()

    reduction_syms = opt_prop_def(
        ArrayAttr.constr(RangeOf.get(SymbolRefAttr).of_length(REDUCTION_COUNT))
    )
    reduction_mod = opt_prop_def(ReductionModifierAttr)
    reduction_byref = opt_prop_def(DenseArrayBase[i1])
    schedule_kind = opt_prop_def(ScheduleKindAttr)
    schedule_mod = opt_prop_def(ScheduleModifierAttr)
    schedule_simd = opt_prop_def(UnitAttr)
    nowait = opt_prop_def(UnitAttr)
    ordered = opt_prop_def(IntegerAttr.constr(value=AtLeast(0), type=IntegerType))
    order = opt_prop_def(OrderKindAttr)
    order_mod = opt_prop_def(OrderModifierAttr)
    private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    private_needs_barrier = opt_prop_def(UnitAttr)
    linear_var_types = opt_prop_def(ArrayAttr)

    body = region_def("single_block")

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    traits = traits_def(LoopWrapper(), RecursiveMemoryEffect())

    def num_block_args(self) -> int:
        return len(self.private_vars) + len(self.reduction_vars)

name = 'omp.wsloop' class-attribute instance-attribute

LINEAR_COUNT: ClassVar = IntVarConstraint('LINEAR_COUNT', AnyInt()) class-attribute instance-attribute

REDUCTION_COUNT: ClassVar = IntVarConstraint('REDUCTION_COUNT', AnyInt()) class-attribute instance-attribute

allocate_vars = var_operand_def() class-attribute instance-attribute

allocator_vars = var_operand_def() class-attribute instance-attribute

linear_vars = var_operand_def(AnyRange().of_length(LINEAR_COUNT)) class-attribute instance-attribute

linear_step_vars = var_operand_def(RangeOf.get(i32).of_length(LINEAR_COUNT)) class-attribute instance-attribute

private_vars = var_operand_def() class-attribute instance-attribute

reduction_vars = var_operand_def(AnyRange().of_length(REDUCTION_COUNT)) class-attribute instance-attribute

schedule_chunk = opt_operand_def() class-attribute instance-attribute

reduction_syms = opt_prop_def(ArrayAttr.constr(RangeOf.get(SymbolRefAttr).of_length(REDUCTION_COUNT))) class-attribute instance-attribute

reduction_mod = opt_prop_def(ReductionModifierAttr) class-attribute instance-attribute

reduction_byref = opt_prop_def(DenseArrayBase[i1]) class-attribute instance-attribute

schedule_kind = opt_prop_def(ScheduleKindAttr) class-attribute instance-attribute

schedule_mod = opt_prop_def(ScheduleModifierAttr) class-attribute instance-attribute

schedule_simd = opt_prop_def(UnitAttr) class-attribute instance-attribute

nowait = opt_prop_def(UnitAttr) class-attribute instance-attribute

ordered = opt_prop_def(IntegerAttr.constr(value=AtLeast(0), type=IntegerType)) class-attribute instance-attribute

order = opt_prop_def(OrderKindAttr) class-attribute instance-attribute

order_mod = opt_prop_def(OrderModifierAttr) class-attribute instance-attribute

private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

private_needs_barrier = opt_prop_def(UnitAttr) class-attribute instance-attribute

linear_var_types = opt_prop_def(ArrayAttr) class-attribute instance-attribute

body = region_def('single_block') class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

traits = traits_def(LoopWrapper(), RecursiveMemoryEffect()) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return len(self.private_vars) + len(self.reduction_vars)

ProcBindKindEnum

Bases: StrEnum

Source code in xdsl/dialects/omp.py
class ProcBindKindEnum(StrEnum):
    PRIMARY = auto()
    MASTER = auto()
    CLOSE = auto()
    SPREAD = auto()

PRIMARY = auto() class-attribute instance-attribute

MASTER = auto() class-attribute instance-attribute

CLOSE = auto() class-attribute instance-attribute

SPREAD = auto() class-attribute instance-attribute

ProcBindKindAttr dataclass

Bases: EnumAttribute[ProcBindKindEnum], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
class ProcBindKindAttr(EnumAttribute[ProcBindKindEnum], SpacedOpaqueSyntaxAttribute):
    name = "omp.procbindkind"

name = 'omp.procbindkind' class-attribute instance-attribute

ParallelOp dataclass

Bases: BlockArgOpenMPOperation

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class ParallelOp(BlockArgOpenMPOperation):
    name = "omp.parallel"

    allocate_vars = var_operand_def()
    allocators_vars = var_operand_def()
    if_expr = opt_operand_def(i1)
    num_threads = opt_operand_def(IntegerType | IndexType)
    # TODO: this is constrained to OpenMP_PointerLikeTypeInterface upstream
    # Relatively shallow interface with just `getElementType`
    private_vars = var_operand_def()
    reduction_vars = var_operand_def()

    region = region_def()

    reductions = opt_prop_def(ArrayAttr[SymbolRefAttr])
    proc_bind_kind = opt_prop_def(ProcBindKindAttr)
    privatizers = opt_prop_def(ArrayAttr[SymbolRefAttr])
    private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    reduction_mod = opt_prop_def(ReductionModifierAttr)
    reduction_byref = opt_prop_def(DenseArrayBase[i1])
    reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    traits = traits_def(RecursiveMemoryEffect())

    def num_block_args(self) -> int:
        return len(self.private_vars) + len(self.reduction_vars)

name = 'omp.parallel' class-attribute instance-attribute

allocate_vars = var_operand_def() class-attribute instance-attribute

allocators_vars = var_operand_def() class-attribute instance-attribute

if_expr = opt_operand_def(i1) class-attribute instance-attribute

num_threads = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

private_vars = var_operand_def() class-attribute instance-attribute

reduction_vars = var_operand_def() class-attribute instance-attribute

region = region_def() class-attribute instance-attribute

reductions = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

proc_bind_kind = opt_prop_def(ProcBindKindAttr) class-attribute instance-attribute

privatizers = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

reduction_mod = opt_prop_def(ReductionModifierAttr) class-attribute instance-attribute

reduction_byref = opt_prop_def(DenseArrayBase[i1]) class-attribute instance-attribute

reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

traits = traits_def(RecursiveMemoryEffect()) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return len(self.private_vars) + len(self.reduction_vars)

DeclareReductionOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.declare_reduction See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class DeclareReductionOp(IRDLOperation):
    """
    Implementation of upstream omp.declare_reduction
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompdeclare_reduction-ompdeclarereductionop).
    """

    name = "omp.declare_reduction"

    sym_name = prop_def(SymbolNameConstraint())
    var_type = prop_def(TypeAttribute, prop_name="type")

    alloc_region = region_def()
    init_region = region_def()
    reduction_region = region_def()
    atomic_reduction_region = region_def()
    cleanup_region = region_def()
    data_ptr_ptr_region = region_def()

    traits = traits_def(IsolatedFromAbove(), SymbolOpInterface())

    assembly_format = """
        $sym_name `:` $type attr-dict-with-keyword
        ( `alloc` $alloc_region^ )?
        `init` $init_region
        `combiner` $reduction_region
        ( `atomic` $atomic_reduction_region^ )?
        ( `cleanup` $cleanup_region^ )?
        ( `data_ptr_ptr` $data_ptr_ptr_region^ )?
    """

    def verify_(self) -> None:
        if len(self.alloc_region.blocks) > 1:
            raise VerifyException(
                f"{self.name} should have at most 1 block in alloc_region"
            )

name = 'omp.declare_reduction' class-attribute instance-attribute

sym_name = prop_def(SymbolNameConstraint()) class-attribute instance-attribute

var_type = prop_def(TypeAttribute, prop_name='type') class-attribute instance-attribute

alloc_region = region_def() class-attribute instance-attribute

init_region = region_def() class-attribute instance-attribute

reduction_region = region_def() class-attribute instance-attribute

atomic_reduction_region = region_def() class-attribute instance-attribute

cleanup_region = region_def() class-attribute instance-attribute

data_ptr_ptr_region = region_def() class-attribute instance-attribute

traits = traits_def(IsolatedFromAbove(), SymbolOpInterface()) class-attribute instance-attribute

assembly_format = '\n $sym_name `:` $type attr-dict-with-keyword\n ( `alloc` $alloc_region^ )?\n `init` $init_region\n `combiner` $reduction_region\n ( `atomic` $atomic_reduction_region^ )?\n ( `cleanup` $cleanup_region^ )?\n ( `data_ptr_ptr` $data_ptr_ptr_region^ )?\n ' class-attribute instance-attribute

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    if len(self.alloc_region.blocks) > 1:
        raise VerifyException(
            f"{self.name} should have at most 1 block in alloc_region"
        )

PrivateClauseOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.private See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class PrivateClauseOp(IRDLOperation):
    """
    Implementation of upstream omp.private
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompprivate-ompprivateclauseop).
    """

    name = "omp.private"

    sym_name = prop_def(SymbolNameConstraint())
    var_type = prop_def(TypeAttribute, prop_name="type")
    data_sharing_type = prop_def(DataSharingClauseAttr)

    init_region = region_def()
    copy_region = region_def()
    dealloc_region = region_def()

    traits = traits_def(IsolatedFromAbove(), SymbolOpInterface())

    assembly_format = """
        $data_sharing_type $sym_name `:` $type
        (`init` $init_region^)?
        (`copy` $copy_region^)?
        (`dealloc` $dealloc_region^)?
        attr-dict
    """

name = 'omp.private' class-attribute instance-attribute

sym_name = prop_def(SymbolNameConstraint()) class-attribute instance-attribute

var_type = prop_def(TypeAttribute, prop_name='type') class-attribute instance-attribute

data_sharing_type = prop_def(DataSharingClauseAttr) class-attribute instance-attribute

init_region = region_def() class-attribute instance-attribute

copy_region = region_def() class-attribute instance-attribute

dealloc_region = region_def() class-attribute instance-attribute

traits = traits_def(IsolatedFromAbove(), SymbolOpInterface()) class-attribute instance-attribute

assembly_format = '\n $data_sharing_type $sym_name `:` $type\n (`init` $init_region^)?\n (`copy` $copy_region^)?\n (`dealloc` $dealloc_region^)?\n attr-dict\n ' class-attribute instance-attribute

YieldOp dataclass

Bases: AbstractYieldOperation[Attribute]

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class YieldOp(AbstractYieldOperation[Attribute]):
    name = "omp.yield"

    assembly_format = "( `(` $arguments^ `:` type($arguments) `)` )? attr-dict"

    traits = traits_def(
        IsTerminator(),
        Pure(),
        HasParent(
            LoopNestOp,
            # TODO: add these when they are implemented
            # AtomicUpdateOp,
            PrivateClauseOp,
            DeclareReductionOp,
        ),
    )

name = 'omp.yield' class-attribute instance-attribute

assembly_format = '( `(` $arguments^ `:` type($arguments) `)` )? attr-dict' class-attribute instance-attribute

traits = traits_def(IsTerminator(), Pure(), HasParent(LoopNestOp, PrivateClauseOp, DeclareReductionOp)) class-attribute instance-attribute

TerminatorOp dataclass

Bases: IRDLOperation

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TerminatorOp(IRDLOperation):
    name = "omp.terminator"

    traits = traits_def(IsTerminator(), Pure())

name = 'omp.terminator' class-attribute instance-attribute

traits = traits_def(IsTerminator(), Pure()) class-attribute instance-attribute

TargetOp dataclass

Bases: BlockArgOpenMPOperation

Implementation of upstream omp.target See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TargetOp(BlockArgOpenMPOperation):
    """
    Implementation of upstream omp.target
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptarget-omptargetop).
    """

    name = "omp.target"

    DEP_COUNT: ClassVar = IntVarConstraint("DEP_COUNT", AnyInt())

    allocate_vars = var_operand_def()
    allocator_vars = var_operand_def()
    depend_vars = var_operand_def(
        AnyRange().of_length(DEP_COUNT)  # TODO: OpenMP_PointerLikeTypeInterface
    )
    device = opt_operand_def(IntegerType)
    has_device_addr_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    host_eval_vars = var_operand_def()
    if_expr = opt_operand_def(i1)
    in_reduction_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    is_device_ptr_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    map_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    private_vars = var_operand_def()
    thread_limit = opt_operand_def(IntegerType | IndexType)

    bare = opt_prop_def(UnitAttr)
    depend_kinds = opt_prop_def(
        ArrayAttr.constr(RangeOf.get(DependKindAttr).of_length(DEP_COUNT))
    )
    in_reduction_byref = opt_prop_def(DenseArrayBase[i1])
    in_reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    nowait = opt_prop_def(UnitAttr)
    private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    private_needs_barrier = opt_prop_def(UnitAttr)
    private_maps = opt_prop_def(DenseArrayBase[i64])

    region = region_def()

    irdl_options = (AttrSizedOperandSegments(as_property=True),)
    traits = traits_def(IsolatedFromAbove())

    def num_block_args(self) -> int:
        return (
            len(self.host_eval_vars)
            + len(self.in_reduction_vars)
            + len(self.map_vars)
            + len(self.private_vars)
        )

    def verify_(self) -> None:
        verify_map_vars(
            self.map_vars,
            self.name,
            disallowed_types=[ClauseMapFlags.DELETE],
        )
        return super().verify_()

name = 'omp.target' class-attribute instance-attribute

DEP_COUNT: ClassVar = IntVarConstraint('DEP_COUNT', AnyInt()) class-attribute instance-attribute

allocate_vars = var_operand_def() class-attribute instance-attribute

allocator_vars = var_operand_def() class-attribute instance-attribute

depend_vars = var_operand_def(AnyRange().of_length(DEP_COUNT)) class-attribute instance-attribute

device = opt_operand_def(IntegerType) class-attribute instance-attribute

has_device_addr_vars = var_operand_def() class-attribute instance-attribute

host_eval_vars = var_operand_def() class-attribute instance-attribute

if_expr = opt_operand_def(i1) class-attribute instance-attribute

in_reduction_vars = var_operand_def() class-attribute instance-attribute

is_device_ptr_vars = var_operand_def() class-attribute instance-attribute

map_vars = var_operand_def() class-attribute instance-attribute

private_vars = var_operand_def() class-attribute instance-attribute

thread_limit = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

bare = opt_prop_def(UnitAttr) class-attribute instance-attribute

depend_kinds = opt_prop_def(ArrayAttr.constr(RangeOf.get(DependKindAttr).of_length(DEP_COUNT))) class-attribute instance-attribute

in_reduction_byref = opt_prop_def(DenseArrayBase[i1]) class-attribute instance-attribute

in_reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

nowait = opt_prop_def(UnitAttr) class-attribute instance-attribute

private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

private_needs_barrier = opt_prop_def(UnitAttr) class-attribute instance-attribute

private_maps = opt_prop_def(DenseArrayBase[i64]) class-attribute instance-attribute

region = region_def() class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

traits = traits_def(IsolatedFromAbove()) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return (
        len(self.host_eval_vars)
        + len(self.in_reduction_vars)
        + len(self.map_vars)
        + len(self.private_vars)
    )

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    verify_map_vars(
        self.map_vars,
        self.name,
        disallowed_types=[ClauseMapFlags.DELETE],
    )
    return super().verify_()

MapBoundsOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.map.bounds See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class MapBoundsOp(IRDLOperation):
    """
    Implementation of upstream omp.map.bounds
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompmapbounds-ompmapboundsop).
    """

    name = "omp.map.bounds"

    lower_bound = opt_operand_def(IntegerType | IndexType)
    upper_bound = opt_operand_def(IntegerType | IndexType)
    extent = opt_operand_def(IntegerType | IndexType)
    stride = opt_operand_def(IntegerType | IndexType)
    start_idx = opt_operand_def(IntegerType | IndexType)

    stride_in_bytes = prop_def(BoolAttr, default_value=BoolAttr.from_bool(False))

    res = result_def(MapBoundsType)

    irdl_options = (AttrSizedOperandSegments(as_property=True),)
    traits = traits_def(NoMemoryEffect())

name = 'omp.map.bounds' class-attribute instance-attribute

lower_bound = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

upper_bound = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

extent = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

stride = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

start_idx = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

stride_in_bytes = prop_def(BoolAttr, default_value=BoolAttr.from_bool(False)) class-attribute instance-attribute

res = result_def(MapBoundsType) class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

traits = traits_def(NoMemoryEffect()) class-attribute instance-attribute

MapInfoOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.map.info See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class MapInfoOp(IRDLOperation):
    """
    Implementation of upstream omp.map.info
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompmapinfo-ompmapinfoop).
    """

    name = "omp.map.info"

    var_ptr = operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    var_ptr_ptr = opt_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    members = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    bounds = var_operand_def(MapBoundsType)

    var_type = prop_def(TypeAttribute)
    map_type = prop_def(ClauseMapFlagsAttr)
    """
    To set or test flags in `map_type` use the bits defined in `OpenMPOffloadMappingFlags`
    """
    map_capture_type = prop_def(VariableCaptureKindAttr)
    members_index = opt_prop_def(ArrayAttr[ArrayAttr[IntegerAttr[i64]]])
    var_name = opt_prop_def(StringAttr, prop_name="name")
    partial_map = opt_prop_def(BoolAttr, default_value=BoolAttr.from_bool(False))

    omp_ptr = result_def()  # TODO: OpenMP_PointerLikeTypeInterface

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    def verify_(self) -> None:
        verify_map_vars(self.members, self.name)
        return super().verify_()

name = 'omp.map.info' class-attribute instance-attribute

var_ptr = operand_def() class-attribute instance-attribute

var_ptr_ptr = opt_operand_def() class-attribute instance-attribute

members = var_operand_def() class-attribute instance-attribute

bounds = var_operand_def(MapBoundsType) class-attribute instance-attribute

var_type = prop_def(TypeAttribute) class-attribute instance-attribute

map_type = prop_def(ClauseMapFlagsAttr) class-attribute instance-attribute

To set or test flags in map_type use the bits defined in OpenMPOffloadMappingFlags

map_capture_type = prop_def(VariableCaptureKindAttr) class-attribute instance-attribute

members_index = opt_prop_def(ArrayAttr[ArrayAttr[IntegerAttr[i64]]]) class-attribute instance-attribute

var_name = opt_prop_def(StringAttr, prop_name='name') class-attribute instance-attribute

partial_map = opt_prop_def(BoolAttr, default_value=BoolAttr.from_bool(False)) class-attribute instance-attribute

omp_ptr = result_def() class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    verify_map_vars(self.members, self.name)
    return super().verify_()

SimdOp dataclass

Bases: BlockArgOpenMPOperation

Implementation of upstream omp.simd See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class SimdOp(BlockArgOpenMPOperation):
    """
    Implementation of upstream omp.simd
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompsimd-ompsimdop).
    """

    name = "omp.simd"

    ALIGN_COUNT: ClassVar = IntVarConstraint("ALIGN_COUNT", AnyInt())
    LINEAR_COUNT: ClassVar = IntVarConstraint("LINEAR_COUNT", AnyInt())

    aligned_vars = var_operand_def(AnyRange().of_length(ALIGN_COUNT))
    if_expr = opt_operand_def(i1)
    linear_vars = var_operand_def(AnyRange().of_length(LINEAR_COUNT))
    linear_step_vars = var_operand_def(RangeOf.get(i32).of_length(LINEAR_COUNT))
    nontemporal_vars = opt_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    private_vars = var_operand_def()
    reduction_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface

    alignments = opt_prop_def(
        ArrayAttr.constr(RangeOf.get(IntegerAttr[i64]).of_length(ALIGN_COUNT))
    )
    order = opt_prop_def(OrderKindAttr)
    order_mod = opt_prop_def(OrderModifierAttr)
    private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    reduction_mod = opt_prop_def(ReductionModifierAttr)
    reduction_byref = opt_prop_def(DenseArrayBase[i1])
    reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    simdlen = opt_prop_def(IntegerAttr.constr(value=AtLeast(1), type=i64))
    safelen = opt_prop_def(IntegerAttr.constr(value=AtLeast(1), type=i64))
    linear_var_types = opt_prop_def(ArrayAttr)

    body = region_def("single_block")

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    traits = traits_def(RecursiveMemoryEffect(), LoopWrapper())

    def num_block_args(self) -> int:
        return len(self.private_vars) + len(self.reduction_vars)

    def verify_(self) -> None:
        if self.simdlen and self.safelen:
            if self.simdlen.value.data > self.safelen.value.data:
                raise VerifyException(
                    f"in {self.name} `safelen` must be greater than or equal to `simdlen`"
                )
        return super().verify_()

name = 'omp.simd' class-attribute instance-attribute

ALIGN_COUNT: ClassVar = IntVarConstraint('ALIGN_COUNT', AnyInt()) class-attribute instance-attribute

LINEAR_COUNT: ClassVar = IntVarConstraint('LINEAR_COUNT', AnyInt()) class-attribute instance-attribute

aligned_vars = var_operand_def(AnyRange().of_length(ALIGN_COUNT)) class-attribute instance-attribute

if_expr = opt_operand_def(i1) class-attribute instance-attribute

linear_vars = var_operand_def(AnyRange().of_length(LINEAR_COUNT)) class-attribute instance-attribute

linear_step_vars = var_operand_def(RangeOf.get(i32).of_length(LINEAR_COUNT)) class-attribute instance-attribute

nontemporal_vars = opt_operand_def() class-attribute instance-attribute

private_vars = var_operand_def() class-attribute instance-attribute

reduction_vars = var_operand_def() class-attribute instance-attribute

alignments = opt_prop_def(ArrayAttr.constr(RangeOf.get(IntegerAttr[i64]).of_length(ALIGN_COUNT))) class-attribute instance-attribute

order = opt_prop_def(OrderKindAttr) class-attribute instance-attribute

order_mod = opt_prop_def(OrderModifierAttr) class-attribute instance-attribute

private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

reduction_mod = opt_prop_def(ReductionModifierAttr) class-attribute instance-attribute

reduction_byref = opt_prop_def(DenseArrayBase[i1]) class-attribute instance-attribute

reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

simdlen = opt_prop_def(IntegerAttr.constr(value=AtLeast(1), type=i64)) class-attribute instance-attribute

safelen = opt_prop_def(IntegerAttr.constr(value=AtLeast(1), type=i64)) class-attribute instance-attribute

linear_var_types = opt_prop_def(ArrayAttr) class-attribute instance-attribute

body = region_def('single_block') class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

traits = traits_def(RecursiveMemoryEffect(), LoopWrapper()) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return len(self.private_vars) + len(self.reduction_vars)

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    if self.simdlen and self.safelen:
        if self.simdlen.value.data > self.safelen.value.data:
            raise VerifyException(
                f"in {self.name} `safelen` must be greater than or equal to `simdlen`"
            )
    return super().verify_()

TeamsOp dataclass

Bases: BlockArgOpenMPOperation

Implementation of upstream omp.teams See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TeamsOp(BlockArgOpenMPOperation):
    """
    Implementation of upstream omp.teams
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompteams-ompteamsop).
    """

    name = "omp.teams"

    allocate_vars = var_operand_def()
    allocator_vars = var_operand_def()
    if_expr = opt_operand_def(i1)
    num_teams_lower = opt_operand_def(IntegerType)
    num_teams_upper = opt_operand_def(IntegerType)
    private_vars = var_operand_def()
    reduction_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    thread_limit = opt_operand_def(IntegerType)

    private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    reduction_mod = opt_prop_def(ReductionModifierAttr)
    reduction_byref = opt_prop_def(DenseArrayBase[i1])
    reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])

    body = region_def()

    irdl_options = (AttrSizedOperandSegments(as_property=True),)
    traits = traits_def(RecursiveMemoryEffect())

    def num_block_args(self) -> int:
        return len(self.private_vars) + len(self.reduction_vars)

name = 'omp.teams' class-attribute instance-attribute

allocate_vars = var_operand_def() class-attribute instance-attribute

allocator_vars = var_operand_def() class-attribute instance-attribute

if_expr = opt_operand_def(i1) class-attribute instance-attribute

num_teams_lower = opt_operand_def(IntegerType) class-attribute instance-attribute

num_teams_upper = opt_operand_def(IntegerType) class-attribute instance-attribute

private_vars = var_operand_def() class-attribute instance-attribute

reduction_vars = var_operand_def() class-attribute instance-attribute

thread_limit = opt_operand_def(IntegerType) class-attribute instance-attribute

private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

reduction_mod = opt_prop_def(ReductionModifierAttr) class-attribute instance-attribute

reduction_byref = opt_prop_def(DenseArrayBase[i1]) class-attribute instance-attribute

reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

body = region_def() class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

traits = traits_def(RecursiveMemoryEffect()) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return len(self.private_vars) + len(self.reduction_vars)

DistributeOp dataclass

Bases: BlockArgOpenMPOperation

Implementation of upstream omp.distribute https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompdistribute-ompdistributeop

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class DistributeOp(BlockArgOpenMPOperation):
    """
    Implementation of upstream omp.distribute
    https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompdistribute-ompdistributeop
    """

    name = "omp.distribute"

    allocate_vars = var_operand_def()
    allocator_vars = var_operand_def()
    dist_schedule_chunk_size = opt_operand_def(IntegerType | IndexType)
    private_vars = var_operand_def()

    dist_schedule_static = opt_prop_def(UnitAttr)
    order = opt_prop_def(OrderKindAttr)
    order_mod = opt_prop_def(OrderModifierAttr)
    private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    body = region_def("single_block")

    traits = traits_def(LoopWrapper(), RecursiveMemoryEffect())

    def num_block_args(self) -> int:
        return len(self.private_vars)

    def verify_(self) -> None:
        if bool(self.dist_schedule_chunk_size) != bool(self.dist_schedule_static):
            raise VerifyException(
                f"{self.name} should have either both dist_schedule_static and dist_schedule_chunk_size, or neither."
            )
        return super().verify_()

name = 'omp.distribute' class-attribute instance-attribute

allocate_vars = var_operand_def() class-attribute instance-attribute

allocator_vars = var_operand_def() class-attribute instance-attribute

dist_schedule_chunk_size = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

private_vars = var_operand_def() class-attribute instance-attribute

dist_schedule_static = opt_prop_def(UnitAttr) class-attribute instance-attribute

order = opt_prop_def(OrderKindAttr) class-attribute instance-attribute

order_mod = opt_prop_def(OrderModifierAttr) class-attribute instance-attribute

private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

body = region_def('single_block') class-attribute instance-attribute

traits = traits_def(LoopWrapper(), RecursiveMemoryEffect()) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return len(self.private_vars)

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    if bool(self.dist_schedule_chunk_size) != bool(self.dist_schedule_static):
        raise VerifyException(
            f"{self.name} should have either both dist_schedule_static and dist_schedule_chunk_size, or neither."
        )
    return super().verify_()

TargetTaskBasedDataOp dataclass

Bases: IRDLOperation

Base class representing target data movement operations which are task based, this includes enter and exit data pragmas along with data update

Source code in xdsl/dialects/omp.py
class TargetTaskBasedDataOp(IRDLOperation):
    """
    Base class representing target data movement operations which are task based,
    this includes enter and exit data pragmas along with data update
    """

    DEP_COUNT: ClassVar = IntVarConstraint("DEP_COUNT", AnyInt())

    depend_vars = var_operand_def(
        AnyRange().of_length(DEP_COUNT)  # TODO: OpenMP_PointerLikeTypeInterface
    )
    device = opt_operand_def(IntegerType | IndexType)
    if_expr = opt_operand_def(i1)
    mapped_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface

    depend_kinds = opt_prop_def(
        ArrayAttr.constr(RangeOf.get(DependKindAttr).of_length(DEP_COUNT))
    )
    nowait = opt_prop_def(UnitAttr)

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

DEP_COUNT: ClassVar = IntVarConstraint('DEP_COUNT', AnyInt()) class-attribute instance-attribute

depend_vars = var_operand_def(AnyRange().of_length(DEP_COUNT)) class-attribute instance-attribute

device = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

if_expr = opt_operand_def(i1) class-attribute instance-attribute

mapped_vars = var_operand_def() class-attribute instance-attribute

depend_kinds = opt_prop_def(ArrayAttr.constr(RangeOf.get(DependKindAttr).of_length(DEP_COUNT))) class-attribute instance-attribute

nowait = opt_prop_def(UnitAttr) class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

TargetEnterDataOp dataclass

Bases: TargetTaskBasedDataOp

Implementation of upstream omp.target_enter_data See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TargetEnterDataOp(TargetTaskBasedDataOp):
    """
    Implementation of upstream omp.target_enter_data
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptarget_enter_data-omptargetenterdataop).
    """

    name = "omp.target_enter_data"

    def verify_(self) -> None:
        verify_map_vars(
            self.mapped_vars,
            self.name,
            disallowed_types=[ClauseMapFlags.FROM, ClauseMapFlags.DELETE],
        )
        return super().verify_()

name = 'omp.target_enter_data' class-attribute instance-attribute

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    verify_map_vars(
        self.mapped_vars,
        self.name,
        disallowed_types=[ClauseMapFlags.FROM, ClauseMapFlags.DELETE],
    )
    return super().verify_()

TargetExitDataOp dataclass

Bases: TargetTaskBasedDataOp

Implementation of omp.target_exit_data See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TargetExitDataOp(TargetTaskBasedDataOp):
    """
    Implementation of omp.target_exit_data
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptarget_enter_data-omptargetenterdataop).
    """

    name = "omp.target_exit_data"

    def verify_(self) -> None:
        verify_map_vars(
            self.mapped_vars,
            self.name,
            disallowed_types=[ClauseMapFlags.TO],
        )
        return super().verify_()

name = 'omp.target_exit_data' class-attribute instance-attribute

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    verify_map_vars(
        self.mapped_vars,
        self.name,
        disallowed_types=[ClauseMapFlags.TO],
    )
    return super().verify_()

TargetUpdateOp dataclass

Bases: TargetTaskBasedDataOp

Implementation of upstream omp.target_update See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TargetUpdateOp(TargetTaskBasedDataOp):
    """
    Implementation of upstream omp.target_update
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptarget_update-omptargetupdateop).
    """

    name = "omp.target_update"

    def verify_(self) -> None:
        verify_map_vars(
            self.mapped_vars,
            self.name,
            disallowed_types=[ClauseMapFlags.DELETE],
        )
        mapped = defaultdict[SSAValue, set[ClauseMapFlags]](lambda: set())
        one_of = {ClauseMapFlags.TO, ClauseMapFlags.FROM}
        for var in self.mapped_vars:
            owner = var.owner
            assert isinstance(owner, MapInfoOp)

            mapped[owner.var_ptr] |= owner.map_type.data
            if len(mapped[owner.var_ptr] & one_of) != 1:
                raise VerifyException(
                    f"{self.name} expected to have exactly one of TO or FROM as map_type"
                )
        return super().verify_()

name = 'omp.target_update' class-attribute instance-attribute

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    verify_map_vars(
        self.mapped_vars,
        self.name,
        disallowed_types=[ClauseMapFlags.DELETE],
    )
    mapped = defaultdict[SSAValue, set[ClauseMapFlags]](lambda: set())
    one_of = {ClauseMapFlags.TO, ClauseMapFlags.FROM}
    for var in self.mapped_vars:
        owner = var.owner
        assert isinstance(owner, MapInfoOp)

        mapped[owner.var_ptr] |= owner.map_type.data
        if len(mapped[owner.var_ptr] & one_of) != 1:
            raise VerifyException(
                f"{self.name} expected to have exactly one of TO or FROM as map_type"
            )
    return super().verify_()

TargetDataOp dataclass

Bases: BlockArgOpenMPOperation

Implementation of upstream omp.target_data See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TargetDataOp(BlockArgOpenMPOperation):
    """
    Implementation of upstream omp.target_data
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptarget_data-omptargetdataop).
    """

    name = "omp.target_data"

    device = opt_operand_def(IntegerType)
    if_expr = opt_operand_def(i1)
    mapped_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    use_device_addr_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    use_device_ptr_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface

    region = region_def()

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    def num_block_args(self) -> int:
        # NOTE: Unlike TargetOp `mapped_vars` are not passed as block args.
        return len(self.use_device_addr_vars) + len(self.use_device_ptr_vars)

    def verify_(self) -> None:
        verify_map_vars(
            self.mapped_vars,
            self.name,
            disallowed_types=[ClauseMapFlags.DELETE],
        )
        return super().verify_()

name = 'omp.target_data' class-attribute instance-attribute

device = opt_operand_def(IntegerType) class-attribute instance-attribute

if_expr = opt_operand_def(i1) class-attribute instance-attribute

mapped_vars = var_operand_def() class-attribute instance-attribute

use_device_addr_vars = var_operand_def() class-attribute instance-attribute

use_device_ptr_vars = var_operand_def() class-attribute instance-attribute

region = region_def() class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    # NOTE: Unlike TargetOp `mapped_vars` are not passed as block args.
    return len(self.use_device_addr_vars) + len(self.use_device_ptr_vars)

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    verify_map_vars(
        self.mapped_vars,
        self.name,
        disallowed_types=[ClauseMapFlags.DELETE],
    )
    return super().verify_()

TaskwaitOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.taskwait See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TaskwaitOp(IRDLOperation):
    """
    Implementation of upstream omp.taskwait
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptaskwait-omptaskwaitop).
    """

    name = "omp.taskwait"

    DEP_COUNT: ClassVar = IntVarConstraint("DEP_COUNT", AnyInt())

    depend_vars = var_operand_def(AnyRange().of_length(DEP_COUNT))

    depend_kinds = opt_prop_def(
        ArrayAttr.constr(RangeOf.get(DependKindAttr).of_length(DEP_COUNT))
    )
    nowait = opt_prop_def(UnitAttr)

name = 'omp.taskwait' class-attribute instance-attribute

DEP_COUNT: ClassVar = IntVarConstraint('DEP_COUNT', AnyInt()) class-attribute instance-attribute

depend_vars = var_operand_def(AnyRange().of_length(DEP_COUNT)) class-attribute instance-attribute

depend_kinds = opt_prop_def(ArrayAttr.constr(RangeOf.get(DependKindAttr).of_length(DEP_COUNT))) class-attribute instance-attribute

nowait = opt_prop_def(UnitAttr) class-attribute instance-attribute

TaskyieldOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.taskyield See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TaskyieldOp(IRDLOperation):
    """
    Implementation of upstream omp.taskyield
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptaskyield-omptaskyieldop).
    """

    name = "omp.taskyield"

name = 'omp.taskyield' class-attribute instance-attribute

SingleOp dataclass

Bases: BlockArgOpenMPOperation

Implementation of upstream omp.single See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class SingleOp(BlockArgOpenMPOperation):
    """
    Implementation of upstream omp.single
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompsingle-ompsingleop).
    """

    name = "omp.single"

    allocate_vars = var_operand_def()
    allocator_vars = var_operand_def()
    copyprivate_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    private_vars = var_operand_def()

    copyprivate_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    nowait = opt_prop_def(UnitAttr)
    private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    private_needs_barrier = opt_prop_def(UnitAttr)

    region = region_def()

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    def num_block_args(self) -> int:
        return len(self.private_vars)

    def verify_(self) -> None:
        num_syms = 0 if self.copyprivate_syms is None else len(self.copyprivate_syms)
        if len(self.copyprivate_vars) != num_syms:
            raise VerifyException(
                f"{self.name} inconsistent number of copyprivate vars "
                f"({len(self.copyprivate_vars)}) and functions ({num_syms})"
            )
        return super().verify_()

name = 'omp.single' class-attribute instance-attribute

allocate_vars = var_operand_def() class-attribute instance-attribute

allocator_vars = var_operand_def() class-attribute instance-attribute

copyprivate_vars = var_operand_def() class-attribute instance-attribute

private_vars = var_operand_def() class-attribute instance-attribute

copyprivate_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

nowait = opt_prop_def(UnitAttr) class-attribute instance-attribute

private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

private_needs_barrier = opt_prop_def(UnitAttr) class-attribute instance-attribute

region = region_def() class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return len(self.private_vars)

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    num_syms = 0 if self.copyprivate_syms is None else len(self.copyprivate_syms)
    if len(self.copyprivate_vars) != num_syms:
        raise VerifyException(
            f"{self.name} inconsistent number of copyprivate vars "
            f"({len(self.copyprivate_vars)}) and functions ({num_syms})"
        )
    return super().verify_()

TaskOp dataclass

Bases: BlockArgOpenMPOperation

Implementation of upstream omp.task See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TaskOp(BlockArgOpenMPOperation):
    """
    Implementation of upstream omp.task
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptask-omptaskop).
    """

    name = "omp.task"

    DEP_COUNT: ClassVar = IntVarConstraint("DEP_COUNT", AnyInt())

    allocate_vars = var_operand_def()
    allocator_vars = var_operand_def()
    depend_vars = var_operand_def(
        AnyRange().of_length(DEP_COUNT)  # TODO: OpenMP_PointerLikeTypeInterface
    )
    final = opt_operand_def(i1)
    if_expr = opt_operand_def(i1)
    in_reduction_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    priority = opt_operand_def(IntegerType)
    private_vars = var_operand_def()
    event_handle = opt_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface

    depend_kinds = opt_prop_def(
        ArrayAttr.constr(RangeOf.get(DependKindAttr).of_length(DEP_COUNT))
    )
    in_reduction_byref = opt_prop_def(DenseArrayBase[i1])
    in_reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    mergeable = opt_prop_def(UnitAttr)
    private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    private_needs_barrier = opt_prop_def(UnitAttr)
    untied = opt_prop_def(UnitAttr)

    region = region_def()

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    def num_block_args(self) -> int:
        return len(self.in_reduction_vars) + len(self.private_vars)

    def verify_(self) -> None:
        num_vars = len(self.in_reduction_vars)
        num_syms = 0 if self.in_reduction_syms is None else len(self.in_reduction_syms)
        if num_vars != num_syms:
            raise VerifyException(
                f"{self.name} expected as many in_reduction symbol references "
                "as in_reduction variables"
            )
        byref = self.in_reduction_byref
        if byref is not None and len(byref) != num_vars:
            raise VerifyException(
                f"{self.name} expected as many in_reduction byref flags "
                "as in_reduction variables"
            )
        return super().verify_()

name = 'omp.task' class-attribute instance-attribute

DEP_COUNT: ClassVar = IntVarConstraint('DEP_COUNT', AnyInt()) class-attribute instance-attribute

allocate_vars = var_operand_def() class-attribute instance-attribute

allocator_vars = var_operand_def() class-attribute instance-attribute

depend_vars = var_operand_def(AnyRange().of_length(DEP_COUNT)) class-attribute instance-attribute

final = opt_operand_def(i1) class-attribute instance-attribute

if_expr = opt_operand_def(i1) class-attribute instance-attribute

in_reduction_vars = var_operand_def() class-attribute instance-attribute

priority = opt_operand_def(IntegerType) class-attribute instance-attribute

private_vars = var_operand_def() class-attribute instance-attribute

event_handle = opt_operand_def() class-attribute instance-attribute

depend_kinds = opt_prop_def(ArrayAttr.constr(RangeOf.get(DependKindAttr).of_length(DEP_COUNT))) class-attribute instance-attribute

in_reduction_byref = opt_prop_def(DenseArrayBase[i1]) class-attribute instance-attribute

in_reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

mergeable = opt_prop_def(UnitAttr) class-attribute instance-attribute

private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

private_needs_barrier = opt_prop_def(UnitAttr) class-attribute instance-attribute

untied = opt_prop_def(UnitAttr) class-attribute instance-attribute

region = region_def() class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return len(self.in_reduction_vars) + len(self.private_vars)

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    num_vars = len(self.in_reduction_vars)
    num_syms = 0 if self.in_reduction_syms is None else len(self.in_reduction_syms)
    if num_vars != num_syms:
        raise VerifyException(
            f"{self.name} expected as many in_reduction symbol references "
            "as in_reduction variables"
        )
    byref = self.in_reduction_byref
    if byref is not None and len(byref) != num_vars:
        raise VerifyException(
            f"{self.name} expected as many in_reduction byref flags "
            "as in_reduction variables"
        )
    return super().verify_()

TaskgroupOp dataclass

Bases: BlockArgOpenMPOperation

Implementation of upstream omp.taskgroup See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TaskgroupOp(BlockArgOpenMPOperation):
    """
    Implementation of upstream omp.taskgroup
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptaskgroup-omptaskgroupop).
    """

    name = "omp.taskgroup"

    allocate_vars = var_operand_def()
    allocator_vars = var_operand_def()
    task_reduction_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface

    task_reduction_byref = opt_prop_def(DenseArrayBase[i1])
    task_reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])

    region = region_def()

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    def num_block_args(self) -> int:
        return len(self.task_reduction_vars)

    def verify_(self) -> None:
        num_vars = len(self.task_reduction_vars)
        num_syms = (
            0 if self.task_reduction_syms is None else len(self.task_reduction_syms)
        )
        if num_vars != num_syms:
            raise VerifyException(
                f"{self.name} expected as many task_reduction symbol references "
                "as task_reduction variables"
            )
        byref = self.task_reduction_byref
        if byref is not None and len(byref) != num_vars:
            raise VerifyException(
                f"{self.name} expected as many task_reduction byref flags "
                "as task_reduction variables"
            )
        return super().verify_()

name = 'omp.taskgroup' class-attribute instance-attribute

allocate_vars = var_operand_def() class-attribute instance-attribute

allocator_vars = var_operand_def() class-attribute instance-attribute

task_reduction_vars = var_operand_def() class-attribute instance-attribute

task_reduction_byref = opt_prop_def(DenseArrayBase[i1]) class-attribute instance-attribute

task_reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

region = region_def() class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return len(self.task_reduction_vars)

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    num_vars = len(self.task_reduction_vars)
    num_syms = (
        0 if self.task_reduction_syms is None else len(self.task_reduction_syms)
    )
    if num_vars != num_syms:
        raise VerifyException(
            f"{self.name} expected as many task_reduction symbol references "
            "as task_reduction variables"
        )
    byref = self.task_reduction_byref
    if byref is not None and len(byref) != num_vars:
        raise VerifyException(
            f"{self.name} expected as many task_reduction byref flags "
            "as task_reduction variables"
        )
    return super().verify_()

TaskloopOp dataclass

Bases: BlockArgOpenMPOperation

Implementation of upstream omp.taskloop See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class TaskloopOp(BlockArgOpenMPOperation):
    """
    Implementation of upstream omp.taskloop
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#omptaskloop-omptaskloopop).
    """

    name = "omp.taskloop"

    allocate_vars = var_operand_def()
    allocator_vars = var_operand_def()
    final = opt_operand_def(i1)
    grainsize = opt_operand_def(IntegerType | IndexType)
    if_expr = opt_operand_def(i1)
    in_reduction_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface
    num_tasks = opt_operand_def(IntegerType | IndexType)
    priority = opt_operand_def(IntegerType)
    private_vars = var_operand_def()
    reduction_vars = var_operand_def()  # TODO: OpenMP_PointerLikeTypeInterface

    grainsize_mod = opt_prop_def(GrainsizeTypeAttr)
    in_reduction_byref = opt_prop_def(DenseArrayBase[i1])
    in_reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    mergeable = opt_prop_def(UnitAttr)
    nogroup = opt_prop_def(UnitAttr)
    num_tasks_mod = opt_prop_def(NumTasksTypeAttr)
    private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    private_needs_barrier = opt_prop_def(UnitAttr)
    reduction_mod = opt_prop_def(ReductionModifierAttr)
    reduction_byref = opt_prop_def(DenseArrayBase[i1])
    reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr])
    untied = opt_prop_def(UnitAttr)

    region = region_def("single_block")

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    traits = traits_def(LoopWrapper(), RecursiveMemoryEffect())

    def num_block_args(self) -> int:
        return (
            len(self.in_reduction_vars)
            + len(self.private_vars)
            + len(self.reduction_vars)
        )

    def verify_(self) -> None:
        if self.grainsize is not None and self.num_tasks is not None:
            raise VerifyException(
                "the grainsize clause and num_tasks clause are mutually exclusive "
                "and may not appear on the same taskloop directive"
            )
        num_in_reduction_vars = len(self.in_reduction_vars)
        num_in_reduction_syms = (
            0 if self.in_reduction_syms is None else len(self.in_reduction_syms)
        )
        if num_in_reduction_vars != num_in_reduction_syms:
            raise VerifyException(
                f"{self.name} expected as many in_reduction symbol references "
                "as in_reduction variables"
            )
        in_reduction_byref = self.in_reduction_byref
        if (
            in_reduction_byref is not None
            and len(in_reduction_byref) != num_in_reduction_vars
        ):
            raise VerifyException(
                f"{self.name} expected as many in_reduction byref flags "
                "as in_reduction variables"
            )
        num_reduction_vars = len(self.reduction_vars)
        num_reduction_syms = (
            0 if self.reduction_syms is None else len(self.reduction_syms)
        )
        if num_reduction_vars != num_reduction_syms:
            raise VerifyException(
                f"{self.name} expected as many reduction symbol references "
                "as reduction variables"
            )
        reduction_byref = self.reduction_byref
        if reduction_byref is not None and len(reduction_byref) != num_reduction_vars:
            raise VerifyException(
                f"{self.name} expected as many reduction byref flags "
                "as reduction variables"
            )
        return super().verify_()

name = 'omp.taskloop' class-attribute instance-attribute

allocate_vars = var_operand_def() class-attribute instance-attribute

allocator_vars = var_operand_def() class-attribute instance-attribute

final = opt_operand_def(i1) class-attribute instance-attribute

grainsize = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

if_expr = opt_operand_def(i1) class-attribute instance-attribute

in_reduction_vars = var_operand_def() class-attribute instance-attribute

num_tasks = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

priority = opt_operand_def(IntegerType) class-attribute instance-attribute

private_vars = var_operand_def() class-attribute instance-attribute

reduction_vars = var_operand_def() class-attribute instance-attribute

grainsize_mod = opt_prop_def(GrainsizeTypeAttr) class-attribute instance-attribute

in_reduction_byref = opt_prop_def(DenseArrayBase[i1]) class-attribute instance-attribute

in_reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

mergeable = opt_prop_def(UnitAttr) class-attribute instance-attribute

nogroup = opt_prop_def(UnitAttr) class-attribute instance-attribute

num_tasks_mod = opt_prop_def(NumTasksTypeAttr) class-attribute instance-attribute

private_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

private_needs_barrier = opt_prop_def(UnitAttr) class-attribute instance-attribute

reduction_mod = opt_prop_def(ReductionModifierAttr) class-attribute instance-attribute

reduction_byref = opt_prop_def(DenseArrayBase[i1]) class-attribute instance-attribute

reduction_syms = opt_prop_def(ArrayAttr[SymbolRefAttr]) class-attribute instance-attribute

untied = opt_prop_def(UnitAttr) class-attribute instance-attribute

region = region_def('single_block') class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

traits = traits_def(LoopWrapper(), RecursiveMemoryEffect()) class-attribute instance-attribute

num_block_args() -> int

Source code in xdsl/dialects/omp.py
def num_block_args(self) -> int:
    return (
        len(self.in_reduction_vars)
        + len(self.private_vars)
        + len(self.reduction_vars)
    )

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    if self.grainsize is not None and self.num_tasks is not None:
        raise VerifyException(
            "the grainsize clause and num_tasks clause are mutually exclusive "
            "and may not appear on the same taskloop directive"
        )
    num_in_reduction_vars = len(self.in_reduction_vars)
    num_in_reduction_syms = (
        0 if self.in_reduction_syms is None else len(self.in_reduction_syms)
    )
    if num_in_reduction_vars != num_in_reduction_syms:
        raise VerifyException(
            f"{self.name} expected as many in_reduction symbol references "
            "as in_reduction variables"
        )
    in_reduction_byref = self.in_reduction_byref
    if (
        in_reduction_byref is not None
        and len(in_reduction_byref) != num_in_reduction_vars
    ):
        raise VerifyException(
            f"{self.name} expected as many in_reduction byref flags "
            "as in_reduction variables"
        )
    num_reduction_vars = len(self.reduction_vars)
    num_reduction_syms = (
        0 if self.reduction_syms is None else len(self.reduction_syms)
    )
    if num_reduction_vars != num_reduction_syms:
        raise VerifyException(
            f"{self.name} expected as many reduction symbol references "
            "as reduction variables"
        )
    reduction_byref = self.reduction_byref
    if reduction_byref is not None and len(reduction_byref) != num_reduction_vars:
        raise VerifyException(
            f"{self.name} expected as many reduction byref flags "
            "as reduction variables"
        )
    return super().verify_()

BarrierOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.barrier See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class BarrierOp(IRDLOperation):
    """
    Implementation of upstream omp.barrier
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompbarrier-ompbarrierop).
    """

    name = "omp.barrier"

name = 'omp.barrier' class-attribute instance-attribute

FlushOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.flush See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class FlushOp(IRDLOperation):
    """
    Implementation of upstream omp.flush
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompflush-ompflushop).
    """

    name = "omp.flush"

    var_list = var_operand_def()

name = 'omp.flush' class-attribute instance-attribute

var_list = var_operand_def() class-attribute instance-attribute

MasterOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.master See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class MasterOp(IRDLOperation):
    """
    Implementation of upstream omp.master
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompmaster-ompmasterop).
    """

    name = "omp.master"

    region = region_def()

name = 'omp.master' class-attribute instance-attribute

region = region_def() class-attribute instance-attribute

MaskedOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.masked See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class MaskedOp(IRDLOperation):
    """
    Implementation of upstream omp.masked
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompmasked-ompmaskedop).
    """

    name = "omp.masked"

    filtered_thread_id = opt_operand_def(IntegerType | IndexType)

    region = region_def()

name = 'omp.masked' class-attribute instance-attribute

filtered_thread_id = opt_operand_def(IntegerType | IndexType) class-attribute instance-attribute

region = region_def() class-attribute instance-attribute

CancelOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.cancel See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class CancelOp(IRDLOperation):
    """
    Implementation of upstream omp.cancel
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompcancel-ompcancelop).
    """

    name = "omp.cancel"

    if_expr = opt_operand_def(i1)

    cancel_directive = prop_def(CancellationConstructTypeAttr)

    def verify_(self) -> None:
        construct = verify_cancel_construct_parent(
            self, self.cancel_directive.data, "cancel"
        )
        if not isinstance(construct, WsLoopOp):
            return
        if construct.nowait is not None:
            raise VerifyException(
                "A worksharing construct that is canceled must not have a nowait clause"
            )
        if construct.ordered is not None:
            raise VerifyException(
                "A worksharing construct that is canceled must not have an ordered clause"
            )

name = 'omp.cancel' class-attribute instance-attribute

if_expr = opt_operand_def(i1) class-attribute instance-attribute

cancel_directive = prop_def(CancellationConstructTypeAttr) class-attribute instance-attribute

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    construct = verify_cancel_construct_parent(
        self, self.cancel_directive.data, "cancel"
    )
    if not isinstance(construct, WsLoopOp):
        return
    if construct.nowait is not None:
        raise VerifyException(
            "A worksharing construct that is canceled must not have a nowait clause"
        )
    if construct.ordered is not None:
        raise VerifyException(
            "A worksharing construct that is canceled must not have an ordered clause"
        )

CancellationPointOp dataclass

Bases: IRDLOperation

Implementation of upstream omp.cancellation_point See external documentation.

Source code in xdsl/dialects/omp.py
@irdl_op_definition
class CancellationPointOp(IRDLOperation):
    """
    Implementation of upstream omp.cancellation_point
    See external [documentation](https://mlir.llvm.org/docs/Dialects/OpenMPDialect/ODS/#ompcancellation_point-ompcancellationpointop).
    """

    name = "omp.cancellation_point"

    cancel_directive = prop_def(CancellationConstructTypeAttr)

    def verify_(self) -> None:
        verify_cancel_construct_parent(
            self, self.cancel_directive.data, "cancellation point"
        )

name = 'omp.cancellation_point' class-attribute instance-attribute

cancel_directive = prop_def(CancellationConstructTypeAttr) class-attribute instance-attribute

verify_() -> None

Source code in xdsl/dialects/omp.py
def verify_(self) -> None:
    verify_cancel_construct_parent(
        self, self.cancel_directive.data, "cancellation point"
    )

verify_map_vars(vars: VarOperand, op_name: str, *, disallowed_types: Sequence[ClauseMapFlags] = ())

Source code in xdsl/dialects/omp.py
def verify_map_vars(
    vars: VarOperand,
    op_name: str,
    *,
    disallowed_types: Sequence[ClauseMapFlags] = (),
):
    for var in vars:
        if not isinstance(owner := var.owner, MapInfoOp):
            raise VerifyException(
                f"All mapped operands of {op_name} must be results of a {MapInfoOp.name}"
            )
        for t in disallowed_types:
            if t in owner.map_type.data:
                raise VerifyException(f"Cannot have map_type {t.name} in {op_name}")

verify_cancel_construct_parent(op: Operation, construct: CancellationConstructType, directive: str) -> Operation | None

Verifies that op is nested in the region the construct refers to, ignoring any non-omp operations in between, and returns the operation of that region.

Source code in xdsl/dialects/omp.py
def verify_cancel_construct_parent(
    op: Operation, construct: CancellationConstructType, directive: str
) -> Operation | None:
    """
    Verifies that `op` is nested in the region the `construct` refers to, ignoring any
    non-omp operations in between, and returns the operation of that region.
    """
    parent = op.parent_op()
    while parent is not None and parent.dialect_name() != OMP.name:
        parent = parent.parent_op()
    if parent is None:
        raise VerifyException(f"Orphaned {directive} construct")
    match construct:
        case CancellationConstructType.PARALLEL:
            if not isinstance(parent, ParallelOp):
                raise VerifyException(
                    f"{directive} parallel must appear inside a parallel region"
                )
        case CancellationConstructType.LOOP:
            parent = parent.parent_op() if isinstance(parent, LoopNestOp) else None
            if not isinstance(parent, WsLoopOp):
                raise VerifyException(
                    f"{directive} loop must appear inside a worksharing-loop region"
                )
        case CancellationConstructType.TASKGROUP:
            if isinstance(parent, LoopNestOp):
                parent = parent.parent_op()
            if not isinstance(parent, TaskOp | TaskloopOp):
                raise VerifyException(
                    f"{directive} taskgroup must appear inside a task region"
                )
        case _:
            # TODO: verify sections once `omp.sections` is defined
            pass
    return parent