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

Use std::numeric_limits as NumericLimitsFunctions backend for cpu

parent 2424c157
No related branches found
No related tags found
1 merge request!438Reduction Support
Pipeline #73008 failed
......@@ -44,7 +44,7 @@ class GenericCpu(Platform):
@property
def required_headers(self) -> set[str]:
return {"<math.h>", "<limits.h>", "<float.h>"}
return {"<math.h>", "<limits>"}
def materialize_iteration_space(
self, body: PsBlock, ispace: IterationSpace
......@@ -64,22 +64,7 @@ class GenericCpu(Platform):
arg_types = (dtype,) * func.num_args
if isinstance(dtype, PsScalarType) and func in (NumericLimitsFunctions.Min, NumericLimitsFunctions.Max):
# get type prefix for macro
# TODO: there must be a better way...
tpe = ""
match dtype:
case PsIeeeFloatType():
match dtype.width:
case 32:
tpe = "FLT"
case 64:
tpe = "DBL"
case _:
raise MaterializationError(
f"No implementation available for function {func} on data type {dtype}"
)
return PsLiteralExpr(PsLiteral(f"{tpe}_{func.function_name}".upper(), dtype))
return PsLiteralExpr(PsLiteral(f"std::numeric_limits<{dtype.c_string()}>::{func.function_name}()", dtype))
if isinstance(dtype, PsIeeeFloatType) and dtype.width in (32, 64):
cfunc: CFunction
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment