gstaichi 0.1.25.dev0__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. gstaichi/CHANGELOG.md +9 -0
  2. gstaichi/__init__.py +40 -0
  3. gstaichi/__main__.py +5 -0
  4. gstaichi/_funcs.py +706 -0
  5. gstaichi/_kernels.py +420 -0
  6. gstaichi/_lib/__init__.py +3 -0
  7. gstaichi/_lib/core/__init__.py +0 -0
  8. gstaichi/_lib/core/gstaichi_python.cp313-win_amd64.pyd +0 -0
  9. gstaichi/_lib/core/gstaichi_python.pyi +2937 -0
  10. gstaichi/_lib/core/py.typed +0 -0
  11. gstaichi/_lib/runtime/runtime_cuda.bc +0 -0
  12. gstaichi/_lib/runtime/runtime_x64.bc +0 -0
  13. gstaichi/_lib/runtime/slim_libdevice.10.bc +0 -0
  14. gstaichi/_lib/utils.py +249 -0
  15. gstaichi/_logging.py +131 -0
  16. gstaichi/_main.py +545 -0
  17. gstaichi/_snode/__init__.py +5 -0
  18. gstaichi/_snode/fields_builder.py +187 -0
  19. gstaichi/_snode/snode_tree.py +34 -0
  20. gstaichi/_test_tools/__init__.py +0 -0
  21. gstaichi/_test_tools/load_kernel_string.py +30 -0
  22. gstaichi/_version.py +1 -0
  23. gstaichi/_version_check.py +103 -0
  24. gstaichi/ad/__init__.py +3 -0
  25. gstaichi/ad/_ad.py +530 -0
  26. gstaichi/algorithms/__init__.py +3 -0
  27. gstaichi/algorithms/_algorithms.py +117 -0
  28. gstaichi/assets/.git +1 -0
  29. gstaichi/assets/Go-Regular.ttf +0 -0
  30. gstaichi/assets/static/imgs/ti_gallery.png +0 -0
  31. gstaichi/examples/minimal.py +28 -0
  32. gstaichi/experimental.py +16 -0
  33. gstaichi/lang/__init__.py +50 -0
  34. gstaichi/lang/_ndarray.py +352 -0
  35. gstaichi/lang/_ndrange.py +152 -0
  36. gstaichi/lang/_template_mapper.py +199 -0
  37. gstaichi/lang/_texture.py +172 -0
  38. gstaichi/lang/_wrap_inspect.py +189 -0
  39. gstaichi/lang/any_array.py +99 -0
  40. gstaichi/lang/argpack.py +411 -0
  41. gstaichi/lang/ast/__init__.py +5 -0
  42. gstaichi/lang/ast/ast_transformer.py +1318 -0
  43. gstaichi/lang/ast/ast_transformer_utils.py +341 -0
  44. gstaichi/lang/ast/ast_transformers/__init__.py +0 -0
  45. gstaichi/lang/ast/ast_transformers/call_transformer.py +267 -0
  46. gstaichi/lang/ast/ast_transformers/function_def_transformer.py +320 -0
  47. gstaichi/lang/ast/checkers.py +106 -0
  48. gstaichi/lang/ast/symbol_resolver.py +57 -0
  49. gstaichi/lang/ast/transform.py +9 -0
  50. gstaichi/lang/common_ops.py +310 -0
  51. gstaichi/lang/exception.py +80 -0
  52. gstaichi/lang/expr.py +180 -0
  53. gstaichi/lang/field.py +466 -0
  54. gstaichi/lang/impl.py +1241 -0
  55. gstaichi/lang/kernel_arguments.py +157 -0
  56. gstaichi/lang/kernel_impl.py +1382 -0
  57. gstaichi/lang/matrix.py +1881 -0
  58. gstaichi/lang/matrix_ops.py +341 -0
  59. gstaichi/lang/matrix_ops_utils.py +190 -0
  60. gstaichi/lang/mesh.py +687 -0
  61. gstaichi/lang/misc.py +778 -0
  62. gstaichi/lang/ops.py +1494 -0
  63. gstaichi/lang/runtime_ops.py +13 -0
  64. gstaichi/lang/shell.py +35 -0
  65. gstaichi/lang/simt/__init__.py +5 -0
  66. gstaichi/lang/simt/block.py +94 -0
  67. gstaichi/lang/simt/grid.py +7 -0
  68. gstaichi/lang/simt/subgroup.py +191 -0
  69. gstaichi/lang/simt/warp.py +96 -0
  70. gstaichi/lang/snode.py +489 -0
  71. gstaichi/lang/source_builder.py +150 -0
  72. gstaichi/lang/struct.py +855 -0
  73. gstaichi/lang/util.py +381 -0
  74. gstaichi/linalg/__init__.py +8 -0
  75. gstaichi/linalg/matrixfree_cg.py +310 -0
  76. gstaichi/linalg/sparse_cg.py +59 -0
  77. gstaichi/linalg/sparse_matrix.py +303 -0
  78. gstaichi/linalg/sparse_solver.py +123 -0
  79. gstaichi/math/__init__.py +11 -0
  80. gstaichi/math/_complex.py +205 -0
  81. gstaichi/math/mathimpl.py +886 -0
  82. gstaichi/profiler/__init__.py +6 -0
  83. gstaichi/profiler/kernel_metrics.py +260 -0
  84. gstaichi/profiler/kernel_profiler.py +586 -0
  85. gstaichi/profiler/memory_profiler.py +15 -0
  86. gstaichi/profiler/scoped_profiler.py +36 -0
  87. gstaichi/sparse/__init__.py +3 -0
  88. gstaichi/sparse/_sparse_grid.py +77 -0
  89. gstaichi/tools/__init__.py +12 -0
  90. gstaichi/tools/diagnose.py +117 -0
  91. gstaichi/tools/np2ply.py +364 -0
  92. gstaichi/tools/vtk.py +38 -0
  93. gstaichi/types/__init__.py +19 -0
  94. gstaichi/types/annotations.py +47 -0
  95. gstaichi/types/compound_types.py +90 -0
  96. gstaichi/types/enums.py +49 -0
  97. gstaichi/types/ndarray_type.py +147 -0
  98. gstaichi/types/primitive_types.py +206 -0
  99. gstaichi/types/quant.py +88 -0
  100. gstaichi/types/texture_type.py +85 -0
  101. gstaichi/types/utils.py +13 -0
  102. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools/cmake/SPIRV-ToolsConfig.cmake +5 -0
  103. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools/cmake/SPIRV-ToolsTarget-release.cmake +29 -0
  104. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools/cmake/SPIRV-ToolsTarget.cmake +113 -0
  105. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffConfig.cmake +5 -0
  106. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffTargets-release.cmake +19 -0
  107. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-diff/cmake/SPIRV-Tools-diffTargets.cmake +122 -0
  108. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkConfig.cmake +5 -0
  109. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkTargets-release.cmake +19 -0
  110. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-link/cmake/SPIRV-Tools-linkTargets.cmake +122 -0
  111. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintConfig.cmake +5 -0
  112. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintTargets-release.cmake +19 -0
  113. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-lint/cmake/SPIRV-Tools-lintTargets.cmake +122 -0
  114. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optConfig.cmake +5 -0
  115. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optTargets-release.cmake +19 -0
  116. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-opt/cmake/SPIRV-Tools-optTargets.cmake +122 -0
  117. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceConfig.cmake +5 -0
  118. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceTarget-release.cmake +19 -0
  119. gstaichi-0.1.25.dev0.data/data/SPIRV-Tools-reduce/cmake/SPIRV-Tools-reduceTarget.cmake +122 -0
  120. gstaichi-0.1.25.dev0.data/data/bin/SPIRV-Tools-shared.dll +0 -0
  121. gstaichi-0.1.25.dev0.data/data/include/spirv-tools/instrument.hpp +268 -0
  122. gstaichi-0.1.25.dev0.data/data/include/spirv-tools/libspirv.h +907 -0
  123. gstaichi-0.1.25.dev0.data/data/include/spirv-tools/libspirv.hpp +375 -0
  124. gstaichi-0.1.25.dev0.data/data/include/spirv-tools/linker.hpp +97 -0
  125. gstaichi-0.1.25.dev0.data/data/include/spirv-tools/optimizer.hpp +970 -0
  126. gstaichi-0.1.25.dev0.data/data/lib/SPIRV-Tools-diff.lib +0 -0
  127. gstaichi-0.1.25.dev0.data/data/lib/SPIRV-Tools-link.lib +0 -0
  128. gstaichi-0.1.25.dev0.data/data/lib/SPIRV-Tools-lint.lib +0 -0
  129. gstaichi-0.1.25.dev0.data/data/lib/SPIRV-Tools-opt.lib +0 -0
  130. gstaichi-0.1.25.dev0.data/data/lib/SPIRV-Tools-reduce.lib +0 -0
  131. gstaichi-0.1.25.dev0.data/data/lib/SPIRV-Tools-shared.lib +0 -0
  132. gstaichi-0.1.25.dev0.data/data/lib/SPIRV-Tools.lib +0 -0
  133. gstaichi-0.1.25.dev0.dist-info/METADATA +105 -0
  134. gstaichi-0.1.25.dev0.dist-info/RECORD +138 -0
  135. gstaichi-0.1.25.dev0.dist-info/WHEEL +5 -0
  136. gstaichi-0.1.25.dev0.dist-info/entry_points.txt +2 -0
  137. gstaichi-0.1.25.dev0.dist-info/licenses/LICENSE +201 -0
  138. gstaichi-0.1.25.dev0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,6 @@
1
+ # type: ignore
2
+
3
+ from gstaichi.profiler.kernel_metrics import *
4
+ from gstaichi.profiler.kernel_profiler import *
5
+ from gstaichi.profiler.memory_profiler import *
6
+ from gstaichi.profiler.scoped_profiler import *
@@ -0,0 +1,260 @@
1
+ # type: ignore
2
+
3
+ from gstaichi._lib import core as _ti_core
4
+
5
+
6
+ class CuptiMetric:
7
+ """A class to add CUPTI metric for :class:`~gstaichi.profiler.kernel_profiler.KernelProfiler`.
8
+
9
+ This class is designed to add user selected CUPTI metrics.
10
+ Only available for the CUDA backend now, i.e. you need ``ti.init(kernel_profiler=True, arch=ti.cuda)``.
11
+ For usage of this class, see examples in func :func:`~gstaichi.profiler.set_kernel_profiler_metrics` and :func:`~gstaichi.profiler.collect_kernel_profiler_metrics`.
12
+
13
+ Args:
14
+ name (str): name of metric that collected by CUPTI toolkit. used by :func:`~gstaichi.profiler.set_kernel_profiler_metrics` and :func:`~gstaichi.profiler.collect_kernel_profiler_metrics`.
15
+ header (str): column header of this metric, used by :func:`~gstaichi.profiler.print_kernel_profiler_info`.
16
+ val_format (str): format for print metric value (and unit of this value), used by :func:`~gstaichi.profiler.print_kernel_profiler_info`.
17
+ scale (float): scale of metric value, used by :func:`~gstaichi.profiler.print_kernel_profiler_info`.
18
+
19
+ Example::
20
+
21
+ >>> import gstaichi as ti
22
+
23
+ >>> ti.init(kernel_profiler=True, arch=ti.cuda)
24
+ >>> num_elements = 128*1024*1024
25
+
26
+ >>> x = ti.field(ti.f32, shape=num_elements)
27
+ >>> y = ti.field(ti.f32, shape=())
28
+ >>> y[None] = 0
29
+
30
+ >>> @ti.kernel
31
+ >>> def reduction():
32
+ >>> for i in x:
33
+ >>> y[None] += x[i]
34
+
35
+ >>> global_op_atom = ti.profiler.CuptiMetric(
36
+ >>> name='l1tex__t_set_accesses_pipe_lsu_mem_global_op_atom.sum',
37
+ >>> header=' global.atom ',
38
+ >>> val_format=' {:8.0f} ')
39
+
40
+ >>> # add and set user defined metrics
41
+ >>> profiling_metrics = ti.profiler.get_predefined_cupti_metrics('global_access') + [global_op_atom]
42
+ >>> ti.profiler.set_kernel_profile_metrics(profiling_metrics)
43
+
44
+ >>> for i in range(16):
45
+ >>> reduction()
46
+ >>> ti.profiler.print_kernel_profiler_info('trace')
47
+
48
+ Note:
49
+ For details about using CUPTI in GsTaichi, please visit https://docs.taichi-lang.org/docs/profiler#advanced-mode.
50
+ """
51
+
52
+ def __init__(self, name="", header="unnamed_header", val_format=" {:8.0f} ", scale=1.0):
53
+ self.name = name
54
+ self.header = header
55
+ self.val_format = val_format
56
+ self.scale = scale
57
+
58
+
59
+ # Global Memory Metrics
60
+ dram_utilization = CuptiMetric(
61
+ name="dram__throughput.avg.pct_of_peak_sustained_elapsed",
62
+ header=" global.uti ",
63
+ val_format=" {:6.2f} % ",
64
+ )
65
+
66
+ dram_bytes_sum = CuptiMetric(
67
+ name="dram__bytes.sum",
68
+ header=" global.R&W ",
69
+ val_format="{:9.3f} MB ",
70
+ scale=1.0 / 1024 / 1024,
71
+ )
72
+
73
+ dram_bytes_throughput = CuptiMetric(
74
+ name="dram__bytes.sum.per_second",
75
+ header=" global.R&W/s ",
76
+ val_format="{:8.3f} GB/s ",
77
+ scale=1.0 / 1024 / 1024 / 1024,
78
+ )
79
+
80
+ dram_bytes_read = CuptiMetric(
81
+ name="dram__bytes_read.sum",
82
+ header=" global.R ",
83
+ val_format="{:8.3f} MB ",
84
+ scale=1.0 / 1024 / 1024,
85
+ )
86
+
87
+ dram_read_throughput = CuptiMetric(
88
+ name="dram__bytes_read.sum.per_second",
89
+ header=" global.R/s ",
90
+ val_format="{:8.3f} GB/s ",
91
+ scale=1.0 / 1024 / 1024 / 1024,
92
+ )
93
+
94
+ dram_bytes_write = CuptiMetric(
95
+ name="dram__bytes_write.sum",
96
+ header=" global.W ",
97
+ val_format="{:8.3f} MB ",
98
+ scale=1.0 / 1024 / 1024,
99
+ )
100
+
101
+ dram_write_throughput = CuptiMetric(
102
+ name="dram__bytes_write.sum.per_second",
103
+ header=" global.W/s ",
104
+ val_format="{:8.3f} GB/s ",
105
+ scale=1.0 / 1024 / 1024 / 1024,
106
+ )
107
+
108
+ # Shared Memory Metrics
109
+ shared_utilization = CuptiMetric(
110
+ name="l1tex__data_pipe_lsu_wavefronts_mem_shared.avg.pct_of_peak_sustained_elapsed",
111
+ header=" uti.shared ",
112
+ val_format=" {:6.2f} % ",
113
+ )
114
+
115
+ shared_transactions_load = CuptiMetric(
116
+ name="l1tex__data_pipe_lsu_wavefronts_mem_shared_op_ld.sum",
117
+ header=" shared.trans.W ",
118
+ val_format=" {:10.0f} ",
119
+ )
120
+
121
+ shared_transactions_store = CuptiMetric(
122
+ name="l1tex__data_pipe_lsu_wavefronts_mem_shared_op_st.sum",
123
+ header=" shared.trans.R ",
124
+ val_format=" {:10.0f} ",
125
+ )
126
+
127
+ shared_bank_conflicts_store = CuptiMetric(
128
+ name="l1tex__data_bank_conflicts_pipe_lsu_mem_shared_op_st.sum",
129
+ header=" bank.conflict.W ",
130
+ val_format=" {:10.0f} ",
131
+ )
132
+
133
+ shared_bank_conflicts_load = CuptiMetric(
134
+ name="l1tex__data_bank_conflicts_pipe_lsu_mem_shared_op_ld.sum",
135
+ header=" bank.conflict.R ",
136
+ val_format=" {:10.0f} ",
137
+ )
138
+
139
+ # Atomic Metrics
140
+ global_op_atom = CuptiMetric(
141
+ name="l1tex__t_set_accesses_pipe_lsu_mem_global_op_atom.sum",
142
+ header=" global.atom ",
143
+ val_format=" {:8.0f} ",
144
+ )
145
+
146
+ global_op_reduction = CuptiMetric(
147
+ name="l1tex__t_set_accesses_pipe_lsu_mem_global_op_red.sum",
148
+ header=" global.red ",
149
+ val_format=" {:8.0f} ",
150
+ )
151
+
152
+ # Hardware Utilization Metrics
153
+ sm_throughput = CuptiMetric(
154
+ name="smsp__cycles_active.avg.pct_of_peak_sustained_elapsed",
155
+ header=" core.uti ",
156
+ val_format=" {:6.2f} % ",
157
+ )
158
+
159
+ dram_throughput = CuptiMetric(
160
+ name="gpu__dram_throughput.avg.pct_of_peak_sustained_elapsed",
161
+ header=" mem.uti ",
162
+ val_format=" {:6.2f} % ",
163
+ )
164
+
165
+ l1tex_throughput = CuptiMetric(
166
+ name="l1tex__throughput.avg.pct_of_peak_sustained_elapsed",
167
+ header=" L1.uti ",
168
+ val_format=" {:6.2f} % ",
169
+ )
170
+
171
+ l2_throughput = CuptiMetric(
172
+ name="lts__throughput.avg.pct_of_peak_sustained_elapsed",
173
+ header=" L2.uti ",
174
+ val_format=" {:6.2f} % ",
175
+ )
176
+
177
+ # Misc Metrics
178
+ l1_hit_rate = CuptiMetric(name="l1tex__t_sector_hit_rate.pct", header=" L1.hit ", val_format=" {:6.2f} % ")
179
+
180
+ l2_hit_rate = CuptiMetric(name="lts__t_sector_hit_rate.pct", header=" L2.hit ", val_format=" {:6.2f} % ")
181
+
182
+ achieved_occupancy = CuptiMetric(
183
+ name="sm__warps_active.avg.pct_of_peak_sustained_active",
184
+ header=" occupancy",
185
+ val_format=" {:6.0f} ",
186
+ )
187
+
188
+ # metric suite: global load & store
189
+ global_access = [
190
+ dram_bytes_sum,
191
+ dram_bytes_throughput,
192
+ dram_bytes_read,
193
+ dram_read_throughput,
194
+ dram_bytes_write,
195
+ dram_write_throughput,
196
+ ]
197
+
198
+ # metric suite: shared load & store
199
+ shared_access = [
200
+ shared_transactions_load,
201
+ shared_transactions_store,
202
+ shared_bank_conflicts_store,
203
+ shared_bank_conflicts_load,
204
+ ]
205
+
206
+ # metric suite: atomic access
207
+ atomic_access = [
208
+ global_op_atom,
209
+ global_op_reduction,
210
+ ]
211
+
212
+ # metric suite: cache hit rate
213
+ cache_hit_rate = [
214
+ l1_hit_rate,
215
+ l2_hit_rate,
216
+ ]
217
+
218
+ # metric suite: device throughput
219
+ device_utilization = [
220
+ sm_throughput,
221
+ dram_throughput,
222
+ shared_utilization,
223
+ l1tex_throughput,
224
+ l2_throughput,
225
+ ]
226
+
227
+ # Predefined metrics suites
228
+ predefined_cupti_metrics = {
229
+ "global_access": global_access,
230
+ "shared_access": shared_access,
231
+ "atomic_access": atomic_access,
232
+ "cache_hit_rate": cache_hit_rate,
233
+ "device_utilization": device_utilization,
234
+ }
235
+
236
+
237
+ def get_predefined_cupti_metrics(name=""):
238
+ """Returns the specified cupti metric.
239
+
240
+ Accepted arguments are 'global_access', 'shared_access', 'atomic_access',
241
+ 'cache_hit_rate', 'device_utilization'.
242
+
243
+ Args:
244
+ name (str): cupti metri name.
245
+ """
246
+ if name not in predefined_cupti_metrics:
247
+ _ti_core.warn("Valid GsTaichi predefined metrics list (str):")
248
+ for key in predefined_cupti_metrics:
249
+ _ti_core.warn(f" '{key}'")
250
+ return None
251
+ return predefined_cupti_metrics[name]
252
+
253
+
254
+ # Default metrics list
255
+ default_cupti_metrics = [dram_bytes_sum]
256
+ """The metrics list, each is an instance of the :class:`~gstaichi.profiler.CuptiMetric`.
257
+ Default to `dram_bytes_sum`.
258
+ """
259
+
260
+ __all__ = ["CuptiMetric", "get_predefined_cupti_metrics"]