From 58b14e5c29a75e6c4eea95f09aa3e0cb51b86bbe Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 2 Sep 2026 11:43:09 -0400 Subject: [PATCH] BUG: Fix wrapping of nvrtcBundledHeadersInfo --- cuda_bindings/cuda/bindings/nvrtc.pxd | 53 +++----------- cuda_bindings/cuda/bindings/nvrtc.pyx | 71 +++++-------------- cuda_bindings/docs/source/module/nvrtc.rst | 3 +- .../tests/legacy_api/test_legacy_nvrtc.py | 18 +++++ cuda_bindings/tests/test_nvrtc.py | 17 +++++ 5 files changed, 63 insertions(+), 99 deletions(-) diff --git a/cuda_bindings/cuda/bindings/nvrtc.pxd b/cuda_bindings/cuda/bindings/nvrtc.pxd index a17faea0763..9952530ae9c 100644 --- a/cuda_bindings/cuda/bindings/nvrtc.pxd +++ b/cuda_bindings/cuda/bindings/nvrtc.pxd @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # This code was automatically generated with version 13.3.0. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=06a058e3c626563f034714cce129fd58b33dd80c0e4a954723e92d0ae61c7c58 +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=ee485e830fdb8037d58a70b73a413f3ce362819576fd86e91d55ce14ba3f9149 cimport cuda.bindings.cynvrtc as cynvrtc include "_lib/utils.pxd" @@ -21,69 +21,35 @@ cdef class nvrtcProgram: cdef cynvrtc.nvrtcProgram _pvt_val cdef cynvrtc.nvrtcProgram* _pvt_ptr -cdef class anon_struct0: +cdef class nvrtcBundledHeadersInfo: """ - Attributes - ---------- - - available : int - - - - compressedSize : size_t - - - - uncompressedSize : size_t - - - - cudaVersionMajor : int - - - - cudaVersionMinor : int - + Structure containing information about bundled headers. - - numFiles : unsigned int - - - - Methods - ------- - getPtr() - Get memory address of class instance - """ - cdef cynvrtc.nvrtcBundledHeadersInfo* _pvt_ptr - -cdef class nvrtcBundledHeadersInfo(anon_struct0): - """ Attributes ---------- available : int - + Non-zero if bundled headers are available compressedSize : size_t - + Size of compressed archive in bytes uncompressedSize : size_t - + Estimated size when extracted in bytes cudaVersionMajor : int - + CUDA major version of bundled headers cudaVersionMinor : int - + CUDA minor version of bundled headers numFiles : unsigned int - + Number of header files in the bundle Methods @@ -92,3 +58,4 @@ cdef class nvrtcBundledHeadersInfo(anon_struct0): Get memory address of class instance """ cdef cynvrtc.nvrtcBundledHeadersInfo _pvt_val + cdef cynvrtc.nvrtcBundledHeadersInfo* _pvt_ptr diff --git a/cuda_bindings/cuda/bindings/nvrtc.pyx b/cuda_bindings/cuda/bindings/nvrtc.pyx index 9864acce7af..ed656c9cd58 100644 --- a/cuda_bindings/cuda/bindings/nvrtc.pyx +++ b/cuda_bindings/cuda/bindings/nvrtc.pyx @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # This code was automatically generated with version 13.3.0. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=5d36f91a9f04660caaf0a8a7afa443d43899bc6eb70e61a26415485d9a39475a +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=9c30b7a3d79561c6721e7df7b758eaee6afdd2763d9692ff638815abb64417e0 from typing import Any, Optional import cython import ctypes @@ -141,33 +141,35 @@ cdef class nvrtcProgram: def getPtr(self): return self._pvt_ptr -cdef class anon_struct0: +cdef class nvrtcBundledHeadersInfo: """ + Structure containing information about bundled headers. + Attributes ---------- available : int - + Non-zero if bundled headers are available compressedSize : size_t - + Size of compressed archive in bytes uncompressedSize : size_t - + Estimated size when extracted in bytes cudaVersionMajor : int - + CUDA major version of bundled headers cudaVersionMinor : int - + CUDA minor version of bundled headers numFiles : unsigned int - + Number of header files in the bundle Methods @@ -175,10 +177,12 @@ cdef class anon_struct0: getPtr() Get memory address of class instance """ - def __cinit__(self, void_ptr _ptr): - self._pvt_ptr = _ptr - - def __init__(self, void_ptr _ptr): + def __cinit__(self, void_ptr _ptr = 0): + if _ptr == 0: + self._pvt_ptr = &self._pvt_val + else: + self._pvt_ptr = _ptr + def __init__(self, void_ptr _ptr = 0): pass def __dealloc__(self): pass @@ -275,49 +279,6 @@ cdef class anon_struct0: self._pvt_ptr[0].numFiles = numFiles -cdef class nvrtcBundledHeadersInfo(anon_struct0): - """ - Attributes - ---------- - - available : int - - - - compressedSize : size_t - - - - uncompressedSize : size_t - - - - cudaVersionMajor : int - - - - cudaVersionMinor : int - - - - numFiles : unsigned int - - - - Methods - ------- - getPtr() - Get memory address of class instance - """ - def __cinit__(self, void_ptr _ptr = 0): - if _ptr == 0: - self._pvt_ptr = &self._pvt_val - else: - self._pvt_ptr = _ptr - - def __init__(self, void_ptr _ptr = 0): - pass - @cython.embedsignature(True) def nvrtcGetErrorString(result not None : nvrtcResult): """ nvrtcGetErrorString is a helper function that returns a string describing the given :py:obj:`~.nvrtcResult` code, e.g., NVRTC_SUCCESS to `"NVRTC_SUCCESS"`. For unrecognized enumeration values, it returns `"NVRTC_ERROR unknown"`. diff --git a/cuda_bindings/docs/source/module/nvrtc.rst b/cuda_bindings/docs/source/module/nvrtc.rst index 5736d3012ec..6b6b7046445 100644 --- a/cuda_bindings/docs/source/module/nvrtc.rst +++ b/cuda_bindings/docs/source/module/nvrtc.rst @@ -3,7 +3,7 @@ .. This code was automatically generated with version 13.3.0. Do not modify it directly. -.. CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=c324889e2f86a6302cc610b49d290d545483f3fc0fa05d62ee47eb8aed781ae1 +.. CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=c0aad81d1be715fcef6b97fc6fa560c100a9c66fd9a67306e78653884618047c ----- nvrtc ----- @@ -122,6 +122,7 @@ Bundled Headers Installation NVRTC defines the following types and functions for bundled headers installation and management. +.. autoclass:: cuda.bindings.nvrtc.nvrtcBundledHeadersInfo .. autoclass:: cuda.bindings.nvrtc.nvrtcBundledHeadersInfo .. autofunction:: cuda.bindings.nvrtc.nvrtcInstallBundledHeaders .. autofunction:: cuda.bindings.nvrtc.nvrtcGetBundledHeadersInfo diff --git a/cuda_bindings/tests/legacy_api/test_legacy_nvrtc.py b/cuda_bindings/tests/legacy_api/test_legacy_nvrtc.py index 90ff6766d41..02a42b9831b 100644 --- a/cuda_bindings/tests/legacy_api/test_legacy_nvrtc.py +++ b/cuda_bindings/tests/legacy_api/test_legacy_nvrtc.py @@ -35,3 +35,21 @@ def test_nvrtcGetLoweredName_failure(): err, name = nvrtc.nvrtcGetLoweredName(0, b"I'm another elevated name!") assert err == nvrtc.nvrtcResult.NVRTC_ERROR_INVALID_PROGRAM assert name is None + + +@pytest.mark.agent_authored(model="claude-sonnet-5") +@pytest.mark.skipif(nvrtcVersionLessThan(13, 3), reason="When nvrtcGetBundledHeadersInfo was introduced") +def test_nvrtcGetBundledHeadersInfo(): + info = nvrtc.nvrtcBundledHeadersInfo() + assert isinstance(info, nvrtc.nvrtcBundledHeadersInfo) + + err, info, errorLog = nvrtc.nvrtcGetBundledHeadersInfo() + ASSERT_DRV(err) + assert isinstance(info, nvrtc.nvrtcBundledHeadersInfo) + assert info.available in (0, 1) + assert info.compressedSize >= 0 + assert info.uncompressedSize >= 0 + assert info.cudaVersionMajor >= 0 + assert info.cudaVersionMinor >= 0 + assert info.numFiles >= 0 + assert errorLog is None diff --git a/cuda_bindings/tests/test_nvrtc.py b/cuda_bindings/tests/test_nvrtc.py index 26eea71a100..fd73b86eaa2 100644 --- a/cuda_bindings/tests/test_nvrtc.py +++ b/cuda_bindings/tests/test_nvrtc.py @@ -23,3 +23,20 @@ def test_get_lowered_name_failure(): nvrtc.get_lowered_name(0, b"I'm an elevated name!") with pytest.raises(nvrtc.InvalidProgramError): nvrtc.get_lowered_name(0, b"I'm another elevated name!") + + +@pytest.mark.agent_authored(model="claude-sonnet-5") +@pytest.mark.skipif(nvrtc_version_less_than(13, 3), reason="When nvrtcGetBundledHeadersInfo was introduced") +def test_get_bundled_headers_info(): + info = nvrtc.BundledHeadersInfo() + assert isinstance(info, nvrtc.BundledHeadersInfo) + + info, error_log = nvrtc.get_bundled_headers_info() + assert isinstance(info, nvrtc.BundledHeadersInfo) + assert info.available in (0, 1) + assert info.compressed_size >= 0 + assert info.uncompressed_size >= 0 + assert info.cuda_version_major >= 0 + assert info.cuda_version_minor >= 0 + assert info.num_files >= 0 + assert error_log is None