Skip to content
Snippets Groups Projects

Reduction Support

Open Richard Angersbach requested to merge rangersbach/reductions into v2.0-dev
Compare and Show latest version
7 files
+ 122
13
Preferences
Compare changes
Files
7
@@ -5,6 +5,7 @@ from typing import cast
from .astnode import PsAstNode
from .expressions import PsExpression, PsLvalue, PsUnOp
from .util import failing_cast
from ...sympyextensions import ReductionOp
from ...types import PsVectorType
@@ -42,6 +43,45 @@ class PsVecBroadcast(PsUnOp, PsVectorOp):
)
class PsVecHorizontal(PsUnOp, PsVectorOp):
"""Extracts scalar value from N vector lanes."""
__match_args__ = ("lanes", "operand", "operation")
def __init__(self, lanes: int, operand: PsExpression, reduction_op: ReductionOp):
super().__init__(operand)
self._lanes = lanes
self._reduction_operation = reduction_op
@property
def lanes(self) -> int:
return self._lanes
@lanes.setter
def lanes(self, n: int):
self._lanes = n
@property
def reduction_operation(self) -> ReductionOp:
return self._reduction_operation
@reduction_operation.setter
def reduction_operation(self, op: ReductionOp):
self._reduction_operation = op
def _clone_expr(self) -> PsVecHorizontal:
return PsVecHorizontal(self._lanes, self._operand.clone(), self._operation.clone())
def structurally_equal(self, other: PsAstNode) -> bool:
if not isinstance(other, PsVecHorizontal):
return False
return (
super().structurally_equal(other)
and self._lanes == other._lanes
and self._operation == other._operation
)
class PsVecMemAcc(PsExpression, PsLvalue, PsVectorOp):
"""Pointer-based vectorized memory access.