Skip to content
Snippets Groups Projects

Reduction Support

Merged Richard Angersbach requested to merge rangersbach/reductions into v2.0-dev
Compare and Show latest version
5 files
+ 65
23
Preferences
Compare changes
Files
5
from __future__ import annotations
from __future__ import annotations
from .generic_gpu import GenericGpu
from .generic_gpu import GenericGpu
 
from ..ast.expressions import PsExpression, PsLiteralExpr
 
from ..exceptions import MaterializationError
 
from ..functions import NumericLimitsFunctions
 
from ..literals import PsLiteral
 
from ...types import PsType, PsIeeeFloatType
class CudaPlatform(GenericGpu):
class CudaPlatform(GenericGpu):
"""Platform for the CUDA GPU taret."""
"""Platform for the CUDA GPU target."""
@property
@property
def required_headers(self) -> set[str]:
def required_headers(self) -> set[str]:
return set()
return super().required_headers | {
 
'"npp.h"',
 
}
 
 
def resolve_numeric_limits(self, func: NumericLimitsFunctions, 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))