From 61f5245b020f9a35a06d50a36c47f15f5da37f0a Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Wed, 12 Jun 2013 00:38:57 -0400 Subject: [PATCH] Fix lots of broken device type queries --- pyopencl/characterize/__init__.py | 14 +++++++------- pyopencl/clrandom.py | 4 ++-- pyopencl/scan.py | 4 ++-- test/test_algorithm.py | 2 +- test/test_wrapper.py | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pyopencl/characterize/__init__.py b/pyopencl/characterize/__init__.py index eb6c9d01..8fd33a86 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 bae170f5..92a5c2de 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 4d1513bb..7ee47e35 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 ef28a015..fc31e8c5 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 4f6a1526..6c04d7d9 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) -- GitLab