Skip to content

Snitch

snitch

This dialect provides operations to target features of the Snitch[1] streaming architecture based on custom extensions to the RISC-V ISA. This dialect works on 'riscv' types directly as all arguments are of 'riscv.reg<>' type and it is meant to be as close as possible to the asm that aims at generating.

[1] https://pulp-platform.github.io/snitch/publications

Snitch = Dialect('snitch', [SsrSetDimensionBoundOp, SsrSetDimensionStrideOp, SsrSetDimensionSourceOp, SsrSetDimensionDestinationOp, SsrSetStreamRepetitionOp, SsrEnableOp, SsrDisableOp], [ReadableStreamType, WritableStreamType]) module-attribute

ReadableStreamType dataclass

Bases: ParametrizedAttribute, TypeAttribute, ContainerType[_StreamTypeElement], Generic[_StreamTypeElement]

Source code in xdsl/dialects/snitch.py
@irdl_attr_definition
class ReadableStreamType(
    ParametrizedAttribute,
    TypeAttribute,
    ContainerType[_StreamTypeElement],
    Generic[_StreamTypeElement],
):
    name = "snitch.readable"

    element_type: _StreamTypeElement

    def get_element_type(self) -> _StreamTypeElement:
        return self.element_type

    @staticmethod
    def constr(
        element_type: IRDLAttrConstraint[_StreamTypeElement] = AnyAttr(),
    ) -> ParamAttrConstraint[ReadableStreamType[_StreamTypeElement]]:
        return cast(
            ParamAttrConstraint[ReadableStreamType[_StreamTypeElement]],
            ParamAttrConstraint.get(ReadableStreamType, element_type),
        )

name = 'snitch.readable' class-attribute instance-attribute

element_type: _StreamTypeElement instance-attribute

get_element_type() -> _StreamTypeElement

Source code in xdsl/dialects/snitch.py
def get_element_type(self) -> _StreamTypeElement:
    return self.element_type

constr(element_type: IRDLAttrConstraint[_StreamTypeElement] = AnyAttr()) -> ParamAttrConstraint[ReadableStreamType[_StreamTypeElement]] staticmethod

Source code in xdsl/dialects/snitch.py
@staticmethod
def constr(
    element_type: IRDLAttrConstraint[_StreamTypeElement] = AnyAttr(),
) -> ParamAttrConstraint[ReadableStreamType[_StreamTypeElement]]:
    return cast(
        ParamAttrConstraint[ReadableStreamType[_StreamTypeElement]],
        ParamAttrConstraint.get(ReadableStreamType, element_type),
    )

WritableStreamType dataclass

Bases: ParametrizedAttribute, TypeAttribute, ContainerType[_StreamTypeElement], Generic[_StreamTypeElement]

Source code in xdsl/dialects/snitch.py
@irdl_attr_definition
class WritableStreamType(
    ParametrizedAttribute,
    TypeAttribute,
    ContainerType[_StreamTypeElement],
    Generic[_StreamTypeElement],
):
    name = "snitch.writable"

    element_type: _StreamTypeElement

    def get_element_type(self) -> _StreamTypeElement:
        return self.element_type

    @staticmethod
    def constr(
        element_type: IRDLAttrConstraint[_StreamTypeElement] = AnyAttr(),
    ) -> ParamAttrConstraint[WritableStreamType[_StreamTypeElement]]:
        return cast(
            ParamAttrConstraint[WritableStreamType[_StreamTypeElement]],
            ParamAttrConstraint.get(WritableStreamType, element_type),
        )

name = 'snitch.writable' class-attribute instance-attribute

element_type: _StreamTypeElement instance-attribute

get_element_type() -> _StreamTypeElement

Source code in xdsl/dialects/snitch.py
def get_element_type(self) -> _StreamTypeElement:
    return self.element_type

constr(element_type: IRDLAttrConstraint[_StreamTypeElement] = AnyAttr()) -> ParamAttrConstraint[WritableStreamType[_StreamTypeElement]] staticmethod

Source code in xdsl/dialects/snitch.py
@staticmethod
def constr(
    element_type: IRDLAttrConstraint[_StreamTypeElement] = AnyAttr(),
) -> ParamAttrConstraint[WritableStreamType[_StreamTypeElement]]:
    return cast(
        ParamAttrConstraint[WritableStreamType[_StreamTypeElement]],
        ParamAttrConstraint.get(WritableStreamType, element_type),
    )

SnitchResources dataclass

Bounds for resources provided by the Snitch architecture.

Source code in xdsl/dialects/snitch.py
@dataclass(frozen=True)
class SnitchResources:
    """
    Bounds for resources provided by the Snitch architecture.
    """

    # Number of dimensions supported by each data mover.
    dimensions: int = 4

dimensions: int = 4 class-attribute instance-attribute

__init__(dimensions: int = 4) -> None

SsrSetDimensionConfigOperation

Bases: IRDLOperation, ABC

A base class for Snitch operations that set a configuration value for a specific dimension handled by a streamer.

Source code in xdsl/dialects/snitch.py
class SsrSetDimensionConfigOperation(IRDLOperation, ABC):
    """
    A base class for Snitch operations that set a
    configuration value for a specific dimension handled by a streamer.
    """

    value = operand_def(IntRegisterType)
    dm = prop_def(IntAttr)
    dimension = prop_def(IntAttr)

    def __init__(
        self,
        value: OperandArg,
        dm: IntAttr,
        dimension: IntAttr,
    ):
        super().__init__(
            operands=[value],
            properties={
                "dm": dm,
                "dimension": dimension,
            },
        )

    def verify_(self) -> None:
        if self.dimension.data >= SnitchResources.dimensions:
            raise VerifyException(
                f"dimension attribute out of range [0..{SnitchResources.dimensions - 1}], "
                f"Snitch supports up to {SnitchResources.dimensions} dimensions per streamer"
            )

value = operand_def(IntRegisterType) class-attribute instance-attribute

dm = prop_def(IntAttr) class-attribute instance-attribute

dimension = prop_def(IntAttr) class-attribute instance-attribute

__init__(value: OperandArg, dm: IntAttr, dimension: IntAttr)

Source code in xdsl/dialects/snitch.py
def __init__(
    self,
    value: OperandArg,
    dm: IntAttr,
    dimension: IntAttr,
):
    super().__init__(
        operands=[value],
        properties={
            "dm": dm,
            "dimension": dimension,
        },
    )

verify_() -> None

Source code in xdsl/dialects/snitch.py
def verify_(self) -> None:
    if self.dimension.data >= SnitchResources.dimensions:
        raise VerifyException(
            f"dimension attribute out of range [0..{SnitchResources.dimensions - 1}], "
            f"Snitch supports up to {SnitchResources.dimensions} dimensions per streamer"
        )

SsrSetStreamConfigOperation

Bases: IRDLOperation, ABC

A base class for Snitch operations that set a configuration value for a streamer.

Source code in xdsl/dialects/snitch.py
class SsrSetStreamConfigOperation(IRDLOperation, ABC):
    """
    A base class for Snitch operations that set a
    configuration value for a streamer.
    """

    value = operand_def(IntRegisterType)
    dm = prop_def(IntAttr)

    def __init__(self, value: OperandArg, dm: IntAttr):
        super().__init__(
            operands=[value],
            properties={
                "dm": dm,
            },
        )

value = operand_def(IntRegisterType) class-attribute instance-attribute

dm = prop_def(IntAttr) class-attribute instance-attribute

__init__(value: OperandArg, dm: IntAttr)

Source code in xdsl/dialects/snitch.py
def __init__(self, value: OperandArg, dm: IntAttr):
    super().__init__(
        operands=[value],
        properties={
            "dm": dm,
        },
    )

SsrSetDimensionBoundOp dataclass

Bases: SsrSetDimensionConfigOperation

Set the bound for one of the dimensions handled by a specific streamer.

Source code in xdsl/dialects/snitch.py
@irdl_op_definition
class SsrSetDimensionBoundOp(SsrSetDimensionConfigOperation):
    """
    Set the bound for one of the dimensions handled by a
    specific streamer.
    """

    name = "snitch.ssr_set_dimension_bound"

name = 'snitch.ssr_set_dimension_bound' class-attribute instance-attribute

SsrSetDimensionStrideOp dataclass

Bases: SsrSetDimensionConfigOperation

Set the stride for one of the dimensions handled by a specific streamer.

Source code in xdsl/dialects/snitch.py
@irdl_op_definition
class SsrSetDimensionStrideOp(SsrSetDimensionConfigOperation):
    """
    Set the stride for one of the dimensions handled by a
    specific streamer.
    """

    name = "snitch.ssr_set_dimension_stride"

name = 'snitch.ssr_set_dimension_stride' class-attribute instance-attribute

SsrSetDimensionSourceOp dataclass

Bases: SsrSetDimensionConfigOperation

Set the data source for one of the dimensions handled by a specific streamer.

Source code in xdsl/dialects/snitch.py
@irdl_op_definition
class SsrSetDimensionSourceOp(SsrSetDimensionConfigOperation):
    """
    Set the data source for one of the dimensions handled by a
    specific streamer.
    """

    name = "snitch.ssr_set_dimension_source"

name = 'snitch.ssr_set_dimension_source' class-attribute instance-attribute

SsrSetDimensionDestinationOp dataclass

Bases: SsrSetDimensionConfigOperation

Set the data destination for one of the dimensions handled by a specific streamer.

Source code in xdsl/dialects/snitch.py
@irdl_op_definition
class SsrSetDimensionDestinationOp(SsrSetDimensionConfigOperation):
    """
    Set the data destination for one of the dimensions handled by a
    specific streamer.
    """

    name = "snitch.ssr_set_dimension_destination"

name = 'snitch.ssr_set_dimension_destination' class-attribute instance-attribute

SsrSetStreamRepetitionOp dataclass

Bases: SsrSetStreamConfigOperation

Setup repetition count for a specific data mover.

Source code in xdsl/dialects/snitch.py
@irdl_op_definition
class SsrSetStreamRepetitionOp(SsrSetStreamConfigOperation):
    """
    Setup repetition count for a specific data mover.
    """

    name = "snitch.ssr_set_stream_repetition"

name = 'snitch.ssr_set_stream_repetition' class-attribute instance-attribute

SsrEnableOp

Bases: IRDLOperation

Enable stream semantics.

Source code in xdsl/dialects/snitch.py
@irdl_op_definition
class SsrEnableOp(IRDLOperation):
    """
    Enable stream semantics.
    """

    name = "snitch.ssr_enable"

    streams = var_result_def(ReadableStreamType.constr() | WritableStreamType.constr())

    def __init__(self, stream_types: Sequence[Attribute]):
        super().__init__(result_types=[stream_types])

name = 'snitch.ssr_enable' class-attribute instance-attribute

streams = var_result_def(ReadableStreamType.constr() | WritableStreamType.constr()) class-attribute instance-attribute

__init__(stream_types: Sequence[Attribute])

Source code in xdsl/dialects/snitch.py
def __init__(self, stream_types: Sequence[Attribute]):
    super().__init__(result_types=[stream_types])

SsrDisableOp

Bases: IRDLOperation

Disable stream semantics.

Source code in xdsl/dialects/snitch.py
@irdl_op_definition
class SsrDisableOp(IRDLOperation):
    """
    Disable stream semantics.
    """

    name = "snitch.ssr_disable"

    def __init__(self):
        super().__init__()

name = 'snitch.ssr_disable' class-attribute instance-attribute

__init__()

Source code in xdsl/dialects/snitch.py
def __init__(self):
    super().__init__()