From 9839793f7bca1284aef8bde1a17622dbcec3e989 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Tue, 15 Oct 2024 22:22:17 +0000 Subject: [PATCH] move everything to under the experimental namespace --- cuda_core/cuda/core/__init__.py | 5 ----- cuda_core/cuda/core/experimental/__init__.pxd | 0 cuda_core/cuda/core/experimental/__init__.py | 9 +++++++++ .../cuda/core/{ => experimental}/_context.py | 2 +- .../cuda/core/{ => experimental}/_device.py | 10 +++++----- .../cuda/core/{ => experimental}/_dlpack.pxd | 0 .../cuda/core/{ => experimental}/_dlpack.pyx | 0 .../cuda/core/{ => experimental}/_event.py | 6 +++--- .../_kernel_arg_handler.pyx | 2 +- .../cuda/core/{ => experimental}/_launcher.py | 10 +++++----- .../cuda/core/{ => experimental}/_memory.py | 6 +++--- .../core/{ => experimental}/_memoryview.pyx | 2 +- .../cuda/core/{ => experimental}/_module.py | 2 +- .../cuda/core/{ => experimental}/_program.py | 4 ++-- .../cuda/core/{ => experimental}/_stream.py | 14 +++++++------- .../cuda/core/{ => experimental}/_utils.py | 0 .../cuda/core/{ => experimental}/dlpack.h | 0 .../cuda/core/{ => experimental}/utils.py | 2 +- cuda_core/docs/source/api.rst | 6 +++--- cuda_core/examples/saxpy.py | 6 +++--- cuda_core/examples/vector_add.py | 6 +++--- cuda_core/pyproject.toml | 4 ++-- cuda_core/setup.py | 19 +++++++------------ 23 files changed, 57 insertions(+), 58 deletions(-) create mode 100644 cuda_core/cuda/core/experimental/__init__.pxd create mode 100644 cuda_core/cuda/core/experimental/__init__.py rename cuda_core/cuda/core/{ => experimental}/_context.py (91%) rename cuda_core/cuda/core/{ => experimental}/_device.py (94%) rename cuda_core/cuda/core/{ => experimental}/_dlpack.pxd (100%) rename cuda_core/cuda/core/{ => experimental}/_dlpack.pyx (100%) rename cuda_core/cuda/core/{ => experimental}/_event.py (94%) rename cuda_core/cuda/core/{ => experimental}/_kernel_arg_handler.pyx (99%) rename cuda_core/cuda/core/{ => experimental}/_launcher.py (90%) rename cuda_core/cuda/core/{ => experimental}/_memory.py (97%) rename cuda_core/cuda/core/{ => experimental}/_memoryview.pyx (99%) rename cuda_core/cuda/core/{ => experimental}/_module.py (97%) rename cuda_core/cuda/core/{ => experimental}/_program.py (96%) rename cuda_core/cuda/core/{ => experimental}/_stream.py (95%) rename cuda_core/cuda/core/{ => experimental}/_utils.py (100%) rename cuda_core/cuda/core/{ => experimental}/dlpack.h (100%) rename cuda_core/cuda/core/{ => experimental}/utils.py (65%) diff --git a/cuda_core/cuda/core/__init__.py b/cuda_core/cuda/core/__init__.py index cec6e8d9..715a9d91 100644 --- a/cuda_core/cuda/core/__init__.py +++ b/cuda_core/cuda/core/__init__.py @@ -2,9 +2,4 @@ # # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE -from cuda.core._device import Device -from cuda.core._event import EventOptions -from cuda.core._launcher import LaunchConfig, launch -from cuda.core._program import Program -from cuda.core._stream import Stream, StreamOptions from cuda.core._version import __version__ diff --git a/cuda_core/cuda/core/experimental/__init__.pxd b/cuda_core/cuda/core/experimental/__init__.pxd new file mode 100644 index 00000000..e69de29b diff --git a/cuda_core/cuda/core/experimental/__init__.py b/cuda_core/cuda/core/experimental/__init__.py new file mode 100644 index 00000000..9b978398 --- /dev/null +++ b/cuda_core/cuda/core/experimental/__init__.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. +# +# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE + +from cuda.core.experimental._device import Device +from cuda.core.experimental._event import EventOptions +from cuda.core.experimental._launcher import LaunchConfig, launch +from cuda.core.experimental._program import Program +from cuda.core.experimental._stream import Stream, StreamOptions diff --git a/cuda_core/cuda/core/_context.py b/cuda_core/cuda/core/experimental/_context.py similarity index 91% rename from cuda_core/cuda/core/_context.py rename to cuda_core/cuda/core/experimental/_context.py index 5d0f5adf..216953ab 100644 --- a/cuda_core/cuda/core/_context.py +++ b/cuda_core/cuda/core/experimental/_context.py @@ -5,7 +5,7 @@ from dataclasses import dataclass from cuda import cuda, cudart -from cuda.core._utils import handle_return +from cuda.core.experimental._utils import handle_return @dataclass diff --git a/cuda_core/cuda/core/_device.py b/cuda_core/cuda/core/experimental/_device.py similarity index 94% rename from cuda_core/cuda/core/_device.py rename to cuda_core/cuda/core/experimental/_device.py index 1268da32..65d5fe9b 100644 --- a/cuda_core/cuda/core/_device.py +++ b/cuda_core/cuda/core/experimental/_device.py @@ -7,11 +7,11 @@ import warnings from cuda import cuda, cudart -from cuda.core._utils import handle_return, ComputeCapability, CUDAError, \ +from cuda.core.experimental._utils import handle_return, ComputeCapability, CUDAError, \ precondition -from cuda.core._context import Context, ContextOptions -from cuda.core._memory import _DefaultAsyncMempool, Buffer, MemoryResource -from cuda.core._stream import default_stream, Stream, StreamOptions +from cuda.core.experimental._context import Context, ContextOptions +from cuda.core.experimental._memory import _DefaultAsyncMempool, Buffer, MemoryResource +from cuda.core.experimental._stream import default_stream, Stream, StreamOptions _tls = threading.local() @@ -125,7 +125,7 @@ def set_current(self, ctx: Context=None) -> Union[Context, None]: Entry point of this object. Users always start a code by calling this method, e.g. - >>> from cuda.core import Device + >>> from cuda.core.experimental import Device >>> dev0 = Device(0) >>> dev0.set_current() >>> # ... do work on device 0 ... diff --git a/cuda_core/cuda/core/_dlpack.pxd b/cuda_core/cuda/core/experimental/_dlpack.pxd similarity index 100% rename from cuda_core/cuda/core/_dlpack.pxd rename to cuda_core/cuda/core/experimental/_dlpack.pxd diff --git a/cuda_core/cuda/core/_dlpack.pyx b/cuda_core/cuda/core/experimental/_dlpack.pyx similarity index 100% rename from cuda_core/cuda/core/_dlpack.pyx rename to cuda_core/cuda/core/experimental/_dlpack.pyx diff --git a/cuda_core/cuda/core/_event.py b/cuda_core/cuda/core/experimental/_event.py similarity index 94% rename from cuda_core/cuda/core/_event.py rename to cuda_core/cuda/core/experimental/_event.py index 5fbacae1..3c85d9fe 100644 --- a/cuda_core/cuda/core/_event.py +++ b/cuda_core/cuda/core/experimental/_event.py @@ -6,9 +6,9 @@ from typing import Optional from cuda import cuda -from cuda.core._utils import check_or_create_options -from cuda.core._utils import CUDAError -from cuda.core._utils import handle_return +from cuda.core.experimental._utils import check_or_create_options +from cuda.core.experimental._utils import CUDAError +from cuda.core.experimental._utils import handle_return @dataclass diff --git a/cuda_core/cuda/core/_kernel_arg_handler.pyx b/cuda_core/cuda/core/experimental/_kernel_arg_handler.pyx similarity index 99% rename from cuda_core/cuda/core/_kernel_arg_handler.pyx rename to cuda_core/cuda/core/experimental/_kernel_arg_handler.pyx index f2d392a8..15846282 100644 --- a/cuda_core/cuda/core/_kernel_arg_handler.pyx +++ b/cuda_core/cuda/core/experimental/_kernel_arg_handler.pyx @@ -15,7 +15,7 @@ import ctypes import numpy -from cuda.core._memory import Buffer +from cuda.core.experimental._memory import Buffer ctypedef cpp_complex.complex[float] cpp_single_complex diff --git a/cuda_core/cuda/core/_launcher.py b/cuda_core/cuda/core/experimental/_launcher.py similarity index 90% rename from cuda_core/cuda/core/_launcher.py rename to cuda_core/cuda/core/experimental/_launcher.py index 03d7fc08..614fabcf 100644 --- a/cuda_core/cuda/core/_launcher.py +++ b/cuda_core/cuda/core/experimental/_launcher.py @@ -8,11 +8,11 @@ import numpy as np from cuda import cuda, cudart -from cuda.core._kernel_arg_handler import ParamHolder -from cuda.core._memory import Buffer -from cuda.core._module import Kernel -from cuda.core._stream import Stream -from cuda.core._utils import CUDAError, check_or_create_options, handle_return +from cuda.core.experimental._kernel_arg_handler import ParamHolder +from cuda.core.experimental._memory import Buffer +from cuda.core.experimental._module import Kernel +from cuda.core.experimental._stream import Stream +from cuda.core.experimental._utils import CUDAError, check_or_create_options, handle_return @dataclass diff --git a/cuda_core/cuda/core/_memory.py b/cuda_core/cuda/core/experimental/_memory.py similarity index 97% rename from cuda_core/cuda/core/_memory.py rename to cuda_core/cuda/core/experimental/_memory.py index 0d5dd0d1..4ef2cbc3 100644 --- a/cuda_core/cuda/core/_memory.py +++ b/cuda_core/cuda/core/experimental/_memory.py @@ -9,9 +9,9 @@ import warnings from cuda import cuda -from cuda.core._dlpack import DLDeviceType, make_py_capsule -from cuda.core._stream import default_stream -from cuda.core._utils import handle_return +from cuda.core.experimental._dlpack import DLDeviceType, make_py_capsule +from cuda.core.experimental._stream import default_stream +from cuda.core.experimental._utils import handle_return PyCapsule = TypeVar("PyCapsule") diff --git a/cuda_core/cuda/core/_memoryview.pyx b/cuda_core/cuda/core/experimental/_memoryview.pyx similarity index 99% rename from cuda_core/cuda/core/_memoryview.pyx rename to cuda_core/cuda/core/experimental/_memoryview.pyx index 8f7cc948..1f467344 100644 --- a/cuda_core/cuda/core/_memoryview.pyx +++ b/cuda_core/cuda/core/experimental/_memoryview.pyx @@ -12,7 +12,7 @@ from typing import Any, Optional from cuda import cuda import numpy -from cuda.core._utils import handle_return +from cuda.core.experimental._utils import handle_return # TODO(leofang): support NumPy structured dtypes diff --git a/cuda_core/cuda/core/_module.py b/cuda_core/cuda/core/experimental/_module.py similarity index 97% rename from cuda_core/cuda/core/_module.py rename to cuda_core/cuda/core/experimental/_module.py index 98926363..a179faf8 100644 --- a/cuda_core/cuda/core/_module.py +++ b/cuda_core/cuda/core/experimental/_module.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE from cuda import cuda, cudart -from cuda.core._utils import handle_return +from cuda.core.experimental._utils import handle_return _backend = { diff --git a/cuda_core/cuda/core/_program.py b/cuda_core/cuda/core/experimental/_program.py similarity index 96% rename from cuda_core/cuda/core/_program.py rename to cuda_core/cuda/core/experimental/_program.py index 0c0f02d7..b6271544 100644 --- a/cuda_core/cuda/core/_program.py +++ b/cuda_core/cuda/core/experimental/_program.py @@ -3,8 +3,8 @@ # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE from cuda import nvrtc -from cuda.core._utils import handle_return -from cuda.core._module import ObjectCode +from cuda.core.experimental._utils import handle_return +from cuda.core.experimental._module import ObjectCode class Program: diff --git a/cuda_core/cuda/core/_stream.py b/cuda_core/cuda/core/experimental/_stream.py similarity index 95% rename from cuda_core/cuda/core/_stream.py rename to cuda_core/cuda/core/experimental/_stream.py index e815f9a8..95f8ec50 100644 --- a/cuda_core/cuda/core/_stream.py +++ b/cuda_core/cuda/core/experimental/_stream.py @@ -9,13 +9,13 @@ from typing import Optional, Tuple, TYPE_CHECKING, Union if TYPE_CHECKING: - from cuda.core._device import Device + from cuda.core.experimental._device import Device from cuda import cuda, cudart -from cuda.core._context import Context -from cuda.core._event import Event, EventOptions -from cuda.core._utils import check_or_create_options -from cuda.core._utils import get_device_from_ctx -from cuda.core._utils import handle_return +from cuda.core.experimental._context import Context +from cuda.core.experimental._event import Event, EventOptions +from cuda.core.experimental._utils import check_or_create_options +from cuda.core.experimental._utils import get_device_from_ctx +from cuda.core.experimental._utils import handle_return @dataclass @@ -181,7 +181,7 @@ def device(self) -> Device: # Note that Stream.device.context might not necessarily agree with # Stream.context, in cases where a different CUDA context is set # current after a stream was created. - from cuda.core._device import Device # avoid circular import + from cuda.core.experimental._device import Device # avoid circular import if self._device_id is None: # Get the stream context first if self._ctx_handle is None: diff --git a/cuda_core/cuda/core/_utils.py b/cuda_core/cuda/core/experimental/_utils.py similarity index 100% rename from cuda_core/cuda/core/_utils.py rename to cuda_core/cuda/core/experimental/_utils.py diff --git a/cuda_core/cuda/core/dlpack.h b/cuda_core/cuda/core/experimental/dlpack.h similarity index 100% rename from cuda_core/cuda/core/dlpack.h rename to cuda_core/cuda/core/experimental/dlpack.h diff --git a/cuda_core/cuda/core/utils.py b/cuda_core/cuda/core/experimental/utils.py similarity index 65% rename from cuda_core/cuda/core/utils.py rename to cuda_core/cuda/core/experimental/utils.py index 3debe1df..74f41e4d 100644 --- a/cuda_core/cuda/core/utils.py +++ b/cuda_core/cuda/core/experimental/utils.py @@ -2,4 +2,4 @@ # # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE -from cuda.core._memoryview import StridedMemoryView, viewable +from cuda.core.experimental._memoryview import StridedMemoryView, viewable diff --git a/cuda_core/docs/source/api.rst b/cuda_core/docs/source/api.rst index 1f4b8a69..756ed776 100644 --- a/cuda_core/docs/source/api.rst +++ b/cuda_core/docs/source/api.rst @@ -1,7 +1,7 @@ -.. module:: cuda.core +.. module:: cuda.core.experimental -``cuda.core`` API Reference -=========================== +``cuda.core.experimental`` API Reference +======================================== CUDA runtime ------------ diff --git a/cuda_core/examples/saxpy.py b/cuda_core/examples/saxpy.py index 7d296deb..37ad4933 100644 --- a/cuda_core/examples/saxpy.py +++ b/cuda_core/examples/saxpy.py @@ -4,9 +4,9 @@ import sys -from cuda.core import Device -from cuda.core import LaunchConfig, launch -from cuda.core import Program +from cuda.core.experimental import Device +from cuda.core.experimental import LaunchConfig, launch +from cuda.core.experimental import Program import cupy as cp diff --git a/cuda_core/examples/vector_add.py b/cuda_core/examples/vector_add.py index 8248ad3b..baee409a 100644 --- a/cuda_core/examples/vector_add.py +++ b/cuda_core/examples/vector_add.py @@ -2,9 +2,9 @@ # # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE -from cuda.core import Device -from cuda.core import LaunchConfig, launch -from cuda.core import Program +from cuda.core.experimental import Device +from cuda.core.experimental import LaunchConfig, launch +from cuda.core.experimental import Program import cupy as cp diff --git a/cuda_core/pyproject.toml b/cuda_core/pyproject.toml index cf1e5b4e..2b497245 100644 --- a/cuda_core/pyproject.toml +++ b/cuda_core/pyproject.toml @@ -46,8 +46,8 @@ dependencies = [ ] -[tool.setuptools] -packages = ["cuda", "cuda.core"] +[tool.setuptools.packages.find] +include = ["cuda.core*"] [tool.setuptools.dynamic] diff --git a/cuda_core/setup.py b/cuda_core/setup.py index 862d38d3..8d20f2c9 100644 --- a/cuda_core/setup.py +++ b/cuda_core/setup.py @@ -5,24 +5,24 @@ import os from Cython.Build import cythonize -from setuptools import setup, Extension, find_packages +from setuptools import setup, Extension from setuptools.command.build_ext import build_ext as _build_ext ext_modules = ( Extension( - "cuda.core._dlpack", - sources=["cuda/core/_dlpack.pyx"], + "cuda.core.experimental._dlpack", + sources=["cuda/core/experimental/_dlpack.pyx"], language="c++", ), Extension( - "cuda.core._memoryview", - sources=["cuda/core/_memoryview.pyx"], + "cuda.core.experimental._memoryview", + sources=["cuda/core/experimental/_memoryview.pyx"], language="c++", ), Extension( - "cuda.core._kernel_arg_handler", - sources=["cuda/core/_kernel_arg_handler.pyx"], + "cuda.core.experimental._kernel_arg_handler", + sources=["cuda/core/experimental/_kernel_arg_handler.pyx"], language="c++", ), ) @@ -39,11 +39,6 @@ def build_extensions(self): ext_modules=cythonize(ext_modules, verbose=True, language_level=3, compiler_directives={'embedsignature': True}), - packages=find_packages(include=['cuda.core', 'cuda.core.*']), - package_data=dict.fromkeys( - find_packages(include=["cuda.core.*"]), - ["*.pxd", "*.pyx", "*.py"], - ), cmdclass = {'build_ext': build_ext,}, zip_safe=False, )