cuda.core.Program#
- class cuda.core.Program(
- code,
- code_type,
- options: ProgramOptions = None,
Represent a compilation machinery to process programs into
ObjectCode.This object provides a unified interface to multiple underlying compiler libraries. Compilation support is enabled for a wide range of code types and compilation types.
- Parameters:
code (Any) – String of the CUDA Runtime Compilation program.
code_type (Any) – String of the code type. Currently
"ptx","c++", and"nvvm"are supported.options (ProgramOptions, optional) – A ProgramOptions object to customize the compilation process. See
ProgramOptionsfor more information.
Methods
- __init__(
- code,
- code_type,
- options: ProgramOptions = None,
- close()#
Destroy this program.
- compile(target_type, name_expressions=(), logs=None)#
Compile the program with a specific compilation type.
- Parameters:
target_type (Any) – String of the targeted compilation type. Supported options are “ptx”, “cubin” and “ltoir”.
name_expressions (Union[list, tuple], optional) – List of explicit name expressions to become accessible. (Default to no expressions)
logs (Any, optional) – Object with a write method to receive the logs generated from compilation. (Default to no logs)
- Returns:
Newly created code object.
- Return type:
- static from_handle(
- handle: int,
- backend: str,
- options: ProgramOptions = None,
Create a new
Programobject from a foreign program handle.Uses a nvrtcProgram or NVVM program handle represented as a Python int to create a new
Programobject.- Parameters:
handle (int) – Program handle representing the address of a foreign program object (nvrtcProgram for NVRTC backend, or NVVM program handle for NVVM backend).
backend (str) – The backend type of the program handle. Must be either “NVRTC” or “NVVM”. This determines how the handle is interpreted and used.
options (
ProgramOptions, optional) – Program options that may be used for subsequent operations. If not provided, default options will be created.
Attributes
- property handle: ProgramHandleT#
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(Program.handle).