diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 4e93de45004..00000000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include cuda/_version.py diff --git a/cuda/LICENSE b/cuda/LICENSE new file mode 100644 index 00000000000..b7d042fcee3 --- /dev/null +++ b/cuda/LICENSE @@ -0,0 +1,48 @@ +NVIDIA SOFTWARE LICENSE + +This license is a legal agreement between you and NVIDIA Corporation ("NVIDIA") and governs your use of the NVIDIA CUDA Python software and materials provided hereunder ("SOFTWARE"). + +This license can be accepted only by an adult of legal age of majority in the country in which the SOFTWARE is used. If you are under the legal age of majority, you must ask your parent or legal guardian to consent to this license. By taking delivery of the SOFTWARE, you affirm that you have reached the legal age of majority, you accept the terms of this license, and you take legal and financial responsibility for the actions of your permitted users. + +You agree to use the SOFTWARE only for purposes that are permitted by (a) this license, and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions. + +1. LICENSE. Subject to the terms of this license, NVIDIA grants you a non-exclusive limited license to: (a) install and use the SOFTWARE, and (b) distribute the SOFTWARE subject to the distribution requirements described in this license. NVIDIA reserves all rights, title and interest in and to the SOFTWARE not expressly granted to you under this license. + +2. DISTRIBUTION REQUIREMENTS. These are the distribution requirements for you to exercise the distribution grant: +a. The terms under which you distribute the SOFTWARE must be consistent with the terms of this license, including (without limitation) terms relating to the license grant and license restrictions and protection of NVIDIA's intellectual property rights. +b. You agree to notify NVIDIA in writing of any known or suspected distribution or use of the SOFTWARE not in compliance with the requirements of this license, and to enforce the terms of your agreements with respect to distributed SOFTWARE. + +3. LIMITATIONS. Your license to use the SOFTWARE is restricted as follows: +a. The SOFTWARE is licensed for you to develop applications only for use in systems with NVIDIA GPUs. +b. You may not reverse engineer, decompile or disassemble, or remove copyright or other proprietary notices from any portion of the SOFTWARE or copies of the SOFTWARE. +c. You may not modify or create derivative works of any portion of the SOFTWARE. +d. You may not bypass, disable, or circumvent any technical measure, encryption, security, digital rights management or authentication mechanism in the SOFTWARE. +e. You may not use the SOFTWARE in any manner that would cause it to become subject to an open source software license. As examples, licenses that require as a condition of use, modification, and/or distribution that the SOFTWARE be (i) disclosed or distributed in source code form; (ii) licensed for the purpose of making derivative works; or (iii) redistributable at no charge. +f. Unless you have an agreement with NVIDIA for this purpose, you may not use the SOFTWARE with any system or application where the use or failure of the system or application can reasonably be expected to threaten or result in personal injury, death, or catastrophic loss. Examples include use in avionics, navigation, military, medical, life support or other life critical applications. NVIDIA does not design, test or manufacture the SOFTWARE for these critical uses and NVIDIA shall not be liable to you or any third party, in whole or in part, for any claims or damages arising from such uses. +g. You agree to defend, indemnify and hold harmless NVIDIA and its affiliates, and their respective employees, contractors, agents, officers and directors, from and against any and all claims, damages, obligations, losses, liabilities, costs or debt, fines, restitutions and expenses (including but not limited to attorney's fees and costs incident to establishing the right of indemnification) arising out of or related to use of the SOFTWARE outside of the scope of this Agreement, or not in compliance with its terms. + +4. PRE-RELEASE. SOFTWARE versions identified as alpha, beta, preview, early access or otherwise as pre-release may not be fully functional, may contain errors or design flaws, and may have reduced or different security, privacy, availability, and reliability standards relative to commercial versions of NVIDIA software and materials. You may use a pre-release SOFTWARE version at your own risk, understanding that these versions are not intended for use in production or business-critical systems. + +5. OWNERSHIP. The SOFTWARE and the related intellectual property rights therein are and will remain the sole and exclusive property of NVIDIA or its licensors. The SOFTWARE is copyrighted and protected by the laws of the United States and other countries, and international treaty provisions. NVIDIA may make changes to the SOFTWARE, at any time without notice, but is not obligated to support or update the SOFTWARE. + +6. COMPONENTS UNDER OTHER LICENSES. The SOFTWARE may include NVIDIA or third-party components with separate legal notices or terms as may be described in proprietary notices accompanying the SOFTWARE. If and to the extent there is a conflict between the terms in this license and the license terms associated with a component, the license terms associated with the components control only to the extent necessary to resolve the conflict. + +7. FEEDBACK. You may, but don't have to, provide to NVIDIA any Feedback. "Feedback" means any suggestions, bug fixes, enhancements, modifications, feature requests or other feedback regarding the SOFTWARE. For any Feedback that you voluntarily provide, you hereby grant NVIDIA and its affiliates a perpetual, non-exclusive, worldwide, irrevocable license to use, reproduce, modify, license, sublicense (through multiple tiers of sublicensees), and distribute (through multiple tiers of distributors) the Feedback without the payment of any royalties or fees to you. NVIDIA will use Feedback at its choice. + +8. NO WARRANTIES. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. NVIDIA DOES NOT WARRANT THAT THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION THEREOF WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ALL ERRORS WILL BE CORRECTED. + +9. LIMITATIONS OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY LAW, NVIDIA AND ITS AFFILIATES SHALL NOT BE LIABLE FOR ANY SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR ANY LOST PROFITS, PROJECT DELAYS, LOSS OF USE, LOSS OF DATA OR LOSS OF GOODWILL, OR THE COSTS OF PROCURING SUBSTITUTE PRODUCTS, ARISING OUT OF OR IN CONNECTION WITH THIS LICENSE OR THE USE OR PERFORMANCE OF THE SOFTWARE, WHETHER SUCH LIABILITY ARISES FROM ANY CLAIM BASED UPON BREACH OF CONTRACT, BREACH OF WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCT LIABILITY OR ANY OTHER CAUSE OF ACTION OR THEORY OF LIABILITY, EVEN IF NVIDIA HAS PREVIOUSLY BEEN ADVISED OF, OR COULD REASONABLY HAVE FORESEEN, THE POSSIBILITY OF SUCH DAMAGES. IN NO EVENT WILL NVIDIA'S AND ITS AFFILIATES TOTAL CUMULATIVE LIABILITY UNDER OR ARISING OUT OF THIS LICENSE EXCEED US$10.00. THE NATURE OF THE LIABILITY OR THE NUMBER OF CLAIMS OR SUITS SHALL NOT ENLARGE OR EXTEND THIS LIMIT. + +10. TERMINATION. Your rights under this license will terminate automatically without notice from NVIDIA if you fail to comply with any term and condition of this license or if you commence or participate in any legal proceeding against NVIDIA with respect to the SOFTWARE. NVIDIA may terminate this license with advance written notice to you if NVIDIA decides to no longer provide the SOFTWARE in a country or, in NVIDIA's sole discretion, the continued use of it is no longer commercially viable. Upon any termination of this license, you agree to promptly discontinue use of the SOFTWARE and destroy all copies in your possession or control. Your prior distributions in accordance with this license are not affected by the termination of this license. All provisions of this license will survive termination, except for the license granted to you. + +11. APPLICABLE LAW. This license will be governed in all respects by the laws of the United States and of the State of Delaware as those laws are applied to contracts entered into and performed entirely within Delaware by Delaware residents, without regard to the conflicts of laws principles. The United Nations Convention on Contracts for the International Sale of Goods is specifically disclaimed. You agree to all terms of this Agreement in the English language. The state or federal courts residing in Santa Clara County, California shall have exclusive jurisdiction over any dispute or claim arising out of this license. Notwithstanding this, you agree that NVIDIA shall still be allowed to apply for injunctive remedies or an equivalent type of urgent legal relief in any jurisdiction. + +12. NO ASSIGNMENT. This license and your rights and obligations thereunder may not be assigned by you by any means or operation of law without NVIDIA's permission. Any attempted assignment not approved by NVIDIA in writing shall be void and of no effect. + +13. EXPORT. The SOFTWARE is subject to United States export laws and regulations. You agree that you will not ship, transfer or export the SOFTWARE into any country, or use the SOFTWARE in any manner, prohibited by the United States Bureau of Industry and Security or economic sanctions regulations administered by the U.S. Department of Treasury's Office of Foreign Assets Control (OFAC), or any applicable export laws, restrictions or regulations. These laws include restrictions on destinations, end users and end use. By accepting this license, you confirm that you are not a resident or citizen of any country currently embargoed by the U.S. and that you are not otherwise prohibited from receiving the SOFTWARE. + +14. GOVERNMENT USE. The SOFTWARE has been developed entirely at private expense and is "commercial items" consisting of "commercial computer software" and "commercial computer software documentation" provided with RESTRICTED RIGHTS. Use, duplication or disclosure by the U.S. Government or a U.S. Government subcontractor is subject to the restrictions in this license pursuant to DFARS 227.7202-3(a) or as set forth in subparagraphs (b)(1) and (2) of the Commercial Computer Software - Restricted Rights clause at FAR 52.227-19, as applicable. Contractor/manufacturer is NVIDIA, 2788 San Tomas Expressway, Santa Clara, CA 95051. + +15. ENTIRE AGREEMENT. This license is the final, complete and exclusive agreement between the parties relating to the subject matter of this license and supersedes all prior or contemporaneous understandings and agreements relating to this subject matter, whether oral or written. If any court of competent jurisdiction determines that any provision of this license is illegal, invalid or unenforceable, the remaining provisions will remain in full force and effect. This license may only be modified in a writing signed by an authorized representative of each party. + +(v. May 12, 2021) diff --git a/cuda/MANIFEST.in b/cuda/MANIFEST.in new file mode 100644 index 00000000000..ef9def92801 --- /dev/null +++ b/cuda/MANIFEST.in @@ -0,0 +1,4 @@ +recursive-include cuda/ *.pyx *.pxd +# at least with setuptools 75.0.0 this folder was added erroneously +# to the payload, causing file copying to the build environment failed +exclude cuda/bindings diff --git a/cuda/README.md b/cuda/README.md new file mode 100644 index 00000000000..1cbafb562d5 --- /dev/null +++ b/cuda/README.md @@ -0,0 +1,76 @@ +# CUDA-Python + +CUDA Python is a standard set of low-level interfaces, providing full coverage of and access to the CUDA host APIs from Python. Checkout the [Overview](https://nvidia.github.io/cuda-python/overview.html) for the workflow and performance results. + +## Installing + +CUDA Python can be installed from: + +* PYPI +* Conda (nvidia channel) +* Source builds + +There're differences in each of these options that are described further in [Installation](https://nvidia.github.io/cuda-python/install.html) documentation. Each package will guarantee minor version compatibility. + +## Runtime Dependencies + +CUDA Python is supported on all platforms that CUDA is supported. Specific dependencies are as follows: + +* Driver: Linux (450.80.02 or later) Windows (456.38 or later) +* CUDA Toolkit 12.0 to 12.6 + +Only the NVRTC redistributable component is required from the CUDA Toolkit. [CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/index.html) Installation Guides can be used for guidance. Note that the NVRTC component in the Toolkit can be obtained via PYPI, Conda or Local Installer. + +### Supported Python Versions + +CUDA Python follows [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html) for supported Python version guarantee. + +Before dropping support, an issue will be raised to look for feedback. + +Source builds work for multiple Python versions, however pre-build PyPI and Conda packages are only provided for a subset: + +* Python 3.9 to 3.12 + +## Testing + +### Requirements + +Latest dependencies can be found in [requirements.txt](https://github.com/NVIDIA/cuda-python/blob/main/requirements.txt). + +### Unit-tests + +You can run the included tests with: + +``` +python -m pytest +``` + +### Benchmark + +You can run benchmark only tests with: + +``` +python -m pytest --benchmark-only +``` + +### Samples + +You can run the included tests with: + +``` +python -m pytest examples +``` + +## Examples + +CUDA Samples rewriten using CUDA Python are found in `examples`. + +Custom extra included examples: + +- `examples/extra/jit_program_test.py`: Demonstrates the use of the API to compile and + launch a kernel on the device. Includes device memory allocation / + deallocation, transfers between host and device, creation and usage of + streams, and context management. +- `examples/extra/numba_emm_plugin.py`: Implements a Numba External Memory Management + plugin, showing that this CUDA Python Driver API can coexist with other + wrappers of the driver API. diff --git a/cuda/__init__.pxd b/cuda/cuda/__init__.pxd similarity index 100% rename from cuda/__init__.pxd rename to cuda/cuda/__init__.pxd diff --git a/cuda/cuda/__init__.py b/cuda/cuda/__init__.py new file mode 100644 index 00000000000..8b302752de4 --- /dev/null +++ b/cuda/cuda/__init__.py @@ -0,0 +1,10 @@ +def __getattr__(name): + if name == "__version__": + import warnings + warnings.warn("accessing cuda.__version__ is deprecated, " + "please switch to use cuda.bindings.__version__ instead", + DeprecationWarning, stacklevel=2) + from . import bindings + return bindings.__version__ + + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") diff --git a/cuda/_cuda/__init__.py b/cuda/cuda/bindings/__init__.pxd similarity index 100% rename from cuda/_cuda/__init__.py rename to cuda/cuda/bindings/__init__.pxd diff --git a/cuda/__init__.py b/cuda/cuda/bindings/__init__.py similarity index 100% rename from cuda/__init__.py rename to cuda/cuda/bindings/__init__.py diff --git a/cuda/_lib/__init__.py b/cuda/cuda/bindings/_cuda/__init__.py similarity index 100% rename from cuda/_lib/__init__.py rename to cuda/cuda/bindings/_cuda/__init__.py diff --git a/cuda/_cuda/ccuda.pxd.in b/cuda/cuda/bindings/_cuda/ccuda.pxd.in similarity index 99% rename from cuda/_cuda/ccuda.pxd.in rename to cuda/cuda/bindings/_cuda/ccuda.pxd.in index 82eba6e206b..21cdb5205ee 100644 --- a/cuda/_cuda/ccuda.pxd.in +++ b/cuda/cuda/bindings/_cuda/ccuda.pxd.in @@ -5,7 +5,7 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -from cuda.ccuda cimport * +from cuda.bindings.cydriver cimport * {{if 'cuGetErrorString' in found_functions}} diff --git a/cuda/_cuda/ccuda.pyx.in b/cuda/cuda/bindings/_cuda/ccuda.pyx.in similarity index 99% rename from cuda/_cuda/ccuda.pyx.in rename to cuda/cuda/bindings/_cuda/ccuda.pyx.in index 64a296f1dd2..b2a9a1cc02c 100644 --- a/cuda/_cuda/ccuda.pyx.in +++ b/cuda/cuda/bindings/_cuda/ccuda.pyx.in @@ -10,11 +10,11 @@ import win32api import struct from pywintypes import error {{else}} -cimport cuda._lib.dlfcn as dlfcn +cimport cuda.bindings._lib.dlfcn as dlfcn {{endif}} import os import sys -cimport cuda._cuda.loader as loader +cimport cuda.bindings._cuda.loader as loader cdef bint __cuPythonInit = False {{if 'cuGetErrorString' in found_functions}}cdef void *__cuGetErrorString = NULL{{endif}} {{if 'cuGetErrorName' in found_functions}}cdef void *__cuGetErrorName = NULL{{endif}} diff --git a/cuda/_cuda/cnvrtc.pxd.in b/cuda/cuda/bindings/_cuda/cnvrtc.pxd.in similarity index 99% rename from cuda/_cuda/cnvrtc.pxd.in rename to cuda/cuda/bindings/_cuda/cnvrtc.pxd.in index 4eccbee8513..26d3a6ffeda 100644 --- a/cuda/_cuda/cnvrtc.pxd.in +++ b/cuda/cuda/bindings/_cuda/cnvrtc.pxd.in @@ -5,7 +5,7 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -from cuda.cnvrtc cimport * +from cuda.bindings.cynvrtc cimport * {{if 'nvrtcGetErrorString' in found_functions}} diff --git a/cuda/_cuda/cnvrtc.pyx.in b/cuda/cuda/bindings/_cuda/cnvrtc.pyx.in similarity index 99% rename from cuda/_cuda/cnvrtc.pyx.in rename to cuda/cuda/bindings/_cuda/cnvrtc.pyx.in index c6da941717b..bb4b4cdb144 100644 --- a/cuda/_cuda/cnvrtc.pyx.in +++ b/cuda/cuda/bindings/_cuda/cnvrtc.pyx.in @@ -10,7 +10,7 @@ import win32api import struct from pywintypes import error {{else}} -cimport cuda._lib.dlfcn as dlfcn +cimport cuda.bindings._lib.dlfcn as dlfcn {{endif}} cdef bint __cuPythonInit = False diff --git a/cuda/_cuda/loader.cpp b/cuda/cuda/bindings/_cuda/loader.cpp similarity index 100% rename from cuda/_cuda/loader.cpp rename to cuda/cuda/bindings/_cuda/loader.cpp diff --git a/cuda/_cuda/loader.h b/cuda/cuda/bindings/_cuda/loader.h similarity index 100% rename from cuda/_cuda/loader.h rename to cuda/cuda/bindings/_cuda/loader.h diff --git a/cuda/_cuda/loader.pxd b/cuda/cuda/bindings/_cuda/loader.pxd similarity index 100% rename from cuda/_cuda/loader.pxd rename to cuda/cuda/bindings/_cuda/loader.pxd diff --git a/cuda/_lib/ccudart/__init__.py b/cuda/cuda/bindings/_lib/__init__.py similarity index 100% rename from cuda/_lib/ccudart/__init__.py rename to cuda/cuda/bindings/_lib/__init__.py diff --git a/cuda/benchmarks/__init__.py b/cuda/cuda/bindings/_lib/ccudart/__init__.py similarity index 100% rename from cuda/benchmarks/__init__.py rename to cuda/cuda/bindings/_lib/ccudart/__init__.py diff --git a/cuda/_lib/ccudart/ccudart.pxd.in b/cuda/cuda/bindings/_lib/ccudart/ccudart.pxd.in similarity index 99% rename from cuda/_lib/ccudart/ccudart.pxd.in rename to cuda/cuda/bindings/_lib/ccudart/ccudart.pxd.in index 072fa91a41c..392950fe1fb 100644 --- a/cuda/_lib/ccudart/ccudart.pxd.in +++ b/cuda/cuda/bindings/_lib/ccudart/ccudart.pxd.in @@ -5,8 +5,8 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -cimport cuda.ccuda as ccuda -from cuda.ccudart cimport * +cimport cuda.bindings.cydriver as ccuda +from cuda.bindings.cyruntime cimport * from libc.stdlib cimport malloc, free, calloc from libc.string cimport memset, memcpy, strncmp from libcpp cimport bool diff --git a/cuda/_lib/ccudart/ccudart.pyx.in b/cuda/cuda/bindings/_lib/ccudart/ccudart.pyx.in similarity index 99% rename from cuda/_lib/ccudart/ccudart.pyx.in rename to cuda/cuda/bindings/_lib/ccudart/ccudart.pyx.in index 25cb36f2008..51e626a2a19 100644 --- a/cuda/_lib/ccudart/ccudart.pyx.in +++ b/cuda/cuda/bindings/_lib/ccudart/ccudart.pyx.in @@ -5,12 +5,12 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -from cuda.ccudart cimport * -from cuda._lib.ccudart.utils cimport * +from cuda.bindings.cyruntime cimport * +from cuda.bindings._lib.ccudart.utils cimport * from libc.stdlib cimport malloc, free, calloc from libc.string cimport memset, memcpy, strncmp from libcpp cimport bool -cimport cuda._cuda.ccuda as ccuda +cimport cuda.bindings._cuda.ccuda as ccuda cdef cudaPythonGlobal m_global = globalGetInstance() @@ -4867,7 +4867,7 @@ cdef cudaError_t _cudaGraphAddNode_v2(cudaGraphNode_t* pGraphNode, cudaGraph_t g {{if True}} {{if 'Windows' != platform.system()}} -cimport cuda._lib.dlfcn as dlfcn +cimport cuda.bindings._lib.dlfcn as dlfcn {{endif}} cdef cudaError_t _getLocalRuntimeVersion(int* runtimeVersion) except ?cudaErrorCallRequiresNewerDriver nogil: diff --git a/cuda/_lib/ccudart/utils.pxd.in b/cuda/cuda/bindings/_lib/ccudart/utils.pxd.in similarity index 99% rename from cuda/_lib/ccudart/utils.pxd.in rename to cuda/cuda/bindings/_lib/ccudart/utils.pxd.in index 7bc552bb3bb..d88b0be6f0b 100644 --- a/cuda/_lib/ccudart/utils.pxd.in +++ b/cuda/cuda/bindings/_lib/ccudart/utils.pxd.in @@ -5,12 +5,12 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -from cuda.ccudart cimport * +from cuda.bindings.cyruntime cimport * from libc.stdlib cimport malloc, free, calloc from libc.string cimport memset, memcpy, strncmp from libcpp cimport bool from libcpp.map cimport map -cimport cuda._cuda.ccuda as ccuda +cimport cuda.bindings._cuda.ccuda as ccuda ctypedef struct cudaAsyncCallbackData_st: cudaAsyncCallback callback diff --git a/cuda/_lib/ccudart/utils.pyx.in b/cuda/cuda/bindings/_lib/ccudart/utils.pyx.in similarity index 99% rename from cuda/_lib/ccudart/utils.pyx.in rename to cuda/cuda/bindings/_lib/ccudart/utils.pyx.in index c34c96f1eb6..4b9b144d969 100644 --- a/cuda/_lib/ccudart/utils.pyx.in +++ b/cuda/cuda/bindings/_lib/ccudart/utils.pyx.in @@ -6,11 +6,11 @@ # this software and related documentation outside the terms of the EULA # is strictly prohibited. import cython -from cuda.ccudart cimport * +from cuda.bindings.cyruntime cimport * from libc.stdlib cimport malloc, free, calloc from libc.string cimport memset, memcpy, strncmp, memcmp from libcpp cimport bool -cimport cuda._cuda.ccuda as ccuda +cimport cuda.bindings._cuda.ccuda as ccuda cdef struct cudaArrayLocalState: ccuda.CUarray array diff --git a/cuda/_lib/dlfcn.pxd b/cuda/cuda/bindings/_lib/dlfcn.pxd similarity index 100% rename from cuda/_lib/dlfcn.pxd rename to cuda/cuda/bindings/_lib/dlfcn.pxd diff --git a/cuda/_lib/param_packer.cpp b/cuda/cuda/bindings/_lib/param_packer.cpp similarity index 100% rename from cuda/_lib/param_packer.cpp rename to cuda/cuda/bindings/_lib/param_packer.cpp diff --git a/cuda/_lib/param_packer.h b/cuda/cuda/bindings/_lib/param_packer.h similarity index 100% rename from cuda/_lib/param_packer.h rename to cuda/cuda/bindings/_lib/param_packer.h diff --git a/cuda/_lib/param_packer.pxd b/cuda/cuda/bindings/_lib/param_packer.pxd similarity index 100% rename from cuda/_lib/param_packer.pxd rename to cuda/cuda/bindings/_lib/param_packer.pxd diff --git a/cuda/_lib/utils.pxd.in b/cuda/cuda/bindings/_lib/utils.pxd.in similarity index 97% rename from cuda/_lib/utils.pxd.in rename to cuda/cuda/bindings/_lib/utils.pxd.in index 229f6be9610..d3c18430f97 100644 --- a/cuda/_lib/utils.pxd.in +++ b/cuda/cuda/bindings/_lib/utils.pxd.in @@ -5,8 +5,8 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -cimport cuda.cuda as cuda -cimport cuda.ccuda as ccuda +cimport cuda.bindings.driver as cuda +cimport cuda.bindings.cydriver as ccuda from libcpp.vector cimport vector cdef class HelperKernelParams: diff --git a/cuda/_lib/utils.pyx.in b/cuda/cuda/bindings/_lib/utils.pyx.in similarity index 99% rename from cuda/_lib/utils.pyx.in rename to cuda/cuda/bindings/_lib/utils.pyx.in index 6f61f90b8db..02efc2cd051 100644 --- a/cuda/_lib/utils.pyx.in +++ b/cuda/cuda/bindings/_lib/utils.pyx.in @@ -13,9 +13,9 @@ from libc.string cimport memcpy from enum import Enum from typing import List, Tuple import ctypes -cimport cuda.ccuda as ccuda -import cuda.cuda as cuda -cimport cuda._lib.param_packer as param_packer +cimport cuda.bindings.cydriver as ccuda +import cuda.bindings.driver as cuda +cimport cuda.bindings._lib.param_packer as param_packer ctypedef unsigned long long void_ptr diff --git a/cuda/_version.py b/cuda/cuda/bindings/_version.py similarity index 100% rename from cuda/_version.py rename to cuda/cuda/bindings/_version.py diff --git a/cuda/tests/__init__.py b/cuda/cuda/bindings/benchmarks/__init__.py similarity index 100% rename from cuda/tests/__init__.py rename to cuda/cuda/bindings/benchmarks/__init__.py diff --git a/cuda/benchmarks/kernels.py b/cuda/cuda/bindings/benchmarks/kernels.py similarity index 100% rename from cuda/benchmarks/kernels.py rename to cuda/cuda/bindings/benchmarks/kernels.py diff --git a/cuda/benchmarks/perf_test_utils.py b/cuda/cuda/bindings/benchmarks/perf_test_utils.py similarity index 100% rename from cuda/benchmarks/perf_test_utils.py rename to cuda/cuda/bindings/benchmarks/perf_test_utils.py diff --git a/cuda/benchmarks/test_cupy.py b/cuda/cuda/bindings/benchmarks/test_cupy.py similarity index 100% rename from cuda/benchmarks/test_cupy.py rename to cuda/cuda/bindings/benchmarks/test_cupy.py diff --git a/cuda/benchmarks/test_launch_latency.py b/cuda/cuda/bindings/benchmarks/test_launch_latency.py similarity index 100% rename from cuda/benchmarks/test_launch_latency.py rename to cuda/cuda/bindings/benchmarks/test_launch_latency.py diff --git a/cuda/benchmarks/test_numba.py b/cuda/cuda/bindings/benchmarks/test_numba.py similarity index 100% rename from cuda/benchmarks/test_numba.py rename to cuda/cuda/bindings/benchmarks/test_numba.py diff --git a/cuda/benchmarks/test_pointer_attributes.py b/cuda/cuda/bindings/benchmarks/test_pointer_attributes.py similarity index 100% rename from cuda/benchmarks/test_pointer_attributes.py rename to cuda/cuda/bindings/benchmarks/test_pointer_attributes.py diff --git a/cuda/ccuda.pxd.in b/cuda/cuda/bindings/cydriver.pxd.in similarity index 100% rename from cuda/ccuda.pxd.in rename to cuda/cuda/bindings/cydriver.pxd.in diff --git a/cuda/ccuda.pyx.in b/cuda/cuda/bindings/cydriver.pyx.in similarity index 99% rename from cuda/ccuda.pyx.in rename to cuda/cuda/bindings/cydriver.pyx.in index 48c06b5b279..d20d0773d75 100644 --- a/cuda/ccuda.pyx.in +++ b/cuda/cuda/bindings/cydriver.pyx.in @@ -5,7 +5,7 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -cimport cuda._cuda.ccuda as ccuda +cimport cuda.bindings._cuda.ccuda as ccuda {{if 'cuGetErrorString' in found_functions}} diff --git a/cuda/cnvrtc.pxd.in b/cuda/cuda/bindings/cynvrtc.pxd.in similarity index 100% rename from cuda/cnvrtc.pxd.in rename to cuda/cuda/bindings/cynvrtc.pxd.in diff --git a/cuda/cnvrtc.pyx.in b/cuda/cuda/bindings/cynvrtc.pyx.in similarity index 99% rename from cuda/cnvrtc.pyx.in rename to cuda/cuda/bindings/cynvrtc.pyx.in index 9781b65fd8f..875e7ce9f32 100644 --- a/cuda/cnvrtc.pyx.in +++ b/cuda/cuda/bindings/cynvrtc.pyx.in @@ -5,7 +5,7 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -cimport cuda._cuda.cnvrtc as cnvrtc +cimport cuda.bindings._cuda.cnvrtc as cnvrtc {{if 'nvrtcGetErrorString' in found_functions}} diff --git a/cuda/ccudart.pxd.in b/cuda/cuda/bindings/cyruntime.pxd.in similarity index 100% rename from cuda/ccudart.pxd.in rename to cuda/cuda/bindings/cyruntime.pxd.in diff --git a/cuda/ccudart.pyx.in b/cuda/cuda/bindings/cyruntime.pyx.in similarity index 99% rename from cuda/ccudart.pyx.in rename to cuda/cuda/bindings/cyruntime.pyx.in index 85acc7713de..98e5476e874 100644 --- a/cuda/ccudart.pyx.in +++ b/cuda/cuda/bindings/cyruntime.pyx.in @@ -8,9 +8,9 @@ # cython: show_performance_hints=False -cimport cuda._cuda.ccuda as ccuda -from cuda._lib.ccudart.ccudart cimport * -from cuda._lib.ccudart.utils cimport * +cimport cuda.bindings._cuda.ccuda as ccuda +from cuda.bindings._lib.ccudart.ccudart cimport * +from cuda.bindings._lib.ccudart.utils cimport * from libc.stdlib cimport malloc, free, calloc from libc cimport string from libcpp cimport bool diff --git a/cuda/cuda.pxd.in b/cuda/cuda/bindings/driver.pxd.in similarity index 99% rename from cuda/cuda.pxd.in rename to cuda/cuda/bindings/driver.pxd.in index 265b6dd3cd1..a5283d11291 100644 --- a/cuda/cuda.pxd.in +++ b/cuda/cuda/bindings/driver.pxd.in @@ -5,8 +5,8 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -cimport cuda.ccuda as ccuda -cimport cuda._lib.utils as utils +cimport cuda.bindings.cydriver as ccuda +cimport cuda.bindings._lib.utils as utils {{if 'CUcontext' in found_types}} diff --git a/cuda/cuda.pyx.in b/cuda/cuda/bindings/driver.pyx.in similarity index 100% rename from cuda/cuda.pyx.in rename to cuda/cuda/bindings/driver.pyx.in diff --git a/examples/0_Introduction/clock_nvrtc_test.py b/cuda/cuda/bindings/examples/0_Introduction/clock_nvrtc_test.py similarity index 100% rename from examples/0_Introduction/clock_nvrtc_test.py rename to cuda/cuda/bindings/examples/0_Introduction/clock_nvrtc_test.py diff --git a/examples/0_Introduction/simpleCubemapTexture_test.py b/cuda/cuda/bindings/examples/0_Introduction/simpleCubemapTexture_test.py similarity index 100% rename from examples/0_Introduction/simpleCubemapTexture_test.py rename to cuda/cuda/bindings/examples/0_Introduction/simpleCubemapTexture_test.py diff --git a/examples/0_Introduction/simpleP2P_test.py b/cuda/cuda/bindings/examples/0_Introduction/simpleP2P_test.py similarity index 100% rename from examples/0_Introduction/simpleP2P_test.py rename to cuda/cuda/bindings/examples/0_Introduction/simpleP2P_test.py diff --git a/examples/0_Introduction/simpleZeroCopy_test.py b/cuda/cuda/bindings/examples/0_Introduction/simpleZeroCopy_test.py similarity index 100% rename from examples/0_Introduction/simpleZeroCopy_test.py rename to cuda/cuda/bindings/examples/0_Introduction/simpleZeroCopy_test.py diff --git a/examples/0_Introduction/systemWideAtomics_test.py b/cuda/cuda/bindings/examples/0_Introduction/systemWideAtomics_test.py similarity index 100% rename from examples/0_Introduction/systemWideAtomics_test.py rename to cuda/cuda/bindings/examples/0_Introduction/systemWideAtomics_test.py diff --git a/examples/0_Introduction/vectorAddDrv_test.py b/cuda/cuda/bindings/examples/0_Introduction/vectorAddDrv_test.py similarity index 100% rename from examples/0_Introduction/vectorAddDrv_test.py rename to cuda/cuda/bindings/examples/0_Introduction/vectorAddDrv_test.py diff --git a/examples/0_Introduction/vectorAddMMAP_test.py b/cuda/cuda/bindings/examples/0_Introduction/vectorAddMMAP_test.py similarity index 100% rename from examples/0_Introduction/vectorAddMMAP_test.py rename to cuda/cuda/bindings/examples/0_Introduction/vectorAddMMAP_test.py diff --git a/examples/2_Concepts_and_Techniques/streamOrderedAllocation_test.py b/cuda/cuda/bindings/examples/2_Concepts_and_Techniques/streamOrderedAllocation_test.py similarity index 100% rename from examples/2_Concepts_and_Techniques/streamOrderedAllocation_test.py rename to cuda/cuda/bindings/examples/2_Concepts_and_Techniques/streamOrderedAllocation_test.py diff --git a/examples/3_CUDA_Features/globalToShmemAsyncCopy_test.py b/cuda/cuda/bindings/examples/3_CUDA_Features/globalToShmemAsyncCopy_test.py similarity index 100% rename from examples/3_CUDA_Features/globalToShmemAsyncCopy_test.py rename to cuda/cuda/bindings/examples/3_CUDA_Features/globalToShmemAsyncCopy_test.py diff --git a/examples/3_CUDA_Features/simpleCudaGraphs_test.py b/cuda/cuda/bindings/examples/3_CUDA_Features/simpleCudaGraphs_test.py similarity index 100% rename from examples/3_CUDA_Features/simpleCudaGraphs_test.py rename to cuda/cuda/bindings/examples/3_CUDA_Features/simpleCudaGraphs_test.py diff --git a/examples/4_CUDA_Libraries/conjugateGradientMultiBlockCG_test.py b/cuda/cuda/bindings/examples/4_CUDA_Libraries/conjugateGradientMultiBlockCG_test.py similarity index 100% rename from examples/4_CUDA_Libraries/conjugateGradientMultiBlockCG_test.py rename to cuda/cuda/bindings/examples/4_CUDA_Libraries/conjugateGradientMultiBlockCG_test.py diff --git a/examples/__init__.py b/cuda/cuda/bindings/examples/__init__.py similarity index 100% rename from examples/__init__.py rename to cuda/cuda/bindings/examples/__init__.py diff --git a/examples/common/common.py b/cuda/cuda/bindings/examples/common/common.py similarity index 100% rename from examples/common/common.py rename to cuda/cuda/bindings/examples/common/common.py diff --git a/examples/common/helper_cuda.py b/cuda/cuda/bindings/examples/common/helper_cuda.py similarity index 100% rename from examples/common/helper_cuda.py rename to cuda/cuda/bindings/examples/common/helper_cuda.py diff --git a/examples/common/helper_string.py b/cuda/cuda/bindings/examples/common/helper_string.py similarity index 100% rename from examples/common/helper_string.py rename to cuda/cuda/bindings/examples/common/helper_string.py diff --git a/examples/extra/isoFDModelling_test.py b/cuda/cuda/bindings/examples/extra/isoFDModelling_test.py similarity index 100% rename from examples/extra/isoFDModelling_test.py rename to cuda/cuda/bindings/examples/extra/isoFDModelling_test.py diff --git a/examples/extra/jit_program_test.py b/cuda/cuda/bindings/examples/extra/jit_program_test.py similarity index 100% rename from examples/extra/jit_program_test.py rename to cuda/cuda/bindings/examples/extra/jit_program_test.py diff --git a/examples/extra/numba_emm_plugin.py b/cuda/cuda/bindings/examples/extra/numba_emm_plugin.py similarity index 100% rename from examples/extra/numba_emm_plugin.py rename to cuda/cuda/bindings/examples/extra/numba_emm_plugin.py diff --git a/examples/setup.cfg b/cuda/cuda/bindings/examples/setup.cfg similarity index 100% rename from examples/setup.cfg rename to cuda/cuda/bindings/examples/setup.cfg diff --git a/cuda/nvrtc.pxd.in b/cuda/cuda/bindings/nvrtc.pxd.in similarity index 91% rename from cuda/nvrtc.pxd.in rename to cuda/cuda/bindings/nvrtc.pxd.in index 10731987b8b..33b77e87ad0 100644 --- a/cuda/nvrtc.pxd.in +++ b/cuda/cuda/bindings/nvrtc.pxd.in @@ -5,8 +5,8 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -cimport cuda.cnvrtc as cnvrtc -cimport cuda._lib.utils as utils +cimport cuda.bindings.cynvrtc as cnvrtc +cimport cuda.bindings._lib.utils as utils {{if 'nvrtcProgram' in found_types}} diff --git a/cuda/nvrtc.pyx.in b/cuda/cuda/bindings/nvrtc.pyx.in similarity index 100% rename from cuda/nvrtc.pyx.in rename to cuda/cuda/bindings/nvrtc.pyx.in diff --git a/cuda/cudart.pxd.in b/cuda/cuda/bindings/runtime.pxd.in similarity index 99% rename from cuda/cudart.pxd.in rename to cuda/cuda/bindings/runtime.pxd.in index 9db3286ad18..a82708b6409 100644 --- a/cuda/cudart.pxd.in +++ b/cuda/cuda/bindings/runtime.pxd.in @@ -5,9 +5,9 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. -cimport cuda.ccudart as ccudart -cimport cuda._lib.utils as utils -cimport cuda.cuda as cuda +cimport cuda.bindings.cyruntime as ccudart +cimport cuda.bindings._lib.utils as utils +cimport cuda.bindings.driver as cuda {{if 'cudaArray_t' in found_types}} diff --git a/cuda/cudart.pyx.in b/cuda/cuda/bindings/runtime.pyx.in similarity index 99% rename from cuda/cudart.pyx.in rename to cuda/cuda/bindings/runtime.pyx.in index 5b868d98666..c58817bf8f6 100644 --- a/cuda/cudart.pyx.in +++ b/cuda/cuda/bindings/runtime.pyx.in @@ -17,7 +17,7 @@ from libc.limits cimport CHAR_MIN from libcpp.vector cimport vector from cpython.buffer cimport PyObject_CheckBuffer, PyObject_GetBuffer, PyBuffer_Release, PyBUF_SIMPLE, PyBUF_ANY_CONTIGUOUS from cpython.bytes cimport PyBytes_FromStringAndSize -import cuda.cuda +import cuda.bindings.driver ctypedef unsigned long long signed_char_ptr ctypedef unsigned long long unsigned_char_ptr diff --git a/cuda/cuda/bindings/tests/__init__.py b/cuda/cuda/bindings/tests/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/cuda/tests/test_ccuda.pyx b/cuda/cuda/bindings/tests/test_ccuda.pyx similarity index 91% rename from cuda/tests/test_ccuda.pyx rename to cuda/cuda/bindings/tests/test_ccuda.pyx index 9bd08650544..0d90ba90985 100644 --- a/cuda/tests/test_ccuda.pyx +++ b/cuda/cuda/bindings/tests/test_ccuda.pyx @@ -9,6 +9,8 @@ from libc.string cimport ( memset, memcmp ) +# TODO: update to new module once the old ones are removed, we use the +# tests to cover backward compatibility. cimport cuda.ccuda as ccuda def test_ccuda_memcpy(): @@ -53,4 +55,4 @@ def test_ccuda_memcpy(): err = ccuda.cuMemFree(dptr) assert(err == 0) err = ccuda.cuCtxDestroy(ctx) - assert(err == 0) \ No newline at end of file + assert(err == 0) diff --git a/cuda/tests/test_ccudart.pyx b/cuda/cuda/bindings/tests/test_ccudart.pyx similarity index 95% rename from cuda/tests/test_ccudart.pyx rename to cuda/cuda/bindings/tests/test_ccudart.pyx index a871fa6f6a4..b228661c8db 100644 --- a/cuda/tests/test_ccudart.pyx +++ b/cuda/cuda/bindings/tests/test_ccudart.pyx @@ -9,6 +9,8 @@ from libc.string cimport ( memset, memcmp ) +# TODO: update to new module once the old ones are removed, we use the +# tests to cover backward compatibility. cimport cuda.ccudart as ccudart def test_ccudart_memcpy(): diff --git a/cuda/tests/test_cuda.py b/cuda/cuda/bindings/tests/test_cuda.py similarity index 100% rename from cuda/tests/test_cuda.py rename to cuda/cuda/bindings/tests/test_cuda.py diff --git a/cuda/tests/test_cudart.py b/cuda/cuda/bindings/tests/test_cudart.py similarity index 100% rename from cuda/tests/test_cudart.py rename to cuda/cuda/bindings/tests/test_cudart.py diff --git a/cuda/tests/test_cython.py b/cuda/cuda/bindings/tests/test_cython.py similarity index 85% rename from cuda/tests/test_cython.py rename to cuda/cuda/bindings/tests/test_cython.py index 4787742f27e..e5577ede339 100644 --- a/cuda/tests/test_cython.py +++ b/cuda/cuda/bindings/tests/test_cython.py @@ -22,9 +22,9 @@ def wrapped(*args, **kwargs): return wrapped -cython_test_modules = ["cuda.tests.test_ccuda", - "cuda.tests.test_ccudart", - "cuda.tests.test_interoperability_cython"] +cython_test_modules = ["cuda.bindings.tests.test_ccuda", + "cuda.bindings.tests.test_ccudart", + "cuda.bindings.tests.test_interoperability_cython"] for mod in cython_test_modules: diff --git a/cuda/tests/test_interoperability.py b/cuda/cuda/bindings/tests/test_interoperability.py similarity index 100% rename from cuda/tests/test_interoperability.py rename to cuda/cuda/bindings/tests/test_interoperability.py diff --git a/cuda/tests/test_interoperability_cython.pyx b/cuda/cuda/bindings/tests/test_interoperability_cython.pyx similarity index 98% rename from cuda/tests/test_interoperability_cython.pyx rename to cuda/cuda/bindings/tests/test_interoperability_cython.pyx index 96b50ce5bb0..5c58e8eae33 100644 --- a/cuda/tests/test_interoperability_cython.pyx +++ b/cuda/cuda/bindings/tests/test_interoperability_cython.pyx @@ -5,6 +5,9 @@ # this software. Any use, reproduction, disclosure, or distribution of # this software and related documentation outside the terms of the EULA # is strictly prohibited. + +# TODO: update to new module once the old ones are removed, we use the +# tests to cover backward compatibility. import pytest import cuda.cuda as cuda import cuda.cudart as cudart diff --git a/cuda/tests/test_kernelParams.py b/cuda/cuda/bindings/tests/test_kernelParams.py similarity index 100% rename from cuda/tests/test_kernelParams.py rename to cuda/cuda/bindings/tests/test_kernelParams.py diff --git a/cuda/tests/test_nvrtc.py b/cuda/cuda/bindings/tests/test_nvrtc.py similarity index 100% rename from cuda/tests/test_nvrtc.py rename to cuda/cuda/bindings/tests/test_nvrtc.py diff --git a/cuda/cuda/ccuda.pxd b/cuda/cuda/ccuda.pxd new file mode 100644 index 00000000000..73f3fc5cb4f --- /dev/null +++ b/cuda/cuda/ccuda.pxd @@ -0,0 +1,7 @@ +from cuda.bindings.cydriver cimport * + +cdef extern from *: + """ + #pragma message ( "The cuda.ccuda module is deprecated and will be removed in a future release, " \ + "please switch to use the cuda.bindings.cydriver module instead." ) + """ diff --git a/cuda/cuda/ccuda.pyx b/cuda/cuda/ccuda.pyx new file mode 100644 index 00000000000..6f6a0a8f5c8 --- /dev/null +++ b/cuda/cuda/ccuda.pyx @@ -0,0 +1,8 @@ +from cuda.bindings.cydriver cimport * + + +cdef extern from *: + """ + #pragma message ( "The cuda.ccuda module is deprecated and will be removed in a future release, " \ + "please switch to use the cuda.bindings.cydriver module instead." ) + """ diff --git a/cuda/cuda/ccudart.pxd b/cuda/cuda/ccudart.pxd new file mode 100644 index 00000000000..b32eece8149 --- /dev/null +++ b/cuda/cuda/ccudart.pxd @@ -0,0 +1,7 @@ +from cuda.bindings.cyruntime cimport * + +cdef extern from *: + """ + #pragma message ( "The cuda.ccudart module is deprecated and will be removed in a future release, " \ + "please switch to use the cuda.bindings.cyruntime module instead." ) + """ diff --git a/cuda/cuda/ccudart.pyx b/cuda/cuda/ccudart.pyx new file mode 100644 index 00000000000..b32eece8149 --- /dev/null +++ b/cuda/cuda/ccudart.pyx @@ -0,0 +1,7 @@ +from cuda.bindings.cyruntime cimport * + +cdef extern from *: + """ + #pragma message ( "The cuda.ccudart module is deprecated and will be removed in a future release, " \ + "please switch to use the cuda.bindings.cyruntime module instead." ) + """ diff --git a/cuda/cuda/cnvrtc.pxd b/cuda/cuda/cnvrtc.pxd new file mode 100644 index 00000000000..a84893e0311 --- /dev/null +++ b/cuda/cuda/cnvrtc.pxd @@ -0,0 +1,8 @@ +from cuda.bindings.cynvrtc cimport * + + +cdef extern from *: + """ + #pragma message ( "The cuda.cnvrtc module is deprecated and will be removed in a future release, " \ + "please switch to use the cuda.bindings.cynvrtc module instead." ) + """ diff --git a/cuda/cuda/cnvrtc.pyx b/cuda/cuda/cnvrtc.pyx new file mode 100644 index 00000000000..a84893e0311 --- /dev/null +++ b/cuda/cuda/cnvrtc.pyx @@ -0,0 +1,8 @@ +from cuda.bindings.cynvrtc cimport * + + +cdef extern from *: + """ + #pragma message ( "The cuda.cnvrtc module is deprecated and will be removed in a future release, " \ + "please switch to use the cuda.bindings.cynvrtc module instead." ) + """ diff --git a/cuda/cuda/cuda.pyx b/cuda/cuda/cuda.pyx new file mode 100644 index 00000000000..f8b197f7163 --- /dev/null +++ b/cuda/cuda/cuda.pyx @@ -0,0 +1,14 @@ +import warnings as _warnings + +from cuda.bindings.driver import * + + +cdef extern from *: + """ + #pragma message ( "The cuda.cuda module is deprecated and will be removed in a future release, " \ + "please switch to use the cuda.bindings.driver module instead." ) + """ + + +_warnings.warn("The cuda.cuda module is deprecated and will be removed in a future release, " + "please switch to use the cuda.bindings.driver module instead.", DeprecationWarning, stacklevel=2) diff --git a/cuda/cuda/cudart.pyx b/cuda/cuda/cudart.pyx new file mode 100644 index 00000000000..8c342df8050 --- /dev/null +++ b/cuda/cuda/cudart.pyx @@ -0,0 +1,14 @@ +import warnings as _warnings + +from cuda.bindings.runtime import * + + +cdef extern from *: + """ + #pragma message ( "The cuda.cudart module is deprecated and will be removed in a future release, " \ + "please switch to use the cuda.bindings.runtime module instead." ) + """ + + +_warnings.warn("The cuda.cudart module is deprecated and will be removed in a future release, " + "please switch to use the cuda.bindings.runtime module instead.", DeprecationWarning, stacklevel=2) diff --git a/cuda/cuda/nvrtc.pyx b/cuda/cuda/nvrtc.pyx new file mode 100644 index 00000000000..4a9e048f272 --- /dev/null +++ b/cuda/cuda/nvrtc.pyx @@ -0,0 +1,14 @@ +import warnings as _warnings + +from cuda.bindings.nvrtc import * + + +cdef extern from *: + """ + #pragma message ( "The cuda.nvrtc module is deprecated and will be removed in a future release, " \ + "please switch to use the cuda.bindings.nvrtc module instead." ) + """ + + +_warnings.warn("The cuda.nvrtc module is deprecated and will be removed in a future release, " + "please switch to use the cuda.bindings.nvrtc module instead.", DeprecationWarning, stacklevel=2) diff --git a/pyproject.toml b/cuda/pyproject.toml similarity index 94% rename from pyproject.toml rename to cuda/pyproject.toml index 470fe642408..f4c9c5bc6c1 100644 --- a/pyproject.toml +++ b/cuda/pyproject.toml @@ -52,7 +52,7 @@ Documentation = "https://nvidia.github.io/cuda-python/" [tool.versioneer] VCS = "git" style = "pep440" -versionfile_source = "cuda/_version.py" -versionfile_build = "cuda/_version.py" +versionfile_source = "cuda/bindings/_version.py" +versionfile_build = "cuda/bindings/_version.py" tag_prefix = "v" parentdir_prefix = "cuda-python-" diff --git a/pytest.ini b/cuda/pytest.ini similarity index 100% rename from pytest.ini rename to cuda/pytest.ini diff --git a/requirements.txt b/cuda/requirements.txt similarity index 100% rename from requirements.txt rename to cuda/requirements.txt diff --git a/setup.py b/cuda/setup.py similarity index 82% rename from setup.py rename to cuda/setup.py index 62fec10f13d..2135ee98f62 100644 --- a/setup.py +++ b/cuda/setup.py @@ -6,18 +6,21 @@ # this software and related documentation outside the terms of the EULA # is strictly prohibited. -from Cython import Tempita -from Cython.Build import cythonize +import glob import os import platform -from pyclibrary import CParser import sys import sysconfig + +from Cython import Tempita +from Cython.Build import cythonize +from pyclibrary import CParser from setuptools import find_packages, setup from setuptools.extension import Extension from setuptools.command.build_ext import build_ext import versioneer + # ---------------------------------------------------------------------- # Fetch configuration options @@ -116,6 +119,7 @@ def unwrapMembers(found_dict): # ---------------------------------------------------------------------- # Generate + def fetch_input_files(path): return [os.path.join(path, f) for f in os.listdir(path) if f.endswith('.in')] @@ -136,9 +140,10 @@ def generate_output(infile, local): f.write(pxdcontent) path_list = [os.path.join('cuda'), - os.path.join('cuda', '_cuda'), - os.path.join('cuda', '_lib'), - os.path.join('cuda', '_lib', 'ccudart')] + os.path.join('cuda', 'bindings'), + os.path.join('cuda', 'bindings', '_cuda'), + os.path.join('cuda', 'bindings', '_lib'), + os.path.join('cuda', 'bindings', '_lib', 'ccudart')] input_files = [] for path in path_list: input_files += fetch_input_files(path) @@ -182,39 +187,53 @@ def generate_output(infile, local): # ---------------------------------------------------------------------- # Cythonize -def do_cythonize(sources): +def prep_extensions(sources): + pattern = sources[0] + files = glob.glob(pattern) + exts = [] + for pyx in files: + mod_name = pyx.replace(".pyx", "").replace(os.sep, ".") + exts.append( + Extension( + mod_name, + sources=[pyx, *sources[1:]], + include_dirs=include_dirs, + library_dirs=library_dirs, + runtime_library_dirs=[], + libraries=[], + language="c++", + extra_compile_args=extra_compile_args, + ) + ) + return exts + + +def do_cythonize(extensions): return cythonize( - [ - Extension( - "*", - sources=sources, - include_dirs=include_dirs, - library_dirs=library_dirs, - runtime_library_dirs=[], - libraries=[], - language="c++", - extra_compile_args=extra_compile_args, - ) - ], - nthreads=nthreads, - compiler_directives=dict( - profile=True, language_level=3, embedsignature=True, binding=True - ), - **extra_cythonize_kwargs) + extensions, + nthreads=nthreads, + compiler_directives=dict( + profile=True, language_level=3, embedsignature=True, binding=True + ), + **extra_cythonize_kwargs) + sources_list = [ # private - ["cuda/_cuda/*.pyx", "cuda/_cuda/loader.cpp"], + ["cuda/bindings/_cuda/*.pyx", "cuda/bindings/_cuda/loader.cpp"], # utils - ["cuda/_lib/*.pyx", "cuda/_lib/param_packer.cpp"], - ["cuda/_lib/ccudart/*.pyx"], + ["cuda/bindings/_lib/*.pyx", "cuda/bindings/_lib/param_packer.cpp"], + ["cuda/bindings/_lib/ccudart/*.pyx"], # public + ["cuda/bindings/*.pyx"], + # public (deprecated, to be removed) ["cuda/*.pyx"], # tests - ["cuda/tests/*.pyx"]] + ["cuda/bindings/tests/*.pyx"], +] for sources in sources_list: - extensions += do_cythonize(sources) + extensions += prep_extensions(sources) # --------------------------------------------------------------------- # Custom build_ext command @@ -240,11 +259,11 @@ def finalize_options(self): setup( version=versioneer.get_version(), - ext_modules=extensions, + ext_modules=do_cythonize(extensions), packages=find_packages(include=["cuda", "cuda.*"]), package_data=dict.fromkeys( - find_packages(include=["cuda", "cuda.*"]), - ["*.pxd", "*.pyx", "*.h", "*.cpp"], + find_packages(include=["cuda.*"]), + ["*.pxd", "*.pyx", "*.py", "*.h", "*.cpp"], ), cmdclass=cmdclass, zip_safe=False,