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
5 files
+ 63
22
Preferences
Compare changes
Files
5
from __future__ import annotations
from .generic_gpu import GenericGpu
from ..ast.expressions import PsExpression, PsLiteralExpr
from ..functions import PsFunction, NumericLimitsFunctions
from ..literals import PsLiteral
from ...types import PsType, PsIeeeFloatType
class CudaPlatform(GenericGpu):
"""Platform for the CUDA GPU taret."""
"""Platform for the CUDA GPU target."""
@property
def required_headers(self) -> set[str]:
return set()
return super().required_headers | {
'"npp.h"',
}
def resolve_numeric_limits(self, func: PsMathFunction, dtype: PsType) -> PsExpression:
assert isinstance(dtype, PsIeeeFloatType)
match func:
case NumericLimitsFunctions.Min:
define = f"NPP_MINABS_{dtype.width}F"
case NumericLimitsFunctions.Max:
define = f"NPP_MAXABS_{dtype.width}F"
case _:
raise MaterializationError(
f"Cannot materialize call to function {func}"
)
return PsLiteralExpr(PsLiteral(define, dtype))