Skip to content

Commit 051cb1a

Browse files
Copilotleofang
andcommitted
Fix reStructuredText rendering issues: hyperlinks, code block introductions, and syntax errors
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
1 parent 6e99356 commit 051cb1a

6 files changed

Lines changed: 33 additions & 29 deletions

File tree

cuda_bindings/docs/source/install.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Installing from PyPI
2727
2828
$ pip install -U cuda-python
2929
30-
Install all optional dependencies with:
30+
Install all optional dependencies with::
31+
3132
.. code-block:: console
3233
3334
pip install -U cuda-python[all]
@@ -52,7 +53,8 @@ Installing from Conda
5253

5354
When using conda, the ``cuda-version`` metapackage can be used to control the versions of CUDA Toolkit components that are installed to the conda environment.
5455

55-
For example:
56+
For example::
57+
5658
.. code-block:: console
5759
5860
$ conda install -c conda-forge cuda-python cuda-version=13
@@ -70,7 +72,7 @@ Requirements
7072

7173
[^2]: The CUDA Runtime static library (``libcudart_static.a`` on Linux, ``cudart_static.lib`` on Windows) is part of the CUDA Toolkit. If using conda packages, it is contained in the ``cuda-cudart-static`` package.
7274

73-
Source builds require that the provided CUDA headers are of the same major.minor version as the ``cuda.bindings`` you're trying to build. Despite this requirement, note that the minor version compatibility is still maintained. Use the ``CUDA_HOME`` (or ``CUDA_PATH``) environment variable to specify the location of your headers. For example, if your headers are located in ``/usr/local/cuda/include``, then you should set ``CUDA_HOME`` with:
75+
Source builds require that the provided CUDA headers are of the same major.minor version as the ``cuda.bindings`` you're trying to build. Despite this requirement, note that the minor version compatibility is still maintained. Use the ``CUDA_HOME`` (or ``CUDA_PATH``) environment variable to specify the location of your headers. For example, if your headers are located in ``/usr/local/cuda/include``, then you should set ``CUDA_HOME`` with::
7476

7577
.. code-block:: console
7678
@@ -85,7 +87,7 @@ See `Environment Variables <environment_variables.rst>`_ for a description of ot
8587
Editable Install
8688
^^^^^^^^^^^^^^^^
8789

88-
You can use
90+
You can use::
8991

9092
.. code-block:: console
9193

cuda_bindings/docs/source/overview.rst

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import this dependency as well.
4848
import numpy as np
4949
5050
Error checking is a fundamental best practice when working with low-level interfaces.
51-
The following code snippet lets us validate each API call and raise exceptions in case of error.
51+
The following code snippet lets us validate each API call and raise exceptions in case of error.::
5252

5353
.. code-block:: python
5454
@@ -99,7 +99,7 @@ Go ahead and compile the kernel into PTX. Remember that this is executed at runt
9999

100100
In the following code example, the Driver API is initialized so that the NVIDIA driver
101101
and GPU are accessible. Next, the GPU is queried for their compute capability. Finally,
102-
the program is compiled to target our local compute capability architecture with FMAD disabled.
102+
the program is compiled to target our local compute capability architecture with FMAD disabled.::
103103

104104
.. code-block:: python
105105
@@ -129,7 +129,7 @@ the program is compiled to target our local compute capability architecture with
129129
Before you can use the PTX or do any work on the GPU, you must create a CUDA
130130
context. CUDA contexts are analogous to host processes for the device. In the
131131
following code example, a handle for compute device 0 is passed to
132-
``cuCtxCreate`` to designate that GPU for context creation.
132+
``cuCtxCreate`` to designate that GPU for context creation.::
133133

134134
.. code-block:: python
135135
@@ -139,7 +139,7 @@ following code example, a handle for compute device 0 is passed to
139139
With a CUDA context created on device 0, load the PTX generated earlier into a
140140
module. A module is analogous to dynamically loaded libraries for the device.
141141
After loading into the module, extract a specific kernel with
142-
``cuModuleGetFunction``. It is not uncommon for multiple kernels to reside in PTX.
142+
``cuModuleGetFunction``. It is not uncommon for multiple kernels to reside in PTX.::
143143

144144
.. code-block:: python
145145
@@ -152,7 +152,7 @@ After loading into the module, extract a specific kernel with
152152
Next, get all your data prepared and transferred to the GPU. For increased
153153
application performance, you can input data on the device to eliminate data
154154
transfers. For completeness, this example shows how you would transfer data to
155-
and from the device.
155+
and from the device.::
156156

157157
.. code-block:: python
158158
@@ -175,7 +175,7 @@ execution.
175175

176176
Python doesn't have a natural concept of pointers, yet ``cuMemcpyHtoDAsync`` expects
177177
``void*``. This is where we leverage NumPy's data types to retrieve each host data pointer
178-
by calling ``XX.ctypes.data`` for the associated XX.
178+
by calling ``XX.ctypes.data`` for the associated XX.::
179179

180180
.. code-block:: python
181181
@@ -196,7 +196,7 @@ With data prep and resources allocation finished, the kernel is ready to be
196196
launched. To pass the location of the data on the device to the kernel execution
197197
configuration, you must retrieve the device pointer. In the following code
198198
example, we call ``int(XXclass)`` to retrieve the device pointer value for the
199-
associated XXclass as a Python ``int`` and wrap it in a ``np.array`` type.
199+
associated XXclass as a Python ``int`` and wrap it in a ``np.array`` type.::
200200

201201
.. code-block:: python
202202
@@ -209,14 +209,14 @@ but this time it's of type ``void**``. What this means is that our argument list
209209
be a contiguous array of ``void*`` elements, where each element is the pointer to a kernel
210210
argument on either host or device. Since we already prepared each of our arguments into a ``np.array`` type, the
211211
construction of our final contiguous array is done by retrieving the ``XX.ctypes.data``
212-
of each kernel argument.
212+
of each kernel argument.::
213213

214214
.. code-block:: python
215215
216216
args = [a, dX, dY, dOut, n]
217217
args = np.array([arg.ctypes.data for arg in args], dtype=np.uint64)
218218
219-
Now the kernel can be launched:
219+
Now the kernel can be launched::
220220

221221
.. code-block:: python
222222
@@ -245,7 +245,7 @@ data transfers. That ensures that the kernel's compute is performed only after
245245
the data has finished transfer, as all API calls and kernel launches within a
246246
stream are serialized. After the call to transfer data back to the host is
247247
executed, ``cuStreamSynchronize`` is used to halt CPU execution until all operations
248-
in the designated stream are finished.
248+
in the designated stream are finished.::
249249

250250
.. code-block:: python
251251
@@ -255,7 +255,7 @@ in the designated stream are finished.
255255
raise ValueError("Error outside tolerance for host-device vectors")
256256
257257
Perform verification of the data to ensure correctness and finish the code with
258-
memory clean up.
258+
memory clean up.::
259259

260260
.. code-block:: python
261261
@@ -277,7 +277,7 @@ kernel performance and `CUDA
277277
Events <https://developer.nvidia.com/blog/how-implement-performance-metrics-cuda-cc/>`_
278278
was used for application performance.
279279

280-
The following command was used to profile the applications:
280+
The following command was used to profile the applications::
281281

282282
.. code-block:: shell
283283
@@ -323,7 +323,8 @@ Using NumPy
323323

324324
NumPy `Array objects <https://numpy.org/doc/stable/reference/arrays.html>`_ can be used to fulfill each of these conditions directly.
325325

326-
Let's use the following kernel definition as an example:
326+
Let's use the following kernel definition as an example::
327+
327328
.. code-block:: python
328329
329330
kernel_string = """
@@ -403,7 +404,8 @@ This example uses the following types:
403404

404405
Note how all three pointers are ``np.intp`` since the pointer values are always a representation of an address space.
405406

406-
Putting it all together:
407+
Putting it all together::
408+
407409
.. code-block:: python
408410
409411
# Define a custom type
@@ -427,13 +429,13 @@ Putting it all together:
427429
The final step is to construct a ``kernelParams`` argument that fulfills all of the launch API conditions. This is made easy because each array object comes
428430
with a `ctypes <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.ctypes.html#numpy.ndarray.ctypes>`_ data attribute that returns the underlying ``void*`` pointer value.
429431

430-
By having the final array object contain all pointers, we fulfill the contiguous array requirement:
432+
By having the final array object contain all pointers, we fulfill the contiguous array requirement::
431433

432434
.. code-block:: python
433435
434436
kernelParams = np.array([arg.ctypes.data for arg in kernelValues], dtype=np.intp)
435437
436-
The launch API supports `Buffer Protocol <https://docs.python.org/3/c-api/buffer.html>`_ objects, therefore we can pass the array object directly.
438+
The launch API supports `Buffer Protocol <https://docs.python.org/3/c-api/buffer.html>`_ objects, therefore we can pass the array object directly.::
437439

438440
.. code-block:: python
439441
@@ -461,7 +463,7 @@ The ctypes approach treats the ``kernelParams`` argument as a pair of two tuples
461463
The ctypes `fundamental data types <https://docs.python.org/3/library/ctypes.html#fundamental-data-types>`_ documentation describes the compatibility between different Python types and C types.
462464
Furthermore, `custom data types <https://docs.python.org/3/library/ctypes.html#calling-functions-with-your-own-custom-data-types>`_ can be used to support kernels with custom types.
463465

464-
For this example the result becomes:
466+
For this example the result becomes::
465467

466468
.. code-block:: python
467469
@@ -500,7 +502,7 @@ Values that are set to ``None`` have a special meaning:
500502

501503
In all three cases, the API call will fetch the underlying pointer value and construct a contiguous array with other kernel parameters.
502504

503-
With the setup complete, the kernel can be launched:
505+
With the setup complete, the kernel can be launched::
504506

505507
.. code-block:: python
506508
@@ -518,7 +520,7 @@ CUDA objects
518520

519521
Certain CUDA kernels use native CUDA types as their parameters such as ``cudaTextureObject_t``. These types require special handling since they're neither a primitive ctype nor a custom user type. Since ``cuda.bindings`` exposes each of them as Python classes, they each implement ``getPtr()`` and ``__int__()``. These two callables used to support the NumPy and ctypes approach. The difference between each call is further described under `Tips and Tricks <https://nvidia.github.io/cuda-python/cuda-bindings/latest/tips_and_tricks.html#>`_.
520522

521-
For this example, lets use the ``transformKernel`` from `examples/0_Introduction/simpleCubemapTexture_test.py <https://github.com/NVIDIA/cuda-python/blob/main/cuda_bindings/examples/0_Introduction/simpleCubemapTexture_test.py>`_:
523+
For this example, lets use the ``transformKernel`` from `examples/0_Introduction/simpleCubemapTexture_test.py <https://github.com/NVIDIA/cuda-python/blob/main/cuda_bindings/examples/0_Introduction/simpleCubemapTexture_test.py>`_::
522524

523525
.. code-block:: python
524526
@@ -537,7 +539,7 @@ For this example, lets use the ``transformKernel`` from `examples/0_Introduction
537539
tex = checkCudaErrors(cudart.cudaCreateTextureObject(texRes, texDescr, None))
538540
...
539541
540-
For NumPy, we can convert these CUDA types by leveraging the ``__int__()`` call to fetch the address of the underlying ``cudaTextureObject_t`` C object and wrapping it in a NumPy object array of type ``np.intp``:
542+
For NumPy, we can convert these CUDA types by leveraging the ``__int__()`` call to fetch the address of the underlying ``cudaTextureObject_t`` C object and wrapping it in a NumPy object array of type ``np.intp``::
541543

542544
.. code-block:: python
543545
@@ -548,7 +550,7 @@ For NumPy, we can convert these CUDA types by leveraging the ``__int__()`` call
548550
)
549551
kernelArgs = np.array([arg.ctypes.data for arg in kernelValues], dtype=np.intp)
550552
551-
For ctypes, we leverage the special handling of ``None`` type since each Python class already implements ``getPtr()``:
553+
For ctypes, we leverage the special handling of ``None`` type since each Python class already implements ``getPtr()``::
552554

553555
.. code-block:: python
554556

cuda_python/docs/source/release/11.8.6-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Released on January 24, 2025.
99
Included components
1010
-------------------
1111

12-
- ``cuda.bindings` 11.8.6 <https://nvidia.github.io/cuda-python/cuda-bindings/12.8.0/release/11.8.6-notes.html>`_
12+
* `cuda.bindings 11.8.6 <https://nvidia.github.io/cuda-python/cuda-bindings/12.8.0/release/11.8.6-notes.html>`_
1313

1414
Highlights
1515
----------

cuda_python/docs/source/release/12.6.1-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Released on Oct 7, 2024
99
Included components
1010
-------------------
1111

12-
- ``cuda.bindings` 12.6.1 <https://nvidia.github.io/cuda-python/cuda-bindings/12.6.1/release/12.6.1-notes.html>`_
12+
* `cuda.bindings 12.6.1 <https://nvidia.github.io/cuda-python/cuda-bindings/12.6.1/release/12.6.1-notes.html>`_
1313

1414
Hightlights
1515
-----------

cuda_python/docs/source/release/12.6.2-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Released on November 5, 2024. Post 1 rebuild released on November 12, 2024.
99
Included components
1010
-------------------
1111

12-
- ``cuda.bindings` 12.6.2 <https://nvidia.github.io/cuda-python/cuda-bindings/12.6.2/release/12.6.2-notes.html>`_
12+
* `cuda.bindings 12.6.2 <https://nvidia.github.io/cuda-python/cuda-bindings/12.6.2/release/12.6.2-notes.html>`_
1313

1414
Hightlights
1515
-----------

cuda_python/docs/source/release/12.8.0-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Released on January 24, 2025.
99
Included components
1010
-------------------
1111

12-
- ``cuda.bindings` 12.8.0 <https://nvidia.github.io/cuda-python/cuda-bindings/12.8.0/release/12.8.0-notes.html>`_
12+
* `cuda.bindings 12.8.0 <https://nvidia.github.io/cuda-python/cuda-bindings/12.8.0/release/12.8.0-notes.html>`_
1313

1414
Highlights
1515
----------

0 commit comments

Comments
 (0)