code: def _check_arg_size(function_name, num_cl_args, arg_types, devs):
      """Check whether argument sizes exceed the OpenCL device limit."""
  
      for dev in devs:
          dev_ptr_size = int(dev.address_bits / 8)
          dev_limit = _get_max_parameter_size(dev)
  
          total_arg_size = 0
  
          is_estimate = False
  
          if arg_types:
              for arg_type in arg_types:
                  if arg_type is None:
                      is_estimate = True
                      total_arg_size += dev_ptr_size
                  elif isinstance(arg_type, VectorArg):
                      total_arg_size += dev_ptr_size
                  else:
                      total_arg_size += np.dtype(arg_type).itemsize
          else:
              # Estimate that each argument has the size of a pointer on average
              is_estimate = True
              total_arg_size = dev_ptr_size * num_cl_args
  
          if total_arg_size > dev_limit:
              from warnings import warn
  
              warn(
                  f"Kernel '{function_name}' has {num_cl_args} arguments with "
                  f"a total size of {total_arg_size} bytes, which is higher than "
                  f"the limit of {dev_limit} bytes on {dev}. This might "
                  "lead to compilation errors, especially on GPU devices.",
                  stacklevel=3,
              )
          elif is_estimate and total_arg_size >= dev_limit * 0.75:
              # Since total_arg_size is just an estimate, also warn in case we are
              # just below the actual limit.
              from warnings import warn
  
              warn(
                  f"Kernel '{function_name}' has {num_cl_args} arguments with "
                  f"a total size of {total_arg_size} bytes, which approaches "
                  f"the limit of {dev_limit} bytes on {dev}. This might "
                  "lead to compilation errors, especially on GPU devices.",
                  stacklevel=3,
              )
  
file_path: pyopencl/pyopencl/invoker.py
imports: import numpy
  from warnings import warn
  import pyopencl._cl
  from pytools.persistent_dict import WriteOncePersistentDict
  from pytools.py_codegen import Indentation, PythonCodeGenerator
  from pyopencl.tools import _NumpyTypesKeyBuilder, VectorArg
  import pyopencl
label_desc: Use image node_id 5 for calling a global function with example usage: _check_arg_size(function_name, num_cl_args, arg_types, devs) without return types