diff --git a/pyopencl/clrandom.py b/pyopencl/clrandom.py index 795474b3d1cafbebe9a0a146b4b98c1a2aeb5afc..10fb8aea1a93fc000d6fec61ce98f8b13a7d5bd6 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;