Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move everything to cuda.core.experimental #171

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions cuda_core/cuda/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Empty file.
9 changes: 9 additions & 0 deletions cuda_core/cuda/core/experimental/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions cuda_core/docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. module:: cuda.core
.. module:: cuda.core.experimental

``cuda.core`` API Reference
===========================
``cuda.core.experimental`` API Reference
========================================

CUDA runtime
------------
Expand Down
6 changes: 3 additions & 3 deletions cuda_core/examples/saxpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions cuda_core/examples/vector_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions cuda_core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ dependencies = [
]


[tool.setuptools]
packages = ["cuda", "cuda.core"]
[tool.setuptools.packages.find]
include = ["cuda.core*"]
leofang marked this conversation as resolved.
Show resolved Hide resolved


[tool.setuptools.dynamic]
Expand Down
19 changes: 7 additions & 12 deletions cuda_core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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++",
),
)
Expand All @@ -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,
)