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 b6d7dd551bb70b799241cb0ca6257fd48b57a3d6..affeb34d48ae4fc25777f34ceebb17a42e6a6286 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: