diff --git a/src/pystencils/backend/functions.py b/src/pystencils/backend/functions.py index 388160f3053e57c19d4edccadb08589d71064896..ea0d6cb9d188061f305b19760001860e2582e3d1 100644 --- a/src/pystencils/backend/functions.py +++ b/src/pystencils/backend/functions.py @@ -94,6 +94,16 @@ class MathFunctions(Enum): self.num_args = num_args +class NumericLimitsFunctions(MathFunctions): + """Numerical limits functions supported by the backend. + + Each platform has to materialize these functions to a concrete implementation. + """ + + min = ("min", 0) + max = ("max", 0) + + class PsMathFunction(PsFunction): """Homogenously typed mathematical functions.""" diff --git a/src/pystencils/backend/platforms/generic_cpu.py b/src/pystencils/backend/platforms/generic_cpu.py index 94fbfa0e1dce6aaf747134b21d946eac4dc023a6..7cb37870365b7f14375f81d002580bdcc637be13 100644 --- a/src/pystencils/backend/platforms/generic_cpu.py +++ b/src/pystencils/backend/platforms/generic_cpu.py @@ -43,7 +43,7 @@ class GenericCpu(Platform): @property def required_headers(self) -> set[str]: - return {"<math.h>"} + return {"<math.h>", "<climits.h"} def materialize_iteration_space( self, body: PsBlock, ispace: IterationSpace @@ -62,6 +62,8 @@ class GenericCpu(Platform): dtype = call.get_dtype() arg_types = (dtype,) * func.num_args + # TODO: numeric limits + if isinstance(dtype, PsIeeeFloatType) and dtype.width in (32, 64): cfunc: CFunction match func: