code: def get_simd_group_size(dev, type_size):
      """Return an estimate of how many work items will be executed across SIMD
      lanes. This returns the size of what Nvidia calls a warp and what AMD calls
      a wavefront.
  
      Only refers to implicit SIMD.
  
      :arg type_size: number of bytes in vector entry type.
      """
      try:
          return dev.warp_size_nv
      except Exception:
          pass
  
      lc_plat_vendor = dev.platform.vendor.lower()
      lc_dev_vendor = dev.vendor.lower()
      if "nvidia" in lc_plat_vendor or "nvidia" in lc_dev_vendor:
          return 32
  
      if (
          "advanced micro" in lc_plat_vendor
          or "ati" in lc_plat_vendor
          or "advanced micro" in lc_dev_vendor
          or "ati" in lc_dev_vendor
      ):
          if dev.type & cl.device_type.GPU:
              # Tomasz Rybak says, in response to reduction misbehaving on the AMD
              # 'Loveland' APU:
              #
              #    Like in CUDA reduction bug (related to Fermi) it again seems
              # to be related to too eager concurrency when reducing results.
              # According to http://oscarbg.blogspot.com/2009/10/news-from-web.html
              # "Actually the wavefront size is only 64 for the highend cards(48XX,
              # 58XX, 57XX), but 32 for the middleend cards and 16 for the lowend
              # cards."
              # IMO we should use PREFERRED_WORK_GROUP_SIZE_MULTIPLE to get
              # non_sync_size. At the same size we lose SIMD CPU optimisation,
              # but I do not know for now how to fix those two at the same time.
              # Attached patch fixes problem on Loveland, not breaking anything on
              # NVIDIA ION.
  
              # 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:
              return 1
          else:
              raise RuntimeError("unexpected AMD device type")
  
      if dev.type & cl.device_type.CPU:
          # implicit assumption: Impl. will vectorize
          return 1
  
      return None
  
imports: import pyopencl
  from pytools import memoize
  from typing import Dict, Optional, Tuple
label_desc: Use image node_id 11 for calling a global function with example usage: get_simd_group_size(dev, type_size) and returns: None, dev, int, int, reasonable_work_group_size_multiple, int