diff --git a/pyopencl/characterize/__init__.py b/pyopencl/characterize/__init__.py index eb6c9d01992543d1aed479559501f16882c42fbc..8fd33a86942d7991cae0951156c46c11809a986e 100644 --- a/pyopencl/characterize/__init__.py +++ b/pyopencl/characterize/__init__.py @@ -119,13 +119,13 @@ def simultaneous_work_items_on_local_access(dev): return 32 - if dev.type == cl.device_type.GPU: + if dev.type & cl.device_type.GPU: from warnings import warn warn("wildly guessing conflicting local access size on '%s'" % dev, CLCharacterizationWarning) return 16 - elif dev.type == cl.device_type.CPU: + elif dev.type & cl.device_type.CPU: return 1 else: from warnings import warn @@ -157,13 +157,13 @@ def local_memory_bank_count(dev): return 32 - if dev.type == cl.device_type.GPU: + if dev.type & cl.device_type.GPU: from warnings import warn warn("wildly guessing local memory bank count on '%s'" % dev, CLCharacterizationWarning) return 16 - elif dev.type == cl.device_type.CPU: + elif dev.type & cl.device_type.CPU: if dev.local_mem_type == cl.device_local_mem_type.GLOBAL: raise RuntimeError("asking for a bank count is " "meaningless for cache-based lmem") @@ -284,7 +284,7 @@ def get_simd_group_size(dev, type_size): return 32 if ("advanced micro" in lc_vendor or "ati" in lc_vendor): - if dev.type == cl.device_type.GPU: + if dev.type & cl.device_type.GPU: # Tomasz Rybak says, in response to reduction mishbehaving on the AMD # 'Loveland' APU: # @@ -303,12 +303,12 @@ def get_simd_group_size(dev, type_size): # This is therefore our best guess as to the SIMD group size. return reasonable_work_group_size_multiple(dev) - elif dev.type == cl.device_type.CPU: + elif dev.type & cl.device_type.CPU: return 1 else: raise RuntimeError("unexpected AMD device type") - if dev.type == cl.device_type.CPU: + if dev.type & cl.device_type.CPU: # implicit assumption: Impl. will vectorize if type_size == 1: diff --git a/pyopencl/clrandom.py b/pyopencl/clrandom.py index bae170f58a41b2b16cfa8bd5c9ddc19cff860810..92a5c2de4862ce17e79c7ededb6e4a29b7f8460f 100644 --- a/pyopencl/clrandom.py +++ b/pyopencl/clrandom.py @@ -105,7 +105,7 @@ class RanluxGenerator(object): luxury = 4 if num_work_items is None: - if queue.device.type == cl.device_type.CPU: + if queue.device.type & cl.device_type.CPU: num_work_items = 8 * queue.device.max_compute_units else: num_work_items = 64 * queue.device.max_compute_units @@ -151,7 +151,7 @@ class RanluxGenerator(object): if ("darwin" in sys.platform and "Apple" in queue.device.platform.vendor and platform.mac_ver()[0].startswith("10.7") - and queue.device.type == cl.device_type.CPU): + and queue.device.type & cl.device_type.CPU): wg_size = (1,) self.wg_size = wg_size diff --git a/pyopencl/scan.py b/pyopencl/scan.py index 4d1513bb90acdfb98e9f4db6db3743db7cbbbf94..7ee47e35579615b9a53e40c8aae836c9f3d016c3 100644 --- a/pyopencl/scan.py +++ b/pyopencl/scan.py @@ -1021,7 +1021,7 @@ class _GenericScanKernelBase(object): arg_ctypes=arg_ctypes, scan_expr=_process_code_for_macro(scan_expr), neutral=_process_code_for_macro(neutral), - is_gpu=self.devices[0].type == cl.device_type.GPU, + is_gpu=bool(self.devices[0].type & cl.device_type.GPU), double_support=all( has_double_support(dev) for dev in devices), ) @@ -1086,7 +1086,7 @@ class GenericScanKernel(_GenericScanKernelBase): if lmem_use + 256 <= avail_local_mem: solutions.append((wg_size*k_group_size, k_group_size, wg_size)) - if self.devices[0].type == cl.device_type.GPU: + if self.devices[0].type & cl.device_type.GPU: from pytools import any for wg_size_floor in [256, 192, 128]: have_sol_above_floor = any(wg_size >= wg_size_floor diff --git a/test/test_algorithm.py b/test/test_algorithm.py index ef28a0156e0fe46230a415dde2e4d714ff4ea315..fc31e8c540560fc5413ccf3e5fd8eac2c18b5945 100644 --- a/test/test_algorithm.py +++ b/test/test_algorithm.py @@ -628,7 +628,7 @@ def test_index_preservation(ctx_factory): classes = [GenericScanKernel] dev = context.devices[0] - if dev.type == cl.device_type.CPU: + if dev.type & cl.device_type.CPU: classes.append(GenericDebugScanKernel) for cls in classes: diff --git a/test/test_wrapper.py b/test/test_wrapper.py index 4f6a152660c80aae0635be4b30990a936590f177..6c04d7d9ab272f753957e7f0dbea98aed610e121 100644 --- a/test/test_wrapper.py +++ b/test/test_wrapper.py @@ -341,7 +341,7 @@ def test_image_2d(ctx_factory): good = la.norm(a_result - a) == 0 if not good: - if queue.device.type == cl.device_type.CPU: + if queue.device.type & cl.device_type.CPU: assert good, ("The image implementation on your CPU CL platform '%s' " "returned bad values. This is bad, but common." % queue.device.platform) @@ -417,7 +417,7 @@ def test_image_3d(ctx_factory): good = la.norm(a_result - a) == 0 if not good: - if queue.device.type == cl.device_type.CPU: + if queue.device.type & cl.device_type.CPU: assert good, ("The image implementation on your CPU CL platform '%s' " "returned bad values. This is bad, but common." % queue.device.platform)