From 0b3f610c79d61c7464d88572f74e4fd346841833 Mon Sep 17 00:00:00 2001 From: Syam Gadde <gadde@biac.duke.edu> Date: Thu, 13 Jul 2017 16:50:22 -0400 Subject: [PATCH] Fixes for single-precision-only devices. --- pyopencl/clrandom.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pyopencl/clrandom.py b/pyopencl/clrandom.py index 795474b3..10fb8aea 100644 --- a/pyopencl/clrandom.py +++ b/pyopencl/clrandom.py @@ -241,7 +241,10 @@ class RanluxGenerator(object): elif dtype == np.int64: assert distribution == "uniform" - bits = 64 + if self.support_double: + bits = 64 + else: + bits = 32 c_type = "long" rng_expr = ("(shift " "+ convert_long4((float) scale * gen) " @@ -524,6 +527,14 @@ class Random123GeneratorBase(object): src = """//CL// #include <%(header_name)s> + #ifndef M_PI + #ifdef M_PI_F + #define M_PI M_PI_F + #else + #define M_PI 3.14159265359f + #endif + #endif + typedef %(output_t)s output_t; typedef %(output_t)s4 output_vec_t; typedef %(gen_name)s_ctr_t ctr_t; -- GitLab