code: def compile_plain(
      source, options, keep, nvcc, cache_dir, target="cubin"
  ):
      from os.path import join
  
      assert target in ["cubin", "ptx", "fatbin"]
  
      if cache_dir:
          checksum = _new_md5()
  
          if "#include" in source:
              checksum.update(
                  preprocess_source(source, options, nvcc).encode(
                      "utf-8"
                  )
              )
          else:
              checksum.update(source.encode("utf-8"))
  
          for option in options:
              checksum.update(option.encode("utf-8"))
          checksum.update(get_nvcc_version(nvcc).encode("utf-8"))
          from pycuda.characterize import platform_bits
  
          checksum.update(str(platform_bits()).encode("utf-8"))
  
          cache_file = checksum.hexdigest()
          cache_path = join(cache_dir, cache_file + "." + target)
  
          try:
              cache_file = open(cache_path, "rb")
              try:
                  return cache_file.read()
              finally:
                  cache_file.close()
  
          except Exception:
              pass
  
      from tempfile import mkdtemp
  
      file_dir = mkdtemp()
      file_root = "kernel"
  
      cu_file_name = file_root + ".cu"
      cu_file_path = join(file_dir, cu_file_name)
  
      outf = open(cu_file_path, "w")
      outf.write(str(source))
      outf.close()
  
      if keep:
          options = options[:]
          options.append("--keep")
  
          print("*** compiler output in %s" % file_dir)
  
      cmdline = [nvcc, "--" + target] + options + [cu_file_name]
      result, stdout, stderr = call_capture_output(
          cmdline, cwd=file_dir, error_on_nonzero=False
      )
  
      try:
          result_f = open(
              join(file_dir, file_root + "." + target), "rb"
          )
      except OSError:
          no_output = True
      else:
          no_output = False
  
      if result != 0 or (no_output and (stdout or stderr)):
          if result == 0:
              from warnings import warn
  
              warn(
                  "PyCUDA: nvcc exited with status 0, but appears to have "
                  "encountered an error"
              )
          from pycuda.driver import CompileError
  
          raise CompileError(
              "nvcc compilation of %s failed" % cu_file_path,
              cmdline,
              stdout=stdout.decode("utf-8", "replace"),
              stderr=stderr.decode("utf-8", "replace"),
          )
  
      if stdout or stderr:
          lcase_err_text = (
              (stdout + stderr).decode("utf-8", "replace").lower()
          )
          from warnings import warn
  
          if (
              "demoted" in lcase_err_text
              or "demoting" in lcase_err_text
          ):
              warn(
                  "nvcc said it demoted types in source code it "
                  "compiled--this is likely not what you want.",
                  stacklevel=4,
              )
          warn(
              "The CUDA compiler succeeded, but said the following:\n"
              + (stdout + stderr).decode("utf-8", "replace"),
              stacklevel=4,
          )
  
      result_data = result_f.read()
      result_f.close()
  
      if cache_dir:
          outf = open(cache_path, "wb")
          outf.write(result_data)
          outf.close()
  
      if not keep:
          from os import listdir, unlink, rmdir
  
          for name in listdir(file_dir):
              unlink(join(file_dir, name))
          rmdir(file_dir)
  
      return result_data
  
imports: from pytools import memoize
  import os
  import sys
  from tempfile import mkstemp
  from os import unlink
  from pytools.prefork import call_capture_output
label_desc: Use image node_id 4 for calling a global function with example usage: compile_plain(source, options, keep, nvcc, cache_dir, target) and returns: result_data, cache_file