cuda.core.Linker#
- class cuda.core.Linker(
- options: LinkerOptions | None = None,
- *object_codes: ObjectCode,
Represent a linking machinery to link one or more object codes into
ObjectCode.This object provides a unified interface to multiple underlying linker libraries (such as nvJitLink or cuLink* from the CUDA driver).
- Parameters:
object_codes (
ObjectCode) – One or more ObjectCode objects to be linked.options (
LinkerOptions, optional) – Options for the linker. If not provided, default options will be used.
Methods
- __init__(*args, **kwargs)#
- get_error_log(self) str#
Get the error log generated by the linker.
- Returns:
The error log.
- Return type:
- get_info_log(self) str#
Get the info log generated by the linker.
- Returns:
The info log.
- Return type:
- link(
- self,
- target_type: ObjectCodeFormatType | str,
Link the provided object codes into a single output of the specified target type.
- Parameters:
target_type (ObjectCodeFormatType | str) – The type of the target output. Must be “cubin”, “ptx”, or “ltoir”. Linked LTOIR output requires
link_time_optimization=Trueand nvJitLink 13.3 or newer.- Returns:
ObjectCode– The linked object code of the specified target type... note:: – Ensure that input object codes were compiled with appropriate flags for linking (e.g., relocatable device code enabled).
A CUBIN produced with
incremental=Truecan be passed directly to anotherLinker, but it can still contain unresolved device references and should be finalized before execution."ltoir"output contains only the LTOIR carried by the inputs. Direct PTX and CUBIN inputs are rejected because they carry no LTOIR. FATBIN, host object, and library inputs are accepted but may carry no LTOIR, in which case they contribute nothing to the output.
- classmethod which_backend(cls) CompilerBackendType#
Return which linking backend will be used.
Returns
NVJITLINKwhen the nvJitLink library is available and meets the minimum version requirement, otherwiseDRIVER.Note
Prefer letting
Linkerdecide. Querywhich_backend()only when you need to dispatch based on input format (for example: choose PTX vs. LTOIR before constructing aLinker). The returned value names an implementation detail whose support matrix may shift across CTK releases.
Attributes
- handle#
Return the underlying handle object.
Note
The type of the returned object depends on the backend.
Caution
This handle is a Python object. To get the memory address of the underlying C handle, call
int(Linker.handle).
- is_closed#
Whether this linker has been closed.