From d35f659d25ae9c0721f30df89dfe01c2148297a8 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 9 Aug 2020 20:03:34 +0100 Subject: [PATCH] compiler: Add additional math fns available from Rust libm --- artiq/compiler/math_fns.py | 9 +++++++++ artiq/test/coredevice/test_numpy.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/artiq/compiler/math_fns.py b/artiq/compiler/math_fns.py index e29c3625b..6b1890c1d 100644 --- a/artiq/compiler/math_fns.py +++ b/artiq/compiler/math_fns.py @@ -15,6 +15,7 @@ unary_fp_intrinsics = [(name, "llvm." + name + ".f64") for name in [ "floor", "ceil", "trunc", + "sqrt", ]] + [ # numpy.rint() seems to (NumPy 1.19.0, Python 3.8.5, Linux x86_64) # implement round-to-even, but unfortunately, rust-lang/libm only @@ -36,6 +37,14 @@ unary_fp_runtime_calls = [ ("arcsin", "asin"), ("arccos", "acos"), ("arctan", "atan"), + ("sinh", "sinh"), + ("cosh", "cosh"), + ("tanh", "tanh"), + ("arcsinh", "asinh"), + ("arccosh", "acosh"), + ("arctanh", "atanh"), + ("expm1", "expm1"), + ("cbrt", "cbrt"), ] #: Array handling builtins (special treatment due to allocations). diff --git a/artiq/test/coredevice/test_numpy.py b/artiq/test/coredevice/test_numpy.py index 715aedaea..6fb4ee3dd 100644 --- a/artiq/test/coredevice/test_numpy.py +++ b/artiq/test/coredevice/test_numpy.py @@ -35,7 +35,7 @@ class CompareHostDeviceTest(ExperimentCase): nonlocal checked checked = True self.assertTrue( - numpy.allclose(host, device), + numpy.allclose(host, device, equal_nan=True), "Discrepancy in binop test for '{}': Expexcted ({}, {}) -> {}, got {}" .format(op, a, b, host, device)) @@ -56,7 +56,7 @@ class CompareHostDeviceTest(ExperimentCase): nonlocal checked checked = True self.assertTrue( - numpy.allclose(host, device), + numpy.allclose(host, device, equal_nan=True), "Discrepancy in unaryop test for '{}': Expexcted {} -> {}, got {}" .format(op, a, host, device))