From 646ef15d8345a5d75002276dc23179afdee80fad Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 5 Mar 2023 07:18:12 -0500 Subject: [PATCH] more consistent way to disable fast math for Intel OpenCL with double precision --- lib/gpu/lal_device.cpp | 5 ++--- lib/gpu/lal_preprocessor.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/gpu/lal_device.cpp b/lib/gpu/lal_device.cpp index c98253ba4c..8d2211481d 100644 --- a/lib/gpu/lal_device.cpp +++ b/lib/gpu/lal_device.cpp @@ -391,10 +391,9 @@ int DeviceT::set_ocl_params(std::string s_config, const std::string &extra_args) #endif // workaround for double precision with Intel OpenCL #ifdef _DOUBLE_DOUBLE - if ((params[4] != "0") && (params[0] != "500")) _ocl_compile_string+="-cl-fast-relaxed-math "; - #else - if (params[4] != "0") _ocl_compile_string+="-cl-fast-relaxed-math "; + if (params[0] == "500") params[4] = "0"; #endif + if (params[4] != "0") _ocl_compile_string+="-cl-fast-relaxed-math "; _ocl_compile_string+=std::string(OCL_INT_TYPE)+" "+ std::string(OCL_PRECISION_COMPILE); if (gpu->has_subgroup_support()) diff --git a/lib/gpu/lal_preprocessor.h b/lib/gpu/lal_preprocessor.h index b3243c3b2e..30dec214e8 100644 --- a/lib/gpu/lal_preprocessor.h +++ b/lib/gpu/lal_preprocessor.h @@ -169,7 +169,7 @@ #define ucl_abs fabs #define ucl_erfc erfc -#if defined(FAST_MATH) && !defined(_DOUBLE_DOUBLE) +#if defined(FAST_MATH) && (FAST_MATH > 0) && !defined(_DOUBLE_DOUBLE) #define ucl_exp native_exp #define ucl_pow pow