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; diff --git a/test/test_algorithm.py b/test/test_algorithm.py index 676390bd751116c334aa3a9425b92f7a32500fe3..5076e2b1c6ad53ab5ab24319068aee0b640d0726 100644 --- a/test/test_algorithm.py +++ b/test/test_algorithm.py @@ -906,6 +906,10 @@ def test_bitonic_sort(ctx_factory, size, dtype): and dtype == np.float64): pytest.xfail("Double precision bitonic sort doesn't work on POCL") + if dtype == np.float64 and not has_double_support(dev): + from pytest import skip + skip("double precision not supported on %s" % dev) + import pyopencl.clrandom as clrandom from pyopencl.bitonic_sort import BitonicSort @@ -950,6 +954,10 @@ def test_bitonic_argsort(ctx_factory, size, dtype): and dtype == np.float64): pytest.xfail("Double precision bitonic sort doesn't work on POCL") + if dtype == np.float64 and not has_double_support(dev): + from pytest import skip + skip("double precision not supported on %s" % dev) + import pyopencl.clrandom as clrandom from pyopencl.bitonic_sort import BitonicSort