code: def get_kernel(base_name, options=None):
      attributes = drv.Context.get_device().get_attributes()
      major = attributes[drv.device_attribute.COMPUTE_CAPABILITY_MAJOR]
      minor = attributes[drv.device_attribute.COMPUTE_CAPABILITY_MINOR]
      if major < 5:
          raise RuntimeError(
              "sass kernels require Maxwell or greater class hardware"
          )
  
      arch = "sm_%d%d" % (major, minor)
  
      libprefix = "PERL5LIB=%s" % (maxas_dir)
      maxas_i = [
          libprefix,
          os.path.join(maxas_dir, "maxas.pl") + " -i -w",
      ]
      maxas_p = [libprefix, os.path.join(maxas_dir, "maxas.pl") + " -p"]
  
      kernel_spec = kernels[base_name]
      kernel_name = base_name
  
      if "args" in kernel_spec:
          for pair in kernel_spec["args"].items():
              maxas_i.append("-D%s %s" % pair)
              maxas_p.append("-D%s %s" % pair)
  
      if options is not None:
          for opt in options:
              if type(opt) is tuple:
                  maxas_i.append("-D%s %s" % opt)
                  maxas_p.append("-D%s %s" % opt)
                  kernel_name += "_%s%s" % opt
              else:
                  maxas_i.append("-D%s 1" % opt)
                  maxas_p.append("-D%s 1" % opt)
                  kernel_name += "_%s" % opt
  
      maxas_i.insert(2, "-k " + kernel_name)
  
      sass_name = kernel_spec["sass"] + ".sass"
      cubin_name = kernel_name + ".cubin"
  
      ptx_version = "4.2" if major < 6 else "5.0"
      ptx_file = get_ptx_file(
          kernel_spec, kernel_name, arch, ptx_version
      )
      sass_file = os.path.join(sass_dir, sass_name)
      cubin_file = os.path.join(cubin_dir, cubin_name)
  
      if not os.path.exists(sass_file):
          raise RuntimeError(
              "Missing: %s for kernel: %s" % (sass_name, kernel_name)
          )
  
      ptx_age = os.path.getmtime(ptx_file)
      cubin_age = (
          os.path.getmtime(cubin_file)
          if os.path.exists(cubin_file)
          else 0
      )
  
      if ptx_age > cubin_age:
          run_command(
              ["ptxas -v -arch", arch, "-o", cubin_file, ptx_file]
          )
          cubin_age = 0
  
      includes = extract_includes(sass_name)
  
      for include, include_age in includes:
          if include_age > cubin_age:
              run_command(maxas_i + [sass_file, cubin_file])
              cubin_age = include_age
              break
  
      if debug:
          pre_file = os.path.join(pre_dir, kernel_name + "_pre.sass")
          dump_file = os.path.join(dump_dir, kernel_name + "_dump.sass")
          pre_age = (
              os.path.getmtime(pre_file)
              if os.path.exists(pre_file)
              else 0
          )
          dump_age = (
              os.path.getmtime(dump_file)
              if os.path.exists(dump_file)
              else 0
          )
  
          for include, include_age in includes:
              if include_age > pre_age:
                  run_command(maxas_p + [sass_file, pre_file])
                  break
  
          if cubin_age > dump_age:
              run_command(["nvdisasm -raw", cubin_file, ">", dump_file])
  
      params = _params[kernel_spec["params"]]
      sig = ""
      for p in params:
          ptype, pname = _space_re.split(p)
          if ptype[-1] == "*":
              sig += "Q"
          elif ptype == "float":
              sig += "f"
          elif ptype == "unsigned":
              sig += "I"
          else:
              sig += "i"
  
      module = drv.module_from_file(
          os.path.join(cubin_dir, kernel_name + ".cubin")
      )
      func = module.get_function(kernel_name)
      func.prepare(sig)
      func.threads = kernel_spec["threads"]
      return func
  
file_path: neon/neon/backends/kernel_specs.py
imports: from builtins import str
  import re
  import os.path
  import subprocess
  import pycuda.driver
  from pycuda.tools import context_dependent_memoize
  from neon import logger
  from neon.util.persist import get_cache_dir
label_desc: Use image node_id 4 for calling a global function with example usage: get_kernel(base_name, options) and returns: func