@@ -8,6 +8,63 @@ cuTile Python is a programming language for NVIDIA GPUs. The official documentat
88on [ docs.nvidia.com] ( https://docs.nvidia.com/cuda/cutile-python ) ,
99or built from source located in the [ docs] ( docs/ ) folder.
1010
11+
12+ Example
13+ -------
14+ ``` python
15+ # This examples uses CuPy which can be installed via `pip install cupy-cuda13x`
16+ # Make sure cuda toolkit 13.1+ is installed: https://developer.nvidia.com/cuda-downloads
17+
18+ import cuda.tile as ct
19+ import cupy
20+
21+ TILE_SIZE = 16
22+
23+ # cuTile kernel for adding two dense vectors. It runs in parallel on the GPU.
24+ @ct.kernel
25+ def vector_add_kernel (a , b , result ):
26+ block_id = ct.bid(0 )
27+ a_tile = ct.load(a, index = (block_id,), shape = (TILE_SIZE ,))
28+ b_tile = ct.load(b, index = (block_id,), shape = (TILE_SIZE ,))
29+ result_tile = a_tile + b_tile
30+ ct.store(result, index = (block_id,), tile = result_tile)
31+
32+ # Host-side function that launches the above kernel.
33+ def vector_add (a : cupy.ndarray, b : cupy.ndarray, result : cupy.ndarray):
34+ assert a.shape == b.shape == result.shape
35+ grid = (ct.cdiv(a.shape[0 ], TILE_SIZE ), 1 , 1 )
36+ ct.launch(cupy.cuda.get_current_stream(), grid, vector_add_kernel, (a, b, result))
37+
38+
39+ import numpy as np
40+
41+ def test_vector_add ():
42+ a = cupy.random.uniform(- 5 , 5 , 128 )
43+ b = cupy.random.uniform(- 5 , 5 , 128 )
44+ result = cupy.zeros_like(a)
45+
46+ vector_add(a, b, result)
47+
48+ a_np = cupy.asnumpy(a)
49+ b_np = cupy.asnumpy(b)
50+ result_np = cupy.asnumpy(result)
51+
52+ expected = a_np + b_np
53+ np.testing.assert_array_almost_equal(result_np, expected)
54+
55+ test_vector_add()
56+ ```
57+
58+ System Requirements
59+ -------------------
60+ cuTile Python generates kernels based on [ Tile IR] ( https://docs.nvidia.com/cuda/tile-ir/ )
61+ which requries NVIDIA Driver r580 or later to run.
62+ Furthermore, the ` tileiras ` compiler only supports Blackwell GPU with 13.1 release, but the
63+ restriction will be removed in the coming versions.
64+ Checkout the [ prerequisites] ( https://docs.nvidia.com/cuda/cutile-python/quickstart.html#prerequisites )
65+ for full list of requirements.
66+
67+
1168Installing from PyPI
1269--------------------
1370cuTile Python is published on [ PyPI] ( https://pypi.org/ ) under the
@@ -16,7 +73,10 @@ cuTile Python is published on [PyPI](https://pypi.org/) under the
1673pip install cuda-tile
1774```
1875Currently, the [ CUDA Toolkit 13.1+] ( https://developer.nvidia.com/cuda-downloads ) is required
19- and needs to be installed separately.
76+ and needs to be installed separately. On a Debian-based system, use `apt-get install
77+ cuda-tileiras-13.1 cuda-compiler-13.1` instead of ` apt-get install cuda-toolkit-13.1`
78+ if you wish to avoid installing the full CUDA Toolkit.
79+
2080
2181Building from Source
2282--------------------
@@ -79,4 +139,4 @@ Copyright and License Information
79139---------------------------------
80140Copyright © 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
81141
82- cuTile-Python is under Apache 2.0 license. See the [ LICENSES] ( LICENSES/ ) folder for the full license text.
142+ cuTile-Python is licensed under the Apache 2.0 license. See the [ LICENSES] ( LICENSES/ ) folder for the full license text.
0 commit comments