cuda.core.utils.make_program_cache_key#
- cuda.core.utils.make_program_cache_key(
- *,
- code: str | bytes,
- code_type: str,
- options: ProgramOptions,
- target_type: str,
- name_expressions: Sequence[str | bytes | bytearray] = (),
- extra_digest: bytes | None = None,
Build a stable cache key from compile inputs.
- Parameters:
code – Source text.
stris encoded as UTF-8.code_type – One of
"c++","ptx","nvvm".options – A
cuda.core.ProgramOptions. Itsarchmust be set (the defaultProgramOptions.__post_init__populates it from the current device).target_type – One of
"ptx","cubin","ltoir".name_expressions – Optional iterable of mangled-name lookups. Order is not significant. Elements may be
str,bytes, orbytearray;"foo"andb"foo"produce distinct keys becauseProgram.compilerecords the original Python object as theObjectCode.symbol_mappingkey, andget_kernellookups must use the same type the cache key recorded.extra_digest – Caller-supplied bytes mixed into the key. Required whenever
cuda.core.ProgramOptionssets any option that pulls in external file content (include_path,pre_include,pch,use_pch,pch_dir) – the cache cannot read those files on the caller’s behalf, so the caller must fingerprint the header / PCH surface and pass it here. Callers may pass this for other inputs too (embedded kernels, generated sources, etc.).
- Returns:
A 32-byte blake2b digest suitable for use as a cache key.
- Return type:
- Raises:
ValueError – If
optionssets an option with compile-time side effects (such ascreate_pch) – a cache hit skips compilation, so the side effect would not occur.ValueError – If
extra_digestisNonewhileoptionssets any option whose compilation effect depends on external file content that the key cannot otherwise observe.