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

Add CUDA backend for numeric limits

parent 10def05e
No related branches found
No related tags found
1 merge request!438Reduction Support
Pipeline #73151 failed
......@@ -28,7 +28,8 @@ from ..ast.expressions import (
from ..ast.expressions import PsLt, PsAnd
from ...types import PsSignedIntegerType, PsIeeeFloatType
from ..literals import PsLiteral
from ..functions import PsMathFunction, MathFunctions, CFunction, PsReductionFunction, ReductionFunctions
from ..functions import PsMathFunction, MathFunctions, CFunction, PsReductionFunction, ReductionFunctions, \
NumericLimitsFunctions
if TYPE_CHECKING:
from ...codegen import GpuIndexingConfig, GpuThreadsRange
......@@ -64,7 +65,7 @@ class CudaPlatform(GenericGpu):
@property
def required_headers(self) -> set[str]:
return {'"gpu_defines.h"'}
return {'"gpu_defines.h"', "<cuda/std/limits>"}
def materialize_iteration_space(
self, body: PsBlock, ispace: IterationSpace
......@@ -83,6 +84,9 @@ class CudaPlatform(GenericGpu):
dtype = call.get_dtype()
arg_types = (dtype,) * func.num_args
if isinstance(dtype, PsScalarType) and func in (NumericLimitsFunctions.Min, NumericLimitsFunctions.Max):
return PsLiteralExpr(PsLiteral(f"::cuda::std::numeric_limits<{dtype.c_string()}>::{func.function_name}()", dtype))
if isinstance(dtype, PsIeeeFloatType):
match func:
case (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment