Skip to content
Snippets Groups Projects
Commit 4ae330dc authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Add C function selection for numeric limits functions

parent af855492
1 merge request!438Reduction Support
...@@ -3,8 +3,8 @@ from typing import Sequence ...@@ -3,8 +3,8 @@ from typing import Sequence
from pystencils.backend.ast.expressions import PsCall from pystencils.backend.ast.expressions import PsCall
from ..functions import CFunction, PsMathFunction, MathFunctions from ..functions import CFunction, PsMathFunction, MathFunctions, NumericLimitsFunctions
from ...types import PsIntegerType, PsIeeeFloatType from ...types import PsIntegerType, PsIeeeFloatType, PsScalarType
from .platform import Platform from .platform import Platform
from ..exceptions import MaterializationError from ..exceptions import MaterializationError
...@@ -62,7 +62,10 @@ class GenericCpu(Platform): ...@@ -62,7 +62,10 @@ class GenericCpu(Platform):
dtype = call.get_dtype() dtype = call.get_dtype()
arg_types = (dtype,) * func.num_args arg_types = (dtype,) * func.num_args
# TODO: numeric limits if isinstance(dtype, PsScalarType) and func in (NumericLimitsFunctions.Min, NumericLimitsFunctions.Max):
cfunc = CFunction(f"{dtype.c_string()}_{func.function_name}".capitalize(), arg_types, dtype)
call.function = cfunc
return call
if isinstance(dtype, PsIeeeFloatType) and dtype.width in (32, 64): if isinstance(dtype, PsIeeeFloatType) and dtype.width in (32, 64):
cfunc: CFunction cfunc: CFunction
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment