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], [ClauseRequiresKindAttr, ClauseMapFlagsAttr, DataSharingClauseAttr, DeclareTargetAttr, DeclareTargetCaptureClauseAttr, DeclareTargetDeviceTypeAttr, OrderKindAttr, ProcBindKindAttr, ScheduleKindAttr, ScheduleModifierAttr, DependKindAttr, MapBoundsType, VariableCaptureKindAttr, VersionAttr, ReductionModifierAttr, OrderModifierAttr]) 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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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
133
134
135
136
137
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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
163
164
165
166
167
168
169
@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
188
189
190
191
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
194
195
196
197
198
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
201
202
class OrderKind(StrEnum):
    CONCURRENT = auto()

CONCURRENT = auto() class-attribute instance-attribute

OrderModifier

Bases: StrEnum

Source code in xdsl/dialects/omp.py
205
206
207
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
210
211
212
213
214
215
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
218
219
220
221
222
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
225
226
227
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
230
231
232
233
234
235
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
238
239
240
241
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
244
245
246
247
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
250
251
252
253
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

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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
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
293
294
295
296
297
298
299
300
301
302
303
304
305
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
307
308
@abstractmethod
def num_block_args(self) -> int: ...

ScheduleKindAttr dataclass

Bases: EnumAttribute[ScheduleKind], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
314
315
316
@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
319
320
321
322
323
@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
326
327
328
329
330
331
332
333
334
335
336
337
@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
330
331
332
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
334
335
336
337
@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
340
341
342
@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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
@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
351
352
353
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
355
356
357
358
@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
361
362
363
@irdl_attr_definition
class OrderModifierAttr(EnumAttribute[OrderModifier], SpacedOpaqueSyntaxAttribute):
    name = "omp.order_mod"

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

VariableCaptureKindAttr dataclass

Bases: EnumAttribute[VariableCaptureKind], SpacedOpaqueSyntaxAttribute

Source code in xdsl/dialects/omp.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
@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
372
373
374
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
376
377
378
379
@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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
@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
393
394
395
396
@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
398
399
400
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
@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
414
415
416
417
@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
419
420
421
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
@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
    capture_clause: DeclareTargetCaptureClauseAttr

    @classmethod
    def parse_parameters(cls, parser: AttrParser) -> list[Attribute]:
        with parser.in_angle_brackets():
            parser.parse_keyword("device_type")
            parser.parse_punctuation("=")
            device_type = DeclareTargetDeviceTypeAttr(
                DeclareTargetDeviceTypeAttr.parse_parameter(parser)
            )
            parser.parse_punctuation(",")
            parser.parse_keyword("capture_clause")
            parser.parse_punctuation("=")
            capture = DeclareTargetCaptureClauseAttr(
                DeclareTargetCaptureClauseAttr.parse_parameter(parser)
            )
            return [device_type, capture]

    def print_parameters(self, printer: Printer):
        with printer.in_angle_brackets():
            printer.print_string("device_type = ")
            self.device_type.print_parameter(printer)
            printer.print_string(", capture_clause = ")
            self.capture_clause.print_parameter(printer)

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

device_type: DeclareTargetDeviceTypeAttr instance-attribute

capture_clause: DeclareTargetCaptureClauseAttr instance-attribute

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

Source code in xdsl/dialects/omp.py
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
@classmethod
def parse_parameters(cls, parser: AttrParser) -> list[Attribute]:
    with parser.in_angle_brackets():
        parser.parse_keyword("device_type")
        parser.parse_punctuation("=")
        device_type = DeclareTargetDeviceTypeAttr(
            DeclareTargetDeviceTypeAttr.parse_parameter(parser)
        )
        parser.parse_punctuation(",")
        parser.parse_keyword("capture_clause")
        parser.parse_punctuation("=")
        capture = DeclareTargetCaptureClauseAttr(
            DeclareTargetCaptureClauseAttr.parse_parameter(parser)
        )
        return [device_type, capture]

print_parameters(printer: Printer)

Source code in xdsl/dialects/omp.py
452
453
454
455
456
457
def print_parameters(self, printer: Printer):
    with printer.in_angle_brackets():
        printer.print_string("device_type = ")
        self.device_type.print_parameter(printer)
        printer.print_string(", capture_clause = ")
        self.capture_clause.print_parameter(printer)

ClauseRequiresKindAttr dataclass

Bases: EnumAttribute[ClauseRequiresKind], SpacedOpaqueSyntaxAttribute

Implementation of upstream omp.clause_requires See external documentation.

Source code in xdsl/dialects/omp.py
460
461
462
463
464
465
466
467
468
469
@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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
@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
483
484
485
486
487
488
@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
490
491
492
493
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
@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
507
508
509
510
511
512
513
@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
515
516
517
518
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
521
522
523
@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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
@irdl_op_definition
class LoopNestOp(IRDLOperation):
    name = "omp.loop_nest"

    lowerBound = var_operand_def(base(IntegerType) | base(IndexType))
    upperBound = var_operand_def(base(IntegerType) | base(IndexType))
    step = var_operand_def(base(IntegerType) | base(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(base(IntegerType) | base(IndexType)) class-attribute instance-attribute

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

step = var_operand_def(base(IntegerType) | base(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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
@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(RangeOf(AnyAttr()).of_length(LINEAR_COUNT))
    linear_step_vars = var_operand_def(RangeOf(eq(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(RangeOf(AnyAttr()).of_length(REDUCTION_COUNT))
    schedule_chunk = opt_operand_def()

    reduction_syms = opt_prop_def(
        ArrayAttr.constr(RangeOf(base(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=base(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(RangeOf(AnyAttr()).of_length(LINEAR_COUNT)) class-attribute instance-attribute

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

private_vars = var_operand_def() class-attribute instance-attribute

reduction_vars = var_operand_def(RangeOf(AnyAttr()).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(base(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=base(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
583
584
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
587
588
589
590
591
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
594
595
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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
@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(base(IntegerType) | base(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(base(IntegerType) | base(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
625
626
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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
@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
660
661
662
663
664
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
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
@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())

    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()) 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
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
@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
714
715
716
717
718
@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
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
@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(
        RangeOf(
            AnyAttr(),  # TODO: OpenMP_PointerLikeTypeInterface
        ).of_length(DEP_COUNT)
    )
    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(base(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(RangeOf(AnyAttr()).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(base(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
765
766
767
768
769
770
771
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
773
774
775
776
777
778
779
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
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
@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
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
@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
833
834
835
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
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
@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(
        RangeOf(
            AnyAttr(),  # TODO: OpenMP_PointerLikeTypeInterface
        ).of_length(ALIGN_COUNT)
    )
    if_expr = opt_operand_def(i1)
    linear_vars = var_operand_def(RangeOf(AnyAttr()).of_length(LINEAR_COUNT))
    linear_step_vars = var_operand_def(RangeOf(eq(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(base(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=eq(i64)))
    safelen = opt_prop_def(IntegerAttr.constr(value=AtLeast(1), type=eq(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(RangeOf(AnyAttr()).of_length(ALIGN_COUNT)) class-attribute instance-attribute

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

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

linear_step_vars = var_operand_def(RangeOf(eq(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(base(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=eq(i64))) class-attribute instance-attribute

safelen = opt_prop_def(IntegerAttr.constr(value=AtLeast(1), type=eq(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
881
882
def num_block_args(self) -> int:
    return len(self.private_vars) + len(self.reduction_vars)

verify_() -> None

Source code in xdsl/dialects/omp.py
884
885
886
887
888
889
890
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
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
@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
921
922
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
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
@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
950
951
def num_block_args(self) -> int:
    return len(self.private_vars)

verify_() -> None

Source code in xdsl/dialects/omp.py
953
954
955
956
957
958
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
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
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(
        RangeOf(
            AnyAttr(),  # TODO: OpenMP_PointerLikeTypeInterface
        ).of_length(DEP_COUNT)
    )
    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(base(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(RangeOf(AnyAttr()).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(base(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
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
@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
 995
 996
 997
 998
 999
1000
1001
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
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
@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
1013
1014
1015
1016
1017
1018
1019
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
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
@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[Operand, 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
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
def verify_(self) -> None:
    verify_map_vars(
        self.mapped_vars,
        self.name,
        disallowed_types=[ClauseMapFlags.DELETE],
    )
    mapped = defaultdict[Operand, 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
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
@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
1070
1071
1072
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
1074
1075
1076
1077
1078
1079
1080
def verify_(self) -> None:
    verify_map_vars(
        self.mapped_vars,
        self.name,
        disallowed_types=[ClauseMapFlags.DELETE],
    )
    return super().verify_()

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

Source code in xdsl/dialects/omp.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
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}")