code: def _get_full_machine_kernel_rate(
      queue, src, args, name="benchmark", timer_factory=None
  ):
      prg = cl.Program(queue.context, src).build()
  
      knl = getattr(prg, name)
  
      dev = queue.device
      global_size = 4 * dev.max_compute_units
  
      def f():
          knl(queue, (global_size,), None, *args)
  
      rates = []
      num_dips = 0
  
      while True:
          elapsed = _get_time(queue, f, timer_factory=timer_factory)
          rate = global_size / elapsed
  
          keep_trying = not rates
  
          if rates and rate > 1.05 * max(rates):  # big improvement
              keep_trying = True
              num_dips = 0
  
          if (
              rates and rate < 0.9 * max(rates) and num_dips < 3
          ):  # big dip
              keep_trying = True
              num_dips += 1
  
          if keep_trying:
              global_size *= 2
              rates.append(rate)
          else:
              rates.append(rate)
              return max(rates)
  
imports: import pyopencl
  import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: _get_full_machine_kernel_rate(queue, src, args, name, timer_factory) and returns: max