[arrayfire] 144/408: BUGFIX in randn for apple systems

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository arrayfire.

commit 3fb199d0c90d33c566274d950bba0ea60e88c497
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Mon Jul 13 17:33:55 2015 -0400

    BUGFIX in randn for apple systems
    
    - A really ugly hack because the proper version fails on OSX for no reason
---
 src/backend/opencl/kernel/random.cl  | 9 +++++++--
 src/backend/opencl/kernel/random.hpp | 4 ++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/backend/opencl/kernel/random.cl b/src/backend/opencl/kernel/random.cl
index 5debf52..d6d0f1f 100644
--- a/src/backend/opencl/kernel/random.cl
+++ b/src/backend/opencl/kernel/random.cl
@@ -241,8 +241,13 @@ void generate(T *one, T *two, threefry2_ctr_t *c, threefry2_key_t k)
     T u1 = result(r.v[0]);
     T u2 = result(r.v[1]);
 
-    T R     = sqrt(-2*log(u1));
-    T Theta = 2 * PI_VAL * u2;
+#if defined(IS_APPLE) // Because Apple is.. "special"
+    T R     = sqrt((T)(-2.0) * log10(u1) * (T)log10_val);
+#else
+    T R     = sqrt((T)(-2.0) * log(u1));
+#endif
+
+    T Theta = 2 * (T)PI_VAL * u2;
 
     *one = R * sin(Theta);
     *two = R * cos(Theta);
diff --git a/src/backend/opencl/kernel/random.hpp b/src/backend/opencl/kernel/random.hpp
index a903e39..f951797 100644
--- a/src/backend/opencl/kernel/random.hpp
+++ b/src/backend/opencl/kernel/random.hpp
@@ -106,6 +106,10 @@ namespace opencl
                         std::ostringstream options;
                         options << " -D T=" << dtype_traits<T>::getName()
                                 << " -D repeat="<< REPEAT
+#if defined(OS_MAC) // Because apple is "special"
+                                << " -D IS_APPLE"
+                                << " -D log10_val=" << std::log(10.0)
+#endif
                                 << " -D " << random_name<T, isRandu>().name();
 
                         if (std::is_same<T, double>::value) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list