singe-cuda-sys 0.1.0

Low-level FFI bindings for the CUDA driver and runtime APIs and the CUDA libraries that ship with them, such as NVRTC.
Documentation
/* automatically generated by rust-bindgen 0.72.1 */

/// Unsigned C `size_t`, used for byte counts and object sizes in the native ABI.
pub type size_t = ::core::ffi::c_ulong;
impl nvvmResult {
    /// The operation completed successfully.
    pub const NVVM_SUCCESS: nvvmResult = nvvmResult(0);
    /// NVVM could not allocate the required memory.
    pub const NVVM_ERROR_OUT_OF_MEMORY: nvvmResult = nvvmResult(1);
    /// NVVM could not create the program.
    pub const NVVM_ERROR_PROGRAM_CREATION_FAILURE: nvvmResult = nvvmResult(2);
    /// The input IR version is incompatible with the NVVM library.
    pub const NVVM_ERROR_IR_VERSION_MISMATCH: nvvmResult = nvvmResult(3);
    /// An input argument is invalid.
    pub const NVVM_ERROR_INVALID_INPUT: nvvmResult = nvvmResult(4);
    /// The program handle is invalid.
    pub const NVVM_ERROR_INVALID_PROGRAM: nvvmResult = nvvmResult(5);
    /// The input NVVM IR is invalid.
    pub const NVVM_ERROR_INVALID_IR: nvvmResult = nvvmResult(6);
    /// A compilation option is invalid.
    pub const NVVM_ERROR_INVALID_OPTION: nvvmResult = nvvmResult(7);
    /// The program contains no IR modules.
    pub const NVVM_ERROR_NO_MODULE_IN_PROGRAM: nvvmResult = nvvmResult(8);
    /// NVVM compilation failed; the program log contains diagnostics.
    pub const NVVM_ERROR_COMPILATION: nvvmResult = nvvmResult(9);
    /// The operation was cancelled.
    pub const NVVM_ERROR_CANCELLED: nvvmResult = nvvmResult(10);
}
/// NVVM API call result code.
#[repr(transparent)]
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct nvvmResult(pub ::core::ffi::c_uint);
singe_loader::functions! { crate::NVVM;
    /// Get the message string for the given [`nvvmResult`] code.
    ///
    /// # Parameters
    ///
    /// - `result`: NVVM API result code.
    pub fn nvvmGetErrorString(result: nvvmResult) -> *const ::core::ffi::c_char;
}
singe_loader::functions! { crate::NVVM;
    /// Get the NVVM version.
    ///
    /// # Parameters
    ///
    /// - `major`: NVVM major version number.
    /// - `minor`: NVVM minor version number.
    pub fn nvvmVersion(
        major: *mut ::core::ffi::c_int,
        minor: *mut ::core::ffi::c_int,
    ) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Get the NVVM IR version.
    ///
    /// # Parameters
    ///
    /// - `majorIR`: NVVM IR major version number.
    /// - `minorIR`: NVVM IR minor version number.
    /// - `majorDbg`: NVVM IR debug metadata major version number.
    /// - `minorDbg`: NVVM IR debug metadata minor version number.
    pub fn nvvmIRVersion(
        majorIR: *mut ::core::ffi::c_int,
        minorIR: *mut ::core::ffi::c_int,
        majorDbg: *mut ::core::ffi::c_int,
        minorDbg: *mut ::core::ffi::c_int,
    ) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Get the LLVM IR version guaranteed to be supported by NVVM.
    ///
    /// The valid arch strings are the ones supported by [`nvvmCompileProgram`].
    ///
    /// # Parameters
    ///
    /// - `arch`: Architecture string.
    /// - `major`: IR version number.
    pub fn nvvmLLVMVersion(
        arch: *const ::core::ffi::c_char,
        major: *mut ::core::ffi::c_int,
    ) -> nvvmResult;
}
/// Incomplete native type used by [`nvvmProgram`] handles. The native API owns its layout.
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _nvvmProgram {
    _unused: [u8; 0],
}
/// NVVM Program.
///
/// An opaque handle for a program.
pub type nvvmProgram = *mut _nvvmProgram;
singe_loader::functions! { crate::NVVM;
    /// Create a program, and set the value of its handle to `*prog`.
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    pub fn nvvmCreateProgram(prog: *mut nvvmProgram) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Destroy a program.
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    pub fn nvvmDestroyProgram(prog: *mut nvvmProgram) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Add a module level NVVM IR to a program.
    ///
    /// The `buffer` should contain an NVVM IR module. The module should have NVVM IR either in the LLVM 7.0.1 bitcode representation or in the LLVM 7.0.1 text representation. Support for reading the text representation of NVVM IR is deprecated and may be removed in a later version.
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    /// - `buffer`: NVVM IR module in the bitcode or text representation.
    /// - `size`: Size of the NVVM IR module.
    /// - `name`: Name of the NVVM IR module. If NULL, “<unnamed>” is used as the name.
    pub fn nvvmAddModuleToProgram(
        prog: nvvmProgram,
        buffer: *const ::core::ffi::c_char,
        size: size_t,
        name: *const ::core::ffi::c_char,
    ) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Add a module level NVVM IR to a program.
    ///
    /// The `buffer` should contain an NVVM IR module. The module should have NVVM IR in the LLVM 7.0.1 bitcode representation.
    ///
    /// A module added using this API is lazily loaded - the only symbols loaded are those that are required by module(s) loaded using nvvmAddModuleToProgram. It is an error for a program to have all modules loaded using this API. Compiler may also optimize entities in this module by making them internal to the linked NVVM IR module, making them eligible for other optimizations. Due to these optimizations, this API to load a module is more efficient and should be used where possible.
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    /// - `buffer`: NVVM IR module in the bitcode representation.
    /// - `size`: Size of the NVVM IR module.
    /// - `name`: Name of the NVVM IR module. If NULL, “<unnamed>” is used as the name.
    pub fn nvvmLazyAddModuleToProgram(
        prog: nvvmProgram,
        buffer: *const ::core::ffi::c_char,
        size: size_t,
        name: *const ::core::ffi::c_char,
    ) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Compile the NVVM program.
    ///
    /// The NVVM IR modules in the program will be linked at the IR level. The linked IR program is compiled to PTX.
    ///
    /// The target datalayout in the linked IR program is used to determine the address size (32bit vs 64bit).
    ///
    /// The valid compiler options are:
    ///
    /// * -g (enable generation of full debugging information). Full debug support is only valid with ‘-opt=0’. Debug support requires the input module to utilize NVVM IR Debug Metadata. Line number (line info) only generation is also enabled via NVVM IR Debug Metadata, there is no specific libNVVM API flag for that case.
    /// * -opt=
    ///
    ///   + 0 (disable optimizations)
    ///   + 3 (default, enable optimizations)
    /// * -arch=
    ///
    ///   + compute_75 (default)
    ///   + compute_80
    ///   + compute_87
    ///   + compute_89
    ///   + compute_90
    ///   + compute_90a
    ///   + compute_100
    ///   + compute_100a
    ///   + compute_100f
    ///   + compute_103
    ///   + compute_103a
    ///   + compute_103f
    ///   + compute_110
    ///   + compute_110a
    ///   + compute_110f
    ///   + compute_120
    ///   + compute_120a
    ///   + compute_120f
    ///   + compute_121
    ///   + compute_121a
    ///   + compute_121f
    /// * -ftz=
    ///
    ///   + 0 (default, preserve denormal values, when performing single-precision floating-point operations)
    ///   + 1 (flush denormal values to zero, when performing single-precision floating-point operations)
    /// * -prec-sqrt=
    ///
    ///   + 0 (use a faster approximation for single-precision floating-point square root)
    ///   + 1 (default, use IEEE round-to-nearest mode for single-precision floating-point square root)
    /// * -prec-div=
    ///
    ///   + 0 (use a faster approximation for single-precision floating-point division and reciprocals)
    ///   + 1 (default, use IEEE round-to-nearest mode for single-precision floating-point division and reciprocals)
    /// * -fma=
    ///
    ///   + 0 (disable FMA contraction)
    ///   + 1 (default, enable FMA contraction)
    /// * -jump-table-density=\[0-101\] Specify the case density percentage in switch statements, and use it as a minimal threshold to determine whether jump table(brx.idx instruction) will be used to implement a switch statement. Default value is 101. The percentage ranges from 0 to 101 inclusively.
    /// * -gen-lto (Generate LTO IR instead of PTX).
    /// * -ptx-version-target=\[86-94\] Specify the target PTX version as (MAJOR VERSION \* 10 + MINOR VERSION). This is supported only for Blackwell and later architectures (compute capability compute_100 or greater). Using this option implies that the operations in incoming `prog` are compliant with targeted PTX version. If not set, highest available PTX version is used.
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    /// - `numOptions`: Number of compiler options passed.
    /// - `options`: Compiler options in the form of C string array.
    pub fn nvvmCompileProgram(
        prog: nvvmProgram,
        numOptions: ::core::ffi::c_int,
        options: *mut *const ::core::ffi::c_char,
    ) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Verify the NVVM program.
    ///
    /// The valid compiler options are:
    ///
    /// Same as for [`nvvmCompileProgram`].
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    /// - `numOptions`: Number of compiler options passed.
    /// - `options`: Compiler options in the form of C string array.
    pub fn nvvmVerifyProgram(
        prog: nvvmProgram,
        numOptions: ::core::ffi::c_int,
        options: *mut *const ::core::ffi::c_char,
    ) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Get the size of the compiled result.
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    /// - `bufferSizeRet`: Size of the compiled result (including the trailing NULL).
    pub fn nvvmGetCompiledResultSize(
        prog: nvvmProgram,
        bufferSizeRet: *mut size_t,
    ) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Get the compiled result.
    ///
    /// The result is stored in the memory pointed to by `buffer`.
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    /// - `buffer`: Compiled result.
    pub fn nvvmGetCompiledResult(
        prog: nvvmProgram,
        buffer: *mut ::core::ffi::c_char,
    ) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Get the Size of Compiler/Verifier Message.
    ///
    /// The size of the message string (including the trailing NULL) is stored into `bufferSizeRet` when the return value is [`nvvmResult::NVVM_SUCCESS`].
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    /// - `bufferSizeRet`: Size of the compilation/verification log (including the trailing NULL).
    pub fn nvvmGetProgramLogSize(
        prog: nvvmProgram,
        bufferSizeRet: *mut size_t,
    ) -> nvvmResult;
}
singe_loader::functions! { crate::NVVM;
    /// Get the Compiler/Verifier Message.
    ///
    /// The NULL terminated message string is stored in the memory pointed to by `buffer` when the return value is [`nvvmResult::NVVM_SUCCESS`].
    ///
    /// # Parameters
    ///
    /// - `prog`: NVVM program.
    /// - `buffer`: Compilation/Verification log.
    pub fn nvvmGetProgramLog(
        prog: nvvmProgram,
        buffer: *mut ::core::ffi::c_char,
    ) -> nvvmResult;
}