From 97ac016b1dfbe1d603532a1bdb347882b7e22bc2 Mon Sep 17 00:00:00 2001 From: Isuru Fernando <isuruf@gmail.com> Date: Thu, 3 Nov 2022 10:26:16 -0500 Subject: [PATCH] use opencl fma builtin --- pyopencl/cl/pyopencl-complex.h | 6 +++--- test/test_clmath.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyopencl/cl/pyopencl-complex.h b/pyopencl/cl/pyopencl-complex.h index c33cbca0..892b5868 100644 --- a/pyopencl/cl/pyopencl-complex.h +++ b/pyopencl/cl/pyopencl-complex.h @@ -77,11 +77,11 @@ ; \ } \ \ - inline TP TPROOT##_muladd(TP a, TP b, TP c) \ + inline TP TPROOT##_fma(TP a, TP b, TP c) \ { \ return TPROOT##_new( \ - (c.real + a.real*b.real) - a.imag*b.imag, \ - (c.imag + a.real*b.imag) + a.imag*b.real); \ + fma(a.real, b.real, c.real) - a.imag*b.imag, \ + fma(a.imag, b.real, fma(a.real, b.imag, c.imag))); \ } \ \ inline TP TPROOT##_mul(TP a, TP b) \ diff --git a/test/test_clmath.py b/test/test_clmath.py index b640e0bb..55d14194 100644 --- a/test/test_clmath.py +++ b/test/test_clmath.py @@ -488,7 +488,7 @@ def test_complex_muladd(ctx_factory, dtype): ) {{ int gid = get_global_id(0); - res[gid] = c{real_type_name}_muladd(a[gid], b[gid], c[gid]); + res[gid] = c{real_type_name}_fma(a[gid], b[gid], c[gid]); }} """.format(real_type_name=real_type_name) -- GitLab