Skip to content

Commit d576dda

Browse files
Copilotleofang
andcommitted
Fix reStructuredText issues: correct cross-refs, links, and code blocks
Co-authored-by: leofang <[email protected]>
1 parent 2a3b6f3 commit d576dda

File tree

3 files changed

+23
-35
lines changed

3 files changed

+23
-35
lines changed

cuda_bindings/docs/source/conduct.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ members of the project's leadership.
8484
Attribution
8585
-----------
8686

87-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
87+
This Code of Conduct is adapted from the `Contributor Covenant <https://www.contributor-covenant.org>`_, version 1.4,
8888
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
8989

90-
[homepage]: https://www.contributor-covenant.org
91-
9290
For answers to common questions about this code of conduct, see
9391
https://www.contributor-covenant.org/faq

cuda_core/docs/source/conduct.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ members of the project's leadership.
8484
Attribution
8585
-----------
8686

87-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
87+
This Code of Conduct is adapted from the `Contributor Covenant <https://www.contributor-covenant.org>`_, version 1.4,
8888
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
8989

90-
[homepage]: https://www.contributor-covenant.org
91-
9290
For answers to common questions about this code of conduct, see
9391
https://www.contributor-covenant.org/faq
Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.. SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
.. SPDX-License-Identifier: Apache-2.0
33
4+
.. currentmodule:: cuda.core.experimental
5+
46
Overview
57
========
68

@@ -18,26 +20,25 @@ including:
1820
- and much more!
1921

2022
Rather than providing 1:1 equivalents of the CUDA driver and runtime APIs
21-
(for that, see [``cuda.bindings``][bindings]), ``cuda.core`` provides high-level constructs such as:
23+
(for that, see `cuda.bindings <https://nvidia.github.io/cuda-python/cuda-bindings/latest/>`_), ``cuda.core`` provides high-level constructs such as:
2224

23-
- {class}``Device <cuda.core.experimental.Device>`` class for GPU device operations and context management.
24-
- {class}``Buffer <cuda.core.experimental.Buffer>`` and {class}``MemoryResource <cuda.core.experimental.MemoryResource>`` classes for memory allocation and management.
25-
- {class}``Program <cuda.core.experimental.Program>`` for JIT compilation of CUDA kernels.
26-
- {class}``GraphBuilder <cuda.core.experimental.GraphBuilder>`` for building and executing CUDA graphs.
27-
- {class}``Stream <cuda.core.experimental.Stream>`` and {class}``Event <cuda.core.experimental.Event>`` for asynchronous execution and timing.
25+
- :class:`Device` class for GPU device operations and context management.
26+
- :class:`Buffer` and :class:`MemoryResource` classes for memory allocation and management.
27+
- :class:`Program` for JIT compilation of CUDA kernels.
28+
- :class:`GraphBuilder` for building and executing CUDA graphs.
29+
- :class:`Stream` and :class:`Event` for asynchronous execution and timing.
2830

2931
Example: Compiling and Launching a CUDA kernel
3032
----------------------------------------------
3133

3234
To get a taste for ``cuda.core``, let's walk through a simple example that compiles and launches a vector addition kernel.
33-
You can find the complete example in [``vector_add.py``][vector_add_example].
35+
You can find the complete example in `vector_add.py <https://github.com/NVIDIA/cuda-python/tree/main/cuda_core/examples/vector_add.py>`_.
3436

3537
First, we define a string containing the CUDA C++ kernel. Note that this is a templated kernel:
3638

3739
.. code-block:: python
3840
39-
compute c = a + b
40-
=================
41+
# compute c = a + b
4142
code = """
4243
template<typename T>
4344
__global__ void vector_add(const T* A,
@@ -51,9 +52,9 @@ First, we define a string containing the CUDA C++ kernel. Note that this is a te
5152
}
5253
"""
5354
54-
Next, we create a {class}``Device <cuda.core.experimental.Device>`` object
55-
and a corresponding {class}``Stream <cuda.core.experimental.Stream>``.
56-
Don't forget to use {meth}``Device.set_current() <cuda.core.experimental.Device.set_current>``!
55+
Next, we create a :class:`Device` object
56+
and a corresponding :class:`Stream`.
57+
Don't forget to use :meth:`Device.set_current`!
5758

5859
.. code-block:: python
5960
@@ -64,9 +65,9 @@ Don't forget to use {meth}``Device.set_current() <cuda.core.experimental.Device.
6465
dev.set_current()
6566
s = dev.create_stream()
6667
67-
Next, we compile the CUDA C++ kernel from earlier using the {class}``Program <cuda.core.experimental.Program>`` class.
68+
Next, we compile the CUDA C++ kernel from earlier using the :class:`Program` class.
6869
The result of the compilation is saved as a CUBIN.
69-
Note the use of the ``name_expressions`` parameter to the {meth}``Program.compile() <cuda.core.experimental.Program.compile>`` method to specify which kernel template instantiations to compile:
70+
Note the use of the ``name_expressions`` parameter to the :meth:`Program.compile` method to specify which kernel template instantiations to compile:
7071

7172
.. code-block:: python
7273
@@ -76,28 +77,26 @@ Note the use of the ``name_expressions`` parameter to the {meth}``Program.compil
7677
mod = prog.compile("cubin", name_expressions=("vector_add<float>",))
7778
7879
Next, we retrieve the compiled kernel from the CUBIN and prepare the arguments and kernel configuration.
79-
We're using [CuPy][cupy] arrays as inputs for this example, but you can use PyTorch tensors too
80-
(we show how to do this in one of our [examples][examples]).
80+
We're using `CuPy <https://cupy.dev/>`_ arrays as inputs for this example, but you can use PyTorch tensors too
81+
(we show how to do this in one of our `examples <https://github.com/NVIDIA/cuda-python/tree/main/cuda_core/examples>`_).
8182

8283
.. code-block:: python
8384
8485
ker = mod.get_kernel("vector_add<float>")
8586
86-
Prepare input/output arrays (using CuPy)
87-
========================================
87+
# Prepare input/output arrays (using CuPy)
8888
size = 50000
8989
rng = cp.random.default_rng()
9090
a = rng.random(size, dtype=cp.float32)
9191
b = rng.random(size, dtype=cp.float32)
9292
c = cp.empty_like(a)
9393
94-
Configure launch parameters
95-
===========================
94+
# Configure launch parameters
9695
block = 256
9796
grid = (size + block - 1) // block
9897
config = LaunchConfig(grid=grid, block=block)
9998
100-
Finally, we use the {func}``launch <cuda.core.experimental.launch>`` function to execute our kernel on the specified stream with the given configuration and arguments. Note the use of ``.data.ptr`` to get the pointer to the array data.
99+
Finally, we use the :func:`launch` function to execute our kernel on the specified stream with the given configuration and arguments. Note the use of ``.data.ptr`` to get the pointer to the array data.
101100

102101
.. code-block:: python
103102
@@ -113,11 +112,4 @@ Examples and Recipes
113112
As we mentioned before, ``cuda.core`` can do much more than just compile and launch kernels.
114113

115114
The best way to explore and learn the different features ``cuda.core`` is through
116-
our [``examples``][examples]. Find one that matches your use-case, and modify it to fit your needs!
117-
118-
[bindings]: https://nvidia.github.io/cuda-python/cuda-bindings/latest/
119-
[cai]: https://numba.readthedocs.io/en/stable/cuda/cuda_array_interface.html
120-
[cupy]: https://cupy.dev/
121-
[dlpack]: https://dmlc.github.io/dlpack/latest/
122-
[examples]: https://github.com/NVIDIA/cuda-python/tree/main/cuda_core/examples
123-
[vector_add_example]: https://github.com/NVIDIA/cuda-python/tree/main/cuda_core/examples/vector_add.py
115+
our `examples <https://github.com/NVIDIA/cuda-python/tree/main/cuda_core/examples>`_. Find one that matches your use-case, and modify it to fit your needs!

0 commit comments

Comments
 (0)