From 5caafdd05712621bc990ce7ef13c08f232f260af Mon Sep 17 00:00:00 2001 From: zy69guqi <richard.angersbach@fau.de> Date: Mon, 10 Feb 2025 15:13:51 +0100 Subject: [PATCH] Add guard for INFINITY numeric limit macro used by cuda backend --- src/pystencils/backend/platforms/cuda.py | 3 +-- src/pystencils/include/gpu_defines.h | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pystencils/backend/platforms/cuda.py b/src/pystencils/backend/platforms/cuda.py index 1a8fdc482..1af8917cc 100644 --- a/src/pystencils/backend/platforms/cuda.py +++ b/src/pystencils/backend/platforms/cuda.py @@ -90,8 +90,7 @@ class CudaPlatform(GenericGpu): assert isinstance(dtype, PsIeeeFloatType) defines = { NumericLimitsFunctions.Min: "NEG_INFINITY", NumericLimitsFunctions.Max: "POS_INFINITY" } - return PsLiteralExpr( - PsLiteral(defines[func.function_name], dtype)) + return PsLiteralExpr(PsLiteral(defines[func], dtype)) if isinstance(dtype, PsIeeeFloatType): match func: diff --git a/src/pystencils/include/gpu_defines.h b/src/pystencils/include/gpu_defines.h index 04eeace47..8f961e25b 100644 --- a/src/pystencils/include/gpu_defines.h +++ b/src/pystencils/include/gpu_defines.h @@ -1,8 +1,10 @@ #pragma once #define POS_INFINITY __int_as_float(0x7f800000) -#define INFINITY POS_INFINITY #define NEG_INFINITY __int_as_float(0xff800000) +#ifndef INFINITY +#define INFINITY POS_INFINITY +#endif #ifdef __HIPCC_RTC__ typedef __hip_uint8_t uint8_t; -- GitLab