diff --git a/pyopencl/characterize/__init__.py b/pyopencl/characterize/__init__.py index a671c09507855af15f4b24c35dfb9feba3ff2c1b..e4676a68d4aacc06ba4073664ab0925cbe30c366 100644 --- a/pyopencl/characterize/__init__.py +++ b/pyopencl/characterize/__init__.py @@ -320,3 +320,15 @@ def get_simd_group_size(dev, type_size): return 1 return None + + +def has_struct_arg_count_bug(dev): + """Checks whether the device is expected to have the + `argument counting bug <https://github.com/pocl/pocl/issues/197>`_. + """ + + if dev.platform.name == "Apple" and dev.type & cl.device_type.CPU: + return True + if dev.platform.name == "Portable Computing Language": + return True + return False diff --git a/test/test_algorithm.py b/test/test_algorithm.py index 88c3097bdbbb3e5c96ab1de1d868dbcef0eddc33..5518d508e01910126143602f34fca40dcc954485 100644 --- a/test/test_algorithm.py +++ b/test/test_algorithm.py @@ -327,8 +327,13 @@ def test_dot(ctx_factory): context = ctx_factory() queue = cl.CommandQueue(context) + dev = context.devices[0] + from pyopencl.characterize import has_struct_arg_count_bug + if has_struct_arg_count_bug(dev): + pytest.xfail("device has struct arg counting bug") + dtypes = [np.float32, np.complex64] - if has_double_support(context.devices[0]): + if has_double_support(dev): dtypes.extend([np.float64, np.complex128]) for a_dtype in dtypes: diff --git a/test/test_array.py b/test/test_array.py index ecfd3ba97a027278ffb4c317c5180d49cd25695e..adb2f74482f7d86023c6d69a1abb28c4648da5f2 100644 --- a/test/test_array.py +++ b/test/test_array.py @@ -95,6 +95,11 @@ def test_mix_complex(ctx_factory): context = ctx_factory() queue = cl.CommandQueue(context) + dev = context.devices[0] + from pyopencl.characterize import has_struct_arg_count_bug + if has_struct_arg_count_bug(dev): + pytest.xfail("device has struct arg counting bug") + size = 10 dtypes = [ @@ -169,6 +174,9 @@ def test_pow_neg1_vs_inv(ctx_factory): if not has_double_support(device): from pytest import skip skip("double precision not supported on %s" % device) + from pyopencl.characterize import has_struct_arg_count_bug + if has_struct_arg_count_bug(device): + pytest.xfail("device has struct arg counting bug") a_dev = make_random_array(queue, np.complex128, 20000) diff --git a/test/test_clmath.py b/test/test_clmath.py index 64af63d48ab030bce336bc2697f72c48a4948950..4173180e5a0eb3af1be7d8511f12c4a28f5f79cb 100644 --- a/test/test_clmath.py +++ b/test/test_clmath.py @@ -76,6 +76,11 @@ def make_unary_function_test(name, limits=(0, 1), threshold=0, use_complex=False gpu_func = getattr(clmath, name) cpu_func = getattr(np, numpy_func_names.get(name, name)) + dev = context.devices[0] + from pyopencl.characterize import has_struct_arg_count_bug + if use_complex and has_struct_arg_count_bug(dev): + pytest.xfail("device has struct arg counting bug") + if has_double_support(context.devices[0]): if use_complex: dtypes = [np.float32, np.float64, np.complex64, np.complex128] diff --git a/test/test_wrapper.py b/test/test_wrapper.py index 01382ec61648b8e3ed74cc75b42d4bdc450f922f..c5bd45c0210555911a4f10f95b8e818acdf7c3fc 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -27,6 +27,7 @@ THE SOFTWARE. import numpy as np import numpy.linalg as la +import pytest import pyopencl as cl import pyopencl.array as cl_array @@ -675,6 +676,10 @@ def test_enqueue_task(ctx_factory): def test_platform_get_devices(platform): + if platform.name == "Apple": + pytest.xfail("Apple doesn't understand all the values we pass " + "for dev_type") + dev_types = [cl.device_type.ACCELERATOR, cl.device_type.ALL, cl.device_type.CPU, cl.device_type.DEFAULT, cl.device_type.GPU] if (platform._get_cl_version() >= (1, 2) and