Skip to content

Commit

Permalink
make the link to different object types explicit for the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ksimpson-work committed Nov 28, 2024
1 parent fd71ced commit 0076720
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
32 changes: 16 additions & 16 deletions cuda_core/cuda/core/experimental/_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class Device:
and use the same GPU device.
While acting as the entry point, many other CUDA resources can be
allocated such as streams and buffers. Any :obj:`Context` dependent
allocated such as streams and buffers. Any :obj:`~cuda.core.experimental._context.Context` dependent
resource created through this device, will continue to refer to
this device's context.
Newly returend :obj:`Device` object are is a thread-local singleton
Newly returned :obj:`~cuda.core.experimental._device.Device` objects are thread-local singletons
for a specified device.
Note
Expand All @@ -37,7 +37,7 @@ class Device:
Parameters
----------
device_id : int, optional
Device ordinal to return a :obj:`Device` object for.
Device ordinal to return a :obj:`~cuda.core.experimental._device.Device` object for.
Default value of `None` return the currently used device.
"""
Expand Down Expand Up @@ -134,7 +134,7 @@ def compute_capability(self) -> ComputeCapability:
@property
@precondition(_check_context_initialized)
def context(self) -> Context:
"""Return the current :obj:`Context` associated with this device.
"""Return the current :obj:`~cuda.core.experimental._context.Context` associated with this device.
Note
----
Expand All @@ -147,7 +147,7 @@ def context(self) -> Context:

@property
def memory_resource(self) -> MemoryResource:
"""Return :obj:`MemoryResource` associated with this device."""
"""Return :obj:`~cuda.core.experimental._memory.MemoryResource` associated with this device."""
return self._mr

@memory_resource.setter
Expand All @@ -158,7 +158,7 @@ def memory_resource(self, mr):

@property
def default_stream(self) -> Stream:
"""Return default CUDA :obj:`Stream` associated with this device.
"""Return default CUDA :obj:`~cuda.core.experimental._stream.Stream` associated with this device.
The type of default stream returned depends on if the environment
variable CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM is set.
Expand All @@ -181,18 +181,18 @@ def set_current(self, ctx: Context = None) -> Union[Context, None]:
Initializes CUDA and sets the calling thread to a valid CUDA
context. By default the primary context is used, but optional `ctx`
parameter can be used to explicitly supply a :obj:`Context` object.
parameter can be used to explicitly supply a :obj:`~cuda.core.experimental._context.Context` object.
Providing a `ctx` causes the previous set context to be popped and returned.
Parameters
----------
ctx : :obj:`Context`, optional
ctx : :obj:`~cuda.core.experimental._context.Context`, optional
Optional context to push onto this device's current thread stack.
Returns
-------
Union[:obj:`Context`, None], optional
Union[:obj:`~cuda.core.experimental._context.Context`, None], optional
Popped context.
Examples
Expand Down Expand Up @@ -237,20 +237,20 @@ def set_current(self, ctx: Context = None) -> Union[Context, None]:
self._has_inited = True

def create_context(self, options: ContextOptions = None) -> Context:
"""Create a new :obj:`Context` object.
"""Create a new :obj:`~cuda.core.experimental._context.Context` object.
Note
----
The newly context will not be set as current.
Parameters
----------
options : :obj:`ContextOptions`, optional
options : :obj:`~cuda.core.experimental._context.ContextOptions`, optional
Customizable dataclass for context creation options.
Returns
-------
:obj:`Context`
:obj:`~cuda.core.experimental._context.Context`
Newly created context object.
"""
Expand All @@ -276,12 +276,12 @@ def create_stream(self, obj=None, options: StreamOptions = None) -> Stream:
----------
obj : Any, optional
Any object supporting the __cuda_stream__ protocol.
options : :obj:`StreamOptions`, optional
options : :obj:`~cuda.core.experimental._stream.StreamOptions`, optional
Customizable dataclass for stream creation options.
Returns
-------
:obj:`Stream`
:obj:`~cuda.core.experimental._stream.Stream`
Newly created stream object.
"""
Expand All @@ -304,13 +304,13 @@ def allocate(self, size, stream=None) -> Buffer:
----------
size : int
Number of bytes to allocate.
stream : :obj:`Stream`, optional
stream : :obj:`~cuda.core.experimental._stream.Stream`, optional
The stream establishing the stream ordering semantic.
Default value of `None` uses default stream.
Returns
-------
:obj:`Buffer`
:obj:`~cuda.core.experimental._memory.Buffer`
Newly created buffer object.
"""
Expand Down
6 changes: 3 additions & 3 deletions cuda_core/cuda/core/experimental/_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@dataclass
class EventOptions:
"""Customizable :obj:`Event` options.
"""Customizable :obj:`~cuda.core.experimental._event.Event` options.
Attributes
----------
Expand Down Expand Up @@ -45,8 +45,8 @@ class Event:
of work up to event's record, and help establish dependencies
between GPU work submissions.
Directly creating an :obj:`Event` is not supported due to ambiguity,
and they should instead be created through a :obj:`Stream` object.
Directly creating an :obj:`~cuda.core.experimental._event.Event` is not supported due to ambiguity,
and they should instead be created through a :obj:`~cuda.core.experimental._stream.Stream` object.
"""

Expand Down
6 changes: 3 additions & 3 deletions cuda_core/cuda/core/experimental/_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LaunchConfig:
Group of threads (Thread Block) that will execute on the same
multiprocessor. Threads within a thread blocks have access to
shared memory and can be explicitly synchronized.
stream : :obj:`Stream`
stream : :obj:`~cuda.core.experimental._stream.Stream`
The stream establishing the stream ordering semantic of a
launch.
shmem_size : int, optional
Expand Down Expand Up @@ -103,9 +103,9 @@ def launch(kernel, config, *kernel_args):
----------
kernel : :obj:`~cuda.core.experimental._module.Kernel`
Kernel to launch.
config : :obj:`LaunchConfig`
config : :obj:`~cuda.core.experimental._launcher.LaunchConfig`
Launch configurations inline with options provided by
:obj:`LaunchConfig` dataclass.
:obj:`~cuda.core.experimental._launcher.LaunchConfig` dataclass.
*kernel_args : Any
Variable length argument list that is provided to the
launching kernel.
Expand Down
6 changes: 3 additions & 3 deletions cuda_core/cuda/core/experimental/_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Buffer:
Allocated buffer handle object
size : Any
Memory size of the buffer
mr : :obj:`MemoryResource`, optional
mr : :obj:`~cuda.core.experimental._memory.MemoryResource`, optional
Memory resource associated with the buffer
"""
Expand Down Expand Up @@ -119,7 +119,7 @@ def copy_to(self, dst: Buffer = None, *, stream) -> Buffer:
Parameters
----------
dst : :obj:`Buffer`
dst : :obj:`~cuda.core.experimental._memory.Buffer`
Source buffer to copy data from
stream : Any
Keyword argument specifying the stream for the
Expand All @@ -142,7 +142,7 @@ def copy_from(self, src: Buffer, *, stream):
Parameters
----------
src : :obj:`Buffer`
src : :obj:`~cuda.core.experimental._memory.Buffer`
Source buffer to copy data from
stream : Any
Keyword argument specifying the stream for the
Expand Down
8 changes: 4 additions & 4 deletions cuda_core/cuda/core/experimental/_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class Kernel:
Kernel instances can execution when passed directly into the
:func:`~cuda.core.experimental.launch` function.
Directly creating a :obj:`Kernel` is not supported, and they
should instead be created through a :obj:`ObjectCode` object.
Directly creating a :obj:`~cuda.core.experimental._module.Kernel` is not supported, and they
should instead be created through a :obj:`~cuda.core.experimental._module.ObjectCode` object.
"""

Expand Down Expand Up @@ -153,7 +153,7 @@ def __del__(self):
pass

def get_kernel(self, name):
"""Return the :obj:`Kernel` of a specified name from this object code.
"""Return the :obj:`~cuda.core.experimental._module.Kernel` of a specified name from this object code.
Parameters
----------
Expand All @@ -162,7 +162,7 @@ def get_kernel(self, name):
Returns
-------
:obj:`Kernel`
:obj:`~cuda.core.experimental._module.Kernel`
Newly created kernel object.
"""
Expand Down
2 changes: 1 addition & 1 deletion cuda_core/cuda/core/experimental/_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def compile(self, target_type, options=(), name_expressions=(), logs=None):
Supported options are "ptx", "cubin" and "ltoir".
options : Union[List, Tuple], optional
List of compilation options associated with the backend
of this :obj:`Program`. (Default to no options)
of this :obj:`~cuda.core.experimental._program.Program`. (Default to no options)
name_expressions : Union[List, Tuple], optional
List of explicit name expressions to become accessible.
(Default to no expressions)
Expand Down
28 changes: 14 additions & 14 deletions cuda_core/cuda/core/experimental/_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@dataclass
class StreamOptions:
"""Customizable :obj:`Stream` options.
"""Customizable :obj:`~cuda.core.experimental._stream.Stream` options.
Attributes
----------
Expand All @@ -40,13 +40,13 @@ class Stream:
Applications use streams to control the order of execution for
GPU work. Work within a single stream are executed sequentially.
Whereas work across multiple streams can be further controlled
using stream priorities and :obj:`Event` managements.
using stream priorities and :obj:`~cuda.core.experimental._event.Event` managements.
Advanced users can utilize default streams for enforce complex
implicit synchronization behaviors.
Directly creating a :obj:`Stream` is not supported due to ambiguity.
New streams should instead be created through a :obj:`Device`
Directly creating a :obj:`~cuda.core.experimental._stream.Stream` is not supported due to ambiguity.
New streams should instead be created through a :obj:`~cuda.core.experimental._device.Device`
object, or created directly through using an existing handle
using Stream.from_handle().
Expand Down Expand Up @@ -172,14 +172,14 @@ def record(self, event: Event = None, options: EventOptions = None) -> Event:
Parameters
----------
event : :obj:`Event`, optional
event : :obj:`~cuda.core.experimental._event.Event`, optional
Optional event object to be reused for recording.
options : :obj:`EventOptions`, optional
Customizable dataclass for event creation options.
Returns
-------
:obj:`Event`
:obj:`~cuda.core.experimental._event.Event`
Newly created event object.
"""
Expand All @@ -198,8 +198,8 @@ def wait(self, event_or_stream: Union[Event, Stream]):
Waiting for an event or a stream establishes a stream order.
If a :obj:`Stream` is provided, then wait until the stream's
work is completed. This is done by recording a new :obj:`Event`
If a :obj:`~cuda.core.experimental._stream.Stream` is provided, then wait until the stream's
work is completed. This is done by recording a new :obj:`~cuda.core.experimental._event.Event`
on the stream and then waiting on it.
"""
Expand All @@ -225,7 +225,7 @@ def wait(self, event_or_stream: Union[Event, Stream]):

@property
def device(self) -> Device:
"""Return the :obj:`Device` singleton associated with this stream.
"""Return the :obj:`~cuda.core.experimental._device.Device` singleton associated with this stream.
Note
----
Expand All @@ -245,7 +245,7 @@ def device(self) -> Device:

@property
def context(self) -> Context:
"""Return the :obj:`Context` associated with this stream."""
"""Return the :obj:`~cuda.core.experimental._context.Context` associated with this stream."""
if self._ctx_handle is None:
self._ctx_handle = handle_return(cuda.cuStreamGetCtx(self._handle))
if self._device_id is None:
Expand All @@ -254,10 +254,10 @@ def context(self) -> Context:

@staticmethod
def from_handle(handle: int) -> Stream:
"""Create a new :obj:`Stream` object from a foreign stream handle.
"""Create a new :obj:`~cuda.core.experimental._stream.Stream` object from a foreign stream handle.
Uses a cudaStream_t pointer address represented as a Python int
to create a new :obj:`Stream` object.
to create a new :obj:`~cuda.core.experimental._stream.Stream` object.
Note
----
Expand All @@ -272,7 +272,7 @@ def from_handle(handle: int) -> Stream:
Returns
-------
:obj:`Stream`
:obj:`~cuda.core.experimental._stream.Stream`
Newly created stream object.
"""
Expand Down Expand Up @@ -308,7 +308,7 @@ def __init__(self):


def default_stream():
"""Return the default CUDA :obj:`Stream`.
"""Return the default CUDA :obj:`~cuda.core.experimental._stream.Stream`.
The type of default stream returned depends on if the environment
variable CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM is set.
Expand Down

0 comments on commit 0076720

Please sign in to comment.