diff --git a/cuda_bindings/cuda/bindings/cudla.pyx b/cuda_bindings/cuda/bindings/cudla.pyx index 9d04eb6013d..f06f010d2f8 100644 --- a/cuda_bindings/cuda/bindings/cudla.pyx +++ b/cuda_bindings/cuda/bindings/cudla.pyx @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # This code was automatically generated across versions from 1.5.0 to 13.4.1. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=27847299a8355597d74d78c538539764838b579ac5331197a0773132e9c1fc18 +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=dacac686fe1821a7d01ad45a8337f4d35d53fc8fafa3892cd3fdcf4b0ec83b1a # <<<< PREAMBLE CONTENT >>>> @@ -75,7 +75,9 @@ cdef intptr_t _cyb_get_buffer_pointer(buf, Py_ssize_t size, readonly=True) excep flags |= _cyb_cpython.PyBUF_WRITABLE cdef int status = -1 cdef _cyb_cpython.Py_buffer view - if isinstance(buf, int): + if buf is None: + ptr = 0 + elif isinstance(buf, int): ptr = buf else: try: @@ -86,7 +88,7 @@ cdef intptr_t _cyb_get_buffer_pointer(buf, Py_ssize_t size, readonly=True) excep except Exception as e: adj = "writable " if not readonly else "" raise ValueError( - "buf must be either a Python int representing the pointer " + "buf must be None, a Python int representing the pointer " f"address to a valid buffer, or a 1D contiguous {adj}" f"buffer, of size {size}" ) from e diff --git a/cuda_bindings/cuda/bindings/nvfatbin.pyx b/cuda_bindings/cuda/bindings/nvfatbin.pyx index 5e098b563e5..3c64bdcb4d0 100644 --- a/cuda_bindings/cuda/bindings/nvfatbin.pyx +++ b/cuda_bindings/cuda/bindings/nvfatbin.pyx @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 # # This code was automatically generated across versions from 12.4.1 to 13.4.1. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=14de87751c0c3d7f45936993e667e4e41c4558782e61b73727a20e908c17c652 +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=b5d55e220498d5f9a4ea3993256cb5e66063e990616da21b03feb12e39fafeac # <<<< PREAMBLE CONTENT >>>> @@ -20,7 +20,9 @@ cdef intptr_t _cyb_get_buffer_pointer(buf, Py_ssize_t size, readonly=True) excep flags |= _cyb_cpython.PyBUF_WRITABLE cdef int status = -1 cdef _cyb_cpython.Py_buffer view - if isinstance(buf, int): + if buf is None: + ptr = 0 + elif isinstance(buf, int): ptr = buf else: try: @@ -31,7 +33,7 @@ cdef intptr_t _cyb_get_buffer_pointer(buf, Py_ssize_t size, readonly=True) excep except Exception as e: adj = "writable " if not readonly else "" raise ValueError( - "buf must be either a Python int representing the pointer " + "buf must be None, a Python int representing the pointer " f"address to a valid buffer, or a 1D contiguous {adj}" f"buffer, of size {size}" ) from e diff --git a/cuda_bindings/cuda/bindings/nvjitlink.pyx b/cuda_bindings/cuda/bindings/nvjitlink.pyx index 095fde7a316..9cfae481d33 100644 --- a/cuda_bindings/cuda/bindings/nvjitlink.pyx +++ b/cuda_bindings/cuda/bindings/nvjitlink.pyx @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 # # This code was automatically generated across versions from 12.0.1 to 13.4.1. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=a78f22b1b6dcb03f525500bc064d3296b9439b5d35d5e0b1fdfb8cc02bc4ae78 +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=2722e4f76d90d40a7e867693a6583e1e1a5364bcb4dd8ec6265135f041d4b362 # <<<< PREAMBLE CONTENT >>>> @@ -23,7 +23,9 @@ cdef intptr_t _cyb_get_buffer_pointer(buf, Py_ssize_t size, readonly=True) excep flags |= _cyb_cpython.PyBUF_WRITABLE cdef int status = -1 cdef _cyb_cpython.Py_buffer view - if isinstance(buf, int): + if buf is None: + ptr = 0 + elif isinstance(buf, int): ptr = buf else: try: @@ -34,7 +36,7 @@ cdef intptr_t _cyb_get_buffer_pointer(buf, Py_ssize_t size, readonly=True) excep except Exception as e: adj = "writable " if not readonly else "" raise ValueError( - "buf must be either a Python int representing the pointer " + "buf must be None, a Python int representing the pointer " f"address to a valid buffer, or a 1D contiguous {adj}" f"buffer, of size {size}" ) from e diff --git a/cuda_bindings/cuda/bindings/nvvm.pyx b/cuda_bindings/cuda/bindings/nvvm.pyx index b66cab7a5ce..b20d028601d 100644 --- a/cuda_bindings/cuda/bindings/nvvm.pyx +++ b/cuda_bindings/cuda/bindings/nvvm.pyx @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 # # This code was automatically generated across versions from 12.0.1 to 13.4.1. Do not modify it directly. -# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=aa6981cde165f72ca15130140b5ccb381525a5bf29691bd36509266da7e781ae +# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=84da1bdc4b1620ced150103d0acd5f0d48ea8808f593d8c67255896868f26ec3 # <<<< PREAMBLE CONTENT >>>> @@ -20,7 +20,9 @@ cdef intptr_t _cyb_get_buffer_pointer(buf, Py_ssize_t size, readonly=True) excep flags |= _cyb_cpython.PyBUF_WRITABLE cdef int status = -1 cdef _cyb_cpython.Py_buffer view - if isinstance(buf, int): + if buf is None: + ptr = 0 + elif isinstance(buf, int): ptr = buf else: try: @@ -31,7 +33,7 @@ cdef intptr_t _cyb_get_buffer_pointer(buf, Py_ssize_t size, readonly=True) excep except Exception as e: adj = "writable " if not readonly else "" raise ValueError( - "buf must be either a Python int representing the pointer " + "buf must be None, a Python int representing the pointer " f"address to a valid buffer, or a 1D contiguous {adj}" f"buffer, of size {size}" ) from e diff --git a/cuda_bindings/docs/source/release/13.5.0-notes.rst b/cuda_bindings/docs/source/release/13.5.0-notes.rst index 1a2b3f9b05e..eb6edfbfa1e 100644 --- a/cuda_bindings/docs/source/release/13.5.0-notes.rst +++ b/cuda_bindings/docs/source/release/13.5.0-notes.rst @@ -11,6 +11,22 @@ Enhancements ------------ - ``cuda-bindings`` docstrings now include the full documentation from the upstream CTK, not just the first paragraph. +- The following functions now accept ``None`` for their buffer-like pointer argument (an integer address or an object supporting the buffer protocol), which is treated as ``NULL``. + + - ``cudla.module_load_from_memory`` (``p_module``) + - ``nvfatbin.add_cubin``, ``nvfatbin.add_index``, ``nvfatbin.add_ltoir``, ``nvfatbin.add_ptx``, ``nvfatbin.add_reloc``, ``nvfatbin.add_tile_ir`` (``code``) + - ``nvfatbin.get`` (``buffer``) + - ``nvjitlink.add_data`` (``data``) + - ``nvjitlink.get_error_log``, ``nvjitlink.get_info_log`` (``log``) + - ``nvjitlink.get_linked_cubin`` (``cubin``) + - ``nvjitlink.get_linked_ltoir`` (``ltoir``) + - ``nvjitlink.get_linked_ptx`` (``ptx``) + - ``nvvm.add_module_to_program``, ``nvvm.lazy_add_module_to_program``, ``nvvm.get_compiled_result``, ``nvvm.get_program_log`` (``buffer``) + +Behavior changes +---------------- + +- Passing a ``None`` to ``nvvm.add_module_to_program`` or ``nvvm.lazy_add_module_to_program`` will now raise a ``nvvm.nvvmError`` (``INVALID_INPUT``) rather than a ``ValueError``. Prerelease feature ------------------ diff --git a/cuda_bindings/tests/test_nvvm.py b/cuda_bindings/tests/test_nvvm.py index 91b7d705d34..aeab34ee861 100644 --- a/cuda_bindings/tests/test_nvvm.py +++ b/cuda_bindings/tests/test_nvvm.py @@ -80,7 +80,7 @@ def test_create_and_destroy(): @pytest.mark.parametrize("add_fn", [nvvm.add_module_to_program, nvvm.lazy_add_module_to_program]) def test_add_module_to_program_fail(add_fn): - with nvvm_program() as prog, pytest.raises(ValueError): + with nvvm_program() as prog, pytest.raises(nvvm.nvvmError): # Passing a C NULL pointer generates "ERROR_INVALID_INPUT (4)", # but that is not possible through our Python bindings. # The ValueError originates from the cython bindings code.