numba-cuda 0.22.0__cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.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.

Potentially problematic release.


This version of numba-cuda might be problematic. Click here for more details.

Files changed (487) hide show
  1. _numba_cuda_redirector.pth +4 -0
  2. _numba_cuda_redirector.py +89 -0
  3. numba_cuda/VERSION +1 -0
  4. numba_cuda/__init__.py +6 -0
  5. numba_cuda/_version.py +11 -0
  6. numba_cuda/numba/cuda/__init__.py +70 -0
  7. numba_cuda/numba/cuda/_internal/cuda_bf16.py +16394 -0
  8. numba_cuda/numba/cuda/_internal/cuda_fp16.py +8112 -0
  9. numba_cuda/numba/cuda/api.py +580 -0
  10. numba_cuda/numba/cuda/api_util.py +76 -0
  11. numba_cuda/numba/cuda/args.py +72 -0
  12. numba_cuda/numba/cuda/bf16.py +397 -0
  13. numba_cuda/numba/cuda/cache_hints.py +287 -0
  14. numba_cuda/numba/cuda/cext/__init__.py +2 -0
  15. numba_cuda/numba/cuda/cext/_devicearray.cpp +159 -0
  16. numba_cuda/numba/cuda/cext/_devicearray.cpython-312-aarch64-linux-gnu.so +0 -0
  17. numba_cuda/numba/cuda/cext/_devicearray.h +29 -0
  18. numba_cuda/numba/cuda/cext/_dispatcher.cpp +1098 -0
  19. numba_cuda/numba/cuda/cext/_dispatcher.cpython-312-aarch64-linux-gnu.so +0 -0
  20. numba_cuda/numba/cuda/cext/_hashtable.cpp +532 -0
  21. numba_cuda/numba/cuda/cext/_hashtable.h +135 -0
  22. numba_cuda/numba/cuda/cext/_helperlib.c +71 -0
  23. numba_cuda/numba/cuda/cext/_helperlib.cpython-312-aarch64-linux-gnu.so +0 -0
  24. numba_cuda/numba/cuda/cext/_helpermod.c +82 -0
  25. numba_cuda/numba/cuda/cext/_pymodule.h +38 -0
  26. numba_cuda/numba/cuda/cext/_typeconv.cpp +206 -0
  27. numba_cuda/numba/cuda/cext/_typeconv.cpython-312-aarch64-linux-gnu.so +0 -0
  28. numba_cuda/numba/cuda/cext/_typeof.cpp +1159 -0
  29. numba_cuda/numba/cuda/cext/_typeof.h +19 -0
  30. numba_cuda/numba/cuda/cext/capsulethunk.h +111 -0
  31. numba_cuda/numba/cuda/cext/mviewbuf.c +385 -0
  32. numba_cuda/numba/cuda/cext/mviewbuf.cpython-312-aarch64-linux-gnu.so +0 -0
  33. numba_cuda/numba/cuda/cext/typeconv.cpp +212 -0
  34. numba_cuda/numba/cuda/cext/typeconv.hpp +101 -0
  35. numba_cuda/numba/cuda/cg.py +67 -0
  36. numba_cuda/numba/cuda/cgutils.py +1294 -0
  37. numba_cuda/numba/cuda/cloudpickle/__init__.py +21 -0
  38. numba_cuda/numba/cuda/cloudpickle/cloudpickle.py +1598 -0
  39. numba_cuda/numba/cuda/cloudpickle/cloudpickle_fast.py +17 -0
  40. numba_cuda/numba/cuda/codegen.py +541 -0
  41. numba_cuda/numba/cuda/compiler.py +1396 -0
  42. numba_cuda/numba/cuda/core/analysis.py +758 -0
  43. numba_cuda/numba/cuda/core/annotations/__init__.py +0 -0
  44. numba_cuda/numba/cuda/core/annotations/pretty_annotate.py +288 -0
  45. numba_cuda/numba/cuda/core/annotations/type_annotations.py +305 -0
  46. numba_cuda/numba/cuda/core/base.py +1332 -0
  47. numba_cuda/numba/cuda/core/boxing.py +1411 -0
  48. numba_cuda/numba/cuda/core/bytecode.py +728 -0
  49. numba_cuda/numba/cuda/core/byteflow.py +2346 -0
  50. numba_cuda/numba/cuda/core/caching.py +744 -0
  51. numba_cuda/numba/cuda/core/callconv.py +392 -0
  52. numba_cuda/numba/cuda/core/codegen.py +171 -0
  53. numba_cuda/numba/cuda/core/compiler.py +199 -0
  54. numba_cuda/numba/cuda/core/compiler_lock.py +85 -0
  55. numba_cuda/numba/cuda/core/compiler_machinery.py +497 -0
  56. numba_cuda/numba/cuda/core/config.py +650 -0
  57. numba_cuda/numba/cuda/core/consts.py +124 -0
  58. numba_cuda/numba/cuda/core/controlflow.py +989 -0
  59. numba_cuda/numba/cuda/core/entrypoints.py +57 -0
  60. numba_cuda/numba/cuda/core/environment.py +66 -0
  61. numba_cuda/numba/cuda/core/errors.py +917 -0
  62. numba_cuda/numba/cuda/core/event.py +511 -0
  63. numba_cuda/numba/cuda/core/funcdesc.py +330 -0
  64. numba_cuda/numba/cuda/core/generators.py +387 -0
  65. numba_cuda/numba/cuda/core/imputils.py +509 -0
  66. numba_cuda/numba/cuda/core/inline_closurecall.py +1787 -0
  67. numba_cuda/numba/cuda/core/interpreter.py +3617 -0
  68. numba_cuda/numba/cuda/core/ir.py +1812 -0
  69. numba_cuda/numba/cuda/core/ir_utils.py +2638 -0
  70. numba_cuda/numba/cuda/core/optional.py +129 -0
  71. numba_cuda/numba/cuda/core/options.py +262 -0
  72. numba_cuda/numba/cuda/core/postproc.py +249 -0
  73. numba_cuda/numba/cuda/core/pythonapi.py +1859 -0
  74. numba_cuda/numba/cuda/core/registry.py +46 -0
  75. numba_cuda/numba/cuda/core/removerefctpass.py +123 -0
  76. numba_cuda/numba/cuda/core/rewrites/__init__.py +26 -0
  77. numba_cuda/numba/cuda/core/rewrites/ir_print.py +91 -0
  78. numba_cuda/numba/cuda/core/rewrites/registry.py +104 -0
  79. numba_cuda/numba/cuda/core/rewrites/static_binop.py +41 -0
  80. numba_cuda/numba/cuda/core/rewrites/static_getitem.py +189 -0
  81. numba_cuda/numba/cuda/core/rewrites/static_raise.py +100 -0
  82. numba_cuda/numba/cuda/core/sigutils.py +68 -0
  83. numba_cuda/numba/cuda/core/ssa.py +498 -0
  84. numba_cuda/numba/cuda/core/targetconfig.py +330 -0
  85. numba_cuda/numba/cuda/core/tracing.py +231 -0
  86. numba_cuda/numba/cuda/core/transforms.py +956 -0
  87. numba_cuda/numba/cuda/core/typed_passes.py +867 -0
  88. numba_cuda/numba/cuda/core/typeinfer.py +1950 -0
  89. numba_cuda/numba/cuda/core/unsafe/__init__.py +0 -0
  90. numba_cuda/numba/cuda/core/unsafe/bytes.py +67 -0
  91. numba_cuda/numba/cuda/core/unsafe/eh.py +67 -0
  92. numba_cuda/numba/cuda/core/unsafe/refcount.py +98 -0
  93. numba_cuda/numba/cuda/core/untyped_passes.py +1979 -0
  94. numba_cuda/numba/cuda/cpython/builtins.py +1153 -0
  95. numba_cuda/numba/cuda/cpython/charseq.py +1218 -0
  96. numba_cuda/numba/cuda/cpython/cmathimpl.py +560 -0
  97. numba_cuda/numba/cuda/cpython/enumimpl.py +103 -0
  98. numba_cuda/numba/cuda/cpython/iterators.py +167 -0
  99. numba_cuda/numba/cuda/cpython/listobj.py +1326 -0
  100. numba_cuda/numba/cuda/cpython/mathimpl.py +499 -0
  101. numba_cuda/numba/cuda/cpython/numbers.py +1475 -0
  102. numba_cuda/numba/cuda/cpython/rangeobj.py +289 -0
  103. numba_cuda/numba/cuda/cpython/slicing.py +322 -0
  104. numba_cuda/numba/cuda/cpython/tupleobj.py +456 -0
  105. numba_cuda/numba/cuda/cpython/unicode.py +2865 -0
  106. numba_cuda/numba/cuda/cpython/unicode_support.py +1597 -0
  107. numba_cuda/numba/cuda/cpython/unsafe/__init__.py +0 -0
  108. numba_cuda/numba/cuda/cpython/unsafe/numbers.py +64 -0
  109. numba_cuda/numba/cuda/cpython/unsafe/tuple.py +92 -0
  110. numba_cuda/numba/cuda/cuda_paths.py +691 -0
  111. numba_cuda/numba/cuda/cudadecl.py +543 -0
  112. numba_cuda/numba/cuda/cudadrv/__init__.py +14 -0
  113. numba_cuda/numba/cuda/cudadrv/devicearray.py +954 -0
  114. numba_cuda/numba/cuda/cudadrv/devices.py +249 -0
  115. numba_cuda/numba/cuda/cudadrv/driver.py +3238 -0
  116. numba_cuda/numba/cuda/cudadrv/drvapi.py +435 -0
  117. numba_cuda/numba/cuda/cudadrv/dummyarray.py +562 -0
  118. numba_cuda/numba/cuda/cudadrv/enums.py +613 -0
  119. numba_cuda/numba/cuda/cudadrv/error.py +48 -0
  120. numba_cuda/numba/cuda/cudadrv/libs.py +220 -0
  121. numba_cuda/numba/cuda/cudadrv/linkable_code.py +184 -0
  122. numba_cuda/numba/cuda/cudadrv/mappings.py +14 -0
  123. numba_cuda/numba/cuda/cudadrv/ndarray.py +26 -0
  124. numba_cuda/numba/cuda/cudadrv/nvrtc.py +193 -0
  125. numba_cuda/numba/cuda/cudadrv/nvvm.py +756 -0
  126. numba_cuda/numba/cuda/cudadrv/rtapi.py +13 -0
  127. numba_cuda/numba/cuda/cudadrv/runtime.py +34 -0
  128. numba_cuda/numba/cuda/cudaimpl.py +983 -0
  129. numba_cuda/numba/cuda/cudamath.py +149 -0
  130. numba_cuda/numba/cuda/datamodel/__init__.py +7 -0
  131. numba_cuda/numba/cuda/datamodel/cuda_manager.py +66 -0
  132. numba_cuda/numba/cuda/datamodel/cuda_models.py +1446 -0
  133. numba_cuda/numba/cuda/datamodel/cuda_packer.py +224 -0
  134. numba_cuda/numba/cuda/datamodel/cuda_registry.py +22 -0
  135. numba_cuda/numba/cuda/datamodel/cuda_testing.py +153 -0
  136. numba_cuda/numba/cuda/datamodel/manager.py +11 -0
  137. numba_cuda/numba/cuda/datamodel/models.py +9 -0
  138. numba_cuda/numba/cuda/datamodel/packer.py +9 -0
  139. numba_cuda/numba/cuda/datamodel/registry.py +11 -0
  140. numba_cuda/numba/cuda/datamodel/testing.py +11 -0
  141. numba_cuda/numba/cuda/debuginfo.py +997 -0
  142. numba_cuda/numba/cuda/decorators.py +294 -0
  143. numba_cuda/numba/cuda/descriptor.py +35 -0
  144. numba_cuda/numba/cuda/device_init.py +155 -0
  145. numba_cuda/numba/cuda/deviceufunc.py +1021 -0
  146. numba_cuda/numba/cuda/dispatcher.py +2463 -0
  147. numba_cuda/numba/cuda/errors.py +72 -0
  148. numba_cuda/numba/cuda/extending.py +697 -0
  149. numba_cuda/numba/cuda/flags.py +178 -0
  150. numba_cuda/numba/cuda/fp16.py +357 -0
  151. numba_cuda/numba/cuda/include/12/cuda_bf16.h +5118 -0
  152. numba_cuda/numba/cuda/include/12/cuda_bf16.hpp +3865 -0
  153. numba_cuda/numba/cuda/include/12/cuda_fp16.h +5363 -0
  154. numba_cuda/numba/cuda/include/12/cuda_fp16.hpp +3483 -0
  155. numba_cuda/numba/cuda/include/13/cuda_bf16.h +5118 -0
  156. numba_cuda/numba/cuda/include/13/cuda_bf16.hpp +3865 -0
  157. numba_cuda/numba/cuda/include/13/cuda_fp16.h +5363 -0
  158. numba_cuda/numba/cuda/include/13/cuda_fp16.hpp +3483 -0
  159. numba_cuda/numba/cuda/initialize.py +24 -0
  160. numba_cuda/numba/cuda/intrinsics.py +531 -0
  161. numba_cuda/numba/cuda/itanium_mangler.py +214 -0
  162. numba_cuda/numba/cuda/kernels/__init__.py +2 -0
  163. numba_cuda/numba/cuda/kernels/reduction.py +265 -0
  164. numba_cuda/numba/cuda/kernels/transpose.py +65 -0
  165. numba_cuda/numba/cuda/libdevice.py +3386 -0
  166. numba_cuda/numba/cuda/libdevicedecl.py +20 -0
  167. numba_cuda/numba/cuda/libdevicefuncs.py +1060 -0
  168. numba_cuda/numba/cuda/libdeviceimpl.py +88 -0
  169. numba_cuda/numba/cuda/locks.py +19 -0
  170. numba_cuda/numba/cuda/lowering.py +1980 -0
  171. numba_cuda/numba/cuda/mathimpl.py +374 -0
  172. numba_cuda/numba/cuda/memory_management/__init__.py +4 -0
  173. numba_cuda/numba/cuda/memory_management/memsys.cu +99 -0
  174. numba_cuda/numba/cuda/memory_management/memsys.cuh +22 -0
  175. numba_cuda/numba/cuda/memory_management/nrt.cu +212 -0
  176. numba_cuda/numba/cuda/memory_management/nrt.cuh +48 -0
  177. numba_cuda/numba/cuda/memory_management/nrt.py +390 -0
  178. numba_cuda/numba/cuda/memory_management/nrt_context.py +438 -0
  179. numba_cuda/numba/cuda/misc/appdirs.py +594 -0
  180. numba_cuda/numba/cuda/misc/cffiimpl.py +24 -0
  181. numba_cuda/numba/cuda/misc/coverage_support.py +43 -0
  182. numba_cuda/numba/cuda/misc/dump_style.py +41 -0
  183. numba_cuda/numba/cuda/misc/findlib.py +75 -0
  184. numba_cuda/numba/cuda/misc/firstlinefinder.py +96 -0
  185. numba_cuda/numba/cuda/misc/gdb_hook.py +240 -0
  186. numba_cuda/numba/cuda/misc/literal.py +28 -0
  187. numba_cuda/numba/cuda/misc/llvm_pass_timings.py +412 -0
  188. numba_cuda/numba/cuda/misc/special.py +94 -0
  189. numba_cuda/numba/cuda/models.py +56 -0
  190. numba_cuda/numba/cuda/np/arraymath.py +5130 -0
  191. numba_cuda/numba/cuda/np/arrayobj.py +7635 -0
  192. numba_cuda/numba/cuda/np/extensions.py +11 -0
  193. numba_cuda/numba/cuda/np/linalg.py +3087 -0
  194. numba_cuda/numba/cuda/np/math/__init__.py +0 -0
  195. numba_cuda/numba/cuda/np/math/cmathimpl.py +558 -0
  196. numba_cuda/numba/cuda/np/math/mathimpl.py +487 -0
  197. numba_cuda/numba/cuda/np/math/numbers.py +1461 -0
  198. numba_cuda/numba/cuda/np/npdatetime.py +969 -0
  199. numba_cuda/numba/cuda/np/npdatetime_helpers.py +217 -0
  200. numba_cuda/numba/cuda/np/npyfuncs.py +1808 -0
  201. numba_cuda/numba/cuda/np/npyimpl.py +1027 -0
  202. numba_cuda/numba/cuda/np/numpy_support.py +798 -0
  203. numba_cuda/numba/cuda/np/polynomial/__init__.py +4 -0
  204. numba_cuda/numba/cuda/np/polynomial/polynomial_core.py +242 -0
  205. numba_cuda/numba/cuda/np/polynomial/polynomial_functions.py +380 -0
  206. numba_cuda/numba/cuda/np/ufunc/__init__.py +4 -0
  207. numba_cuda/numba/cuda/np/ufunc/decorators.py +203 -0
  208. numba_cuda/numba/cuda/np/ufunc/sigparse.py +68 -0
  209. numba_cuda/numba/cuda/np/ufunc/ufuncbuilder.py +65 -0
  210. numba_cuda/numba/cuda/np/ufunc_db.py +1282 -0
  211. numba_cuda/numba/cuda/np/unsafe/__init__.py +0 -0
  212. numba_cuda/numba/cuda/np/unsafe/ndarray.py +84 -0
  213. numba_cuda/numba/cuda/nvvmutils.py +254 -0
  214. numba_cuda/numba/cuda/printimpl.py +126 -0
  215. numba_cuda/numba/cuda/random.py +308 -0
  216. numba_cuda/numba/cuda/reshape_funcs.cu +156 -0
  217. numba_cuda/numba/cuda/serialize.py +267 -0
  218. numba_cuda/numba/cuda/simulator/__init__.py +63 -0
  219. numba_cuda/numba/cuda/simulator/_internal/__init__.py +4 -0
  220. numba_cuda/numba/cuda/simulator/_internal/cuda_bf16.py +2 -0
  221. numba_cuda/numba/cuda/simulator/api.py +179 -0
  222. numba_cuda/numba/cuda/simulator/bf16.py +4 -0
  223. numba_cuda/numba/cuda/simulator/compiler.py +38 -0
  224. numba_cuda/numba/cuda/simulator/cudadrv/__init__.py +11 -0
  225. numba_cuda/numba/cuda/simulator/cudadrv/devicearray.py +462 -0
  226. numba_cuda/numba/cuda/simulator/cudadrv/devices.py +122 -0
  227. numba_cuda/numba/cuda/simulator/cudadrv/driver.py +66 -0
  228. numba_cuda/numba/cuda/simulator/cudadrv/drvapi.py +7 -0
  229. numba_cuda/numba/cuda/simulator/cudadrv/dummyarray.py +7 -0
  230. numba_cuda/numba/cuda/simulator/cudadrv/error.py +10 -0
  231. numba_cuda/numba/cuda/simulator/cudadrv/libs.py +10 -0
  232. numba_cuda/numba/cuda/simulator/cudadrv/linkable_code.py +61 -0
  233. numba_cuda/numba/cuda/simulator/cudadrv/nvrtc.py +11 -0
  234. numba_cuda/numba/cuda/simulator/cudadrv/nvvm.py +32 -0
  235. numba_cuda/numba/cuda/simulator/cudadrv/runtime.py +22 -0
  236. numba_cuda/numba/cuda/simulator/dispatcher.py +11 -0
  237. numba_cuda/numba/cuda/simulator/kernel.py +320 -0
  238. numba_cuda/numba/cuda/simulator/kernelapi.py +509 -0
  239. numba_cuda/numba/cuda/simulator/memory_management/__init__.py +4 -0
  240. numba_cuda/numba/cuda/simulator/memory_management/nrt.py +21 -0
  241. numba_cuda/numba/cuda/simulator/reduction.py +19 -0
  242. numba_cuda/numba/cuda/simulator/tests/support.py +4 -0
  243. numba_cuda/numba/cuda/simulator/vector_types.py +65 -0
  244. numba_cuda/numba/cuda/simulator_init.py +18 -0
  245. numba_cuda/numba/cuda/stubs.py +624 -0
  246. numba_cuda/numba/cuda/target.py +505 -0
  247. numba_cuda/numba/cuda/testing.py +347 -0
  248. numba_cuda/numba/cuda/tests/__init__.py +62 -0
  249. numba_cuda/numba/cuda/tests/benchmarks/__init__.py +0 -0
  250. numba_cuda/numba/cuda/tests/benchmarks/test_kernel_launch.py +119 -0
  251. numba_cuda/numba/cuda/tests/cloudpickle_main_class.py +9 -0
  252. numba_cuda/numba/cuda/tests/core/serialize_usecases.py +113 -0
  253. numba_cuda/numba/cuda/tests/core/test_itanium_mangler.py +83 -0
  254. numba_cuda/numba/cuda/tests/core/test_serialize.py +371 -0
  255. numba_cuda/numba/cuda/tests/cudadrv/__init__.py +9 -0
  256. numba_cuda/numba/cuda/tests/cudadrv/test_array_attr.py +147 -0
  257. numba_cuda/numba/cuda/tests/cudadrv/test_context_stack.py +161 -0
  258. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_array_slicing.py +397 -0
  259. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_auto_context.py +24 -0
  260. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_devicerecord.py +180 -0
  261. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_driver.py +313 -0
  262. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_memory.py +191 -0
  263. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_ndarray.py +621 -0
  264. numba_cuda/numba/cuda/tests/cudadrv/test_deallocations.py +247 -0
  265. numba_cuda/numba/cuda/tests/cudadrv/test_detect.py +100 -0
  266. numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +200 -0
  267. numba_cuda/numba/cuda/tests/cudadrv/test_events.py +53 -0
  268. numba_cuda/numba/cuda/tests/cudadrv/test_host_alloc.py +72 -0
  269. numba_cuda/numba/cuda/tests/cudadrv/test_init.py +138 -0
  270. numba_cuda/numba/cuda/tests/cudadrv/test_inline_ptx.py +43 -0
  271. numba_cuda/numba/cuda/tests/cudadrv/test_is_fp16.py +15 -0
  272. numba_cuda/numba/cuda/tests/cudadrv/test_linkable_code.py +58 -0
  273. numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +348 -0
  274. numba_cuda/numba/cuda/tests/cudadrv/test_managed_alloc.py +128 -0
  275. numba_cuda/numba/cuda/tests/cudadrv/test_module_callbacks.py +301 -0
  276. numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py +174 -0
  277. numba_cuda/numba/cuda/tests/cudadrv/test_nvrtc.py +28 -0
  278. numba_cuda/numba/cuda/tests/cudadrv/test_nvvm_driver.py +185 -0
  279. numba_cuda/numba/cuda/tests/cudadrv/test_pinned.py +39 -0
  280. numba_cuda/numba/cuda/tests/cudadrv/test_profiler.py +23 -0
  281. numba_cuda/numba/cuda/tests/cudadrv/test_reset_device.py +38 -0
  282. numba_cuda/numba/cuda/tests/cudadrv/test_runtime.py +48 -0
  283. numba_cuda/numba/cuda/tests/cudadrv/test_select_device.py +44 -0
  284. numba_cuda/numba/cuda/tests/cudadrv/test_streams.py +127 -0
  285. numba_cuda/numba/cuda/tests/cudapy/__init__.py +9 -0
  286. numba_cuda/numba/cuda/tests/cudapy/cache_usecases.py +231 -0
  287. numba_cuda/numba/cuda/tests/cudapy/cache_with_cpu_usecases.py +50 -0
  288. numba_cuda/numba/cuda/tests/cudapy/cg_cache_usecases.py +36 -0
  289. numba_cuda/numba/cuda/tests/cudapy/complex_usecases.py +116 -0
  290. numba_cuda/numba/cuda/tests/cudapy/enum_usecases.py +59 -0
  291. numba_cuda/numba/cuda/tests/cudapy/extensions_usecases.py +62 -0
  292. numba_cuda/numba/cuda/tests/cudapy/jitlink.ptx +28 -0
  293. numba_cuda/numba/cuda/tests/cudapy/overload_usecases.py +33 -0
  294. numba_cuda/numba/cuda/tests/cudapy/recursion_usecases.py +104 -0
  295. numba_cuda/numba/cuda/tests/cudapy/test_alignment.py +47 -0
  296. numba_cuda/numba/cuda/tests/cudapy/test_analysis.py +1122 -0
  297. numba_cuda/numba/cuda/tests/cudapy/test_array.py +344 -0
  298. numba_cuda/numba/cuda/tests/cudapy/test_array_alignment.py +268 -0
  299. numba_cuda/numba/cuda/tests/cudapy/test_array_args.py +203 -0
  300. numba_cuda/numba/cuda/tests/cudapy/test_array_methods.py +63 -0
  301. numba_cuda/numba/cuda/tests/cudapy/test_array_reductions.py +360 -0
  302. numba_cuda/numba/cuda/tests/cudapy/test_atomics.py +1815 -0
  303. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16.py +599 -0
  304. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16_bindings.py +377 -0
  305. numba_cuda/numba/cuda/tests/cudapy/test_blackscholes.py +160 -0
  306. numba_cuda/numba/cuda/tests/cudapy/test_boolean.py +27 -0
  307. numba_cuda/numba/cuda/tests/cudapy/test_byteflow.py +98 -0
  308. numba_cuda/numba/cuda/tests/cudapy/test_cache_hints.py +210 -0
  309. numba_cuda/numba/cuda/tests/cudapy/test_caching.py +683 -0
  310. numba_cuda/numba/cuda/tests/cudapy/test_casting.py +265 -0
  311. numba_cuda/numba/cuda/tests/cudapy/test_cffi.py +42 -0
  312. numba_cuda/numba/cuda/tests/cudapy/test_compiler.py +718 -0
  313. numba_cuda/numba/cuda/tests/cudapy/test_complex.py +370 -0
  314. numba_cuda/numba/cuda/tests/cudapy/test_complex_kernel.py +23 -0
  315. numba_cuda/numba/cuda/tests/cudapy/test_const_string.py +142 -0
  316. numba_cuda/numba/cuda/tests/cudapy/test_constmem.py +178 -0
  317. numba_cuda/numba/cuda/tests/cudapy/test_cooperative_groups.py +193 -0
  318. numba_cuda/numba/cuda/tests/cudapy/test_copy_propagate.py +131 -0
  319. numba_cuda/numba/cuda/tests/cudapy/test_cuda_array_interface.py +438 -0
  320. numba_cuda/numba/cuda/tests/cudapy/test_cuda_jit_no_types.py +94 -0
  321. numba_cuda/numba/cuda/tests/cudapy/test_datetime.py +101 -0
  322. numba_cuda/numba/cuda/tests/cudapy/test_debug.py +105 -0
  323. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +978 -0
  324. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo_types.py +476 -0
  325. numba_cuda/numba/cuda/tests/cudapy/test_device_func.py +500 -0
  326. numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +820 -0
  327. numba_cuda/numba/cuda/tests/cudapy/test_enums.py +152 -0
  328. numba_cuda/numba/cuda/tests/cudapy/test_errors.py +111 -0
  329. numba_cuda/numba/cuda/tests/cudapy/test_exception.py +170 -0
  330. numba_cuda/numba/cuda/tests/cudapy/test_extending.py +1088 -0
  331. numba_cuda/numba/cuda/tests/cudapy/test_extending_types.py +71 -0
  332. numba_cuda/numba/cuda/tests/cudapy/test_fastmath.py +265 -0
  333. numba_cuda/numba/cuda/tests/cudapy/test_flow_control.py +1433 -0
  334. numba_cuda/numba/cuda/tests/cudapy/test_forall.py +57 -0
  335. numba_cuda/numba/cuda/tests/cudapy/test_freevar.py +34 -0
  336. numba_cuda/numba/cuda/tests/cudapy/test_frexp_ldexp.py +69 -0
  337. numba_cuda/numba/cuda/tests/cudapy/test_globals.py +62 -0
  338. numba_cuda/numba/cuda/tests/cudapy/test_gufunc.py +474 -0
  339. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scalar.py +167 -0
  340. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scheduling.py +92 -0
  341. numba_cuda/numba/cuda/tests/cudapy/test_idiv.py +39 -0
  342. numba_cuda/numba/cuda/tests/cudapy/test_inline.py +170 -0
  343. numba_cuda/numba/cuda/tests/cudapy/test_inspect.py +255 -0
  344. numba_cuda/numba/cuda/tests/cudapy/test_intrinsics.py +1219 -0
  345. numba_cuda/numba/cuda/tests/cudapy/test_ipc.py +263 -0
  346. numba_cuda/numba/cuda/tests/cudapy/test_ir.py +598 -0
  347. numba_cuda/numba/cuda/tests/cudapy/test_ir_utils.py +276 -0
  348. numba_cuda/numba/cuda/tests/cudapy/test_iterators.py +101 -0
  349. numba_cuda/numba/cuda/tests/cudapy/test_lang.py +68 -0
  350. numba_cuda/numba/cuda/tests/cudapy/test_laplace.py +123 -0
  351. numba_cuda/numba/cuda/tests/cudapy/test_libdevice.py +194 -0
  352. numba_cuda/numba/cuda/tests/cudapy/test_lineinfo.py +220 -0
  353. numba_cuda/numba/cuda/tests/cudapy/test_localmem.py +173 -0
  354. numba_cuda/numba/cuda/tests/cudapy/test_make_function_to_jit_function.py +364 -0
  355. numba_cuda/numba/cuda/tests/cudapy/test_mandel.py +47 -0
  356. numba_cuda/numba/cuda/tests/cudapy/test_math.py +842 -0
  357. numba_cuda/numba/cuda/tests/cudapy/test_matmul.py +76 -0
  358. numba_cuda/numba/cuda/tests/cudapy/test_minmax.py +78 -0
  359. numba_cuda/numba/cuda/tests/cudapy/test_montecarlo.py +25 -0
  360. numba_cuda/numba/cuda/tests/cudapy/test_multigpu.py +145 -0
  361. numba_cuda/numba/cuda/tests/cudapy/test_multiprocessing.py +39 -0
  362. numba_cuda/numba/cuda/tests/cudapy/test_multithreads.py +82 -0
  363. numba_cuda/numba/cuda/tests/cudapy/test_nondet.py +53 -0
  364. numba_cuda/numba/cuda/tests/cudapy/test_operator.py +504 -0
  365. numba_cuda/numba/cuda/tests/cudapy/test_optimization.py +93 -0
  366. numba_cuda/numba/cuda/tests/cudapy/test_overload.py +402 -0
  367. numba_cuda/numba/cuda/tests/cudapy/test_powi.py +128 -0
  368. numba_cuda/numba/cuda/tests/cudapy/test_print.py +193 -0
  369. numba_cuda/numba/cuda/tests/cudapy/test_py2_div_issue.py +37 -0
  370. numba_cuda/numba/cuda/tests/cudapy/test_random.py +117 -0
  371. numba_cuda/numba/cuda/tests/cudapy/test_record_dtype.py +614 -0
  372. numba_cuda/numba/cuda/tests/cudapy/test_recursion.py +130 -0
  373. numba_cuda/numba/cuda/tests/cudapy/test_reduction.py +94 -0
  374. numba_cuda/numba/cuda/tests/cudapy/test_retrieve_autoconverted_arrays.py +83 -0
  375. numba_cuda/numba/cuda/tests/cudapy/test_serialize.py +86 -0
  376. numba_cuda/numba/cuda/tests/cudapy/test_slicing.py +40 -0
  377. numba_cuda/numba/cuda/tests/cudapy/test_sm.py +457 -0
  378. numba_cuda/numba/cuda/tests/cudapy/test_sm_creation.py +233 -0
  379. numba_cuda/numba/cuda/tests/cudapy/test_ssa.py +454 -0
  380. numba_cuda/numba/cuda/tests/cudapy/test_stream_api.py +56 -0
  381. numba_cuda/numba/cuda/tests/cudapy/test_sync.py +277 -0
  382. numba_cuda/numba/cuda/tests/cudapy/test_tracing.py +200 -0
  383. numba_cuda/numba/cuda/tests/cudapy/test_transpose.py +90 -0
  384. numba_cuda/numba/cuda/tests/cudapy/test_typeconv.py +333 -0
  385. numba_cuda/numba/cuda/tests/cudapy/test_typeinfer.py +538 -0
  386. numba_cuda/numba/cuda/tests/cudapy/test_ufuncs.py +585 -0
  387. numba_cuda/numba/cuda/tests/cudapy/test_userexc.py +42 -0
  388. numba_cuda/numba/cuda/tests/cudapy/test_vector_type.py +485 -0
  389. numba_cuda/numba/cuda/tests/cudapy/test_vectorize.py +312 -0
  390. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_complex.py +23 -0
  391. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_decor.py +183 -0
  392. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_device.py +40 -0
  393. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_scalar_arg.py +40 -0
  394. numba_cuda/numba/cuda/tests/cudapy/test_warning.py +206 -0
  395. numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +446 -0
  396. numba_cuda/numba/cuda/tests/cudasim/__init__.py +9 -0
  397. numba_cuda/numba/cuda/tests/cudasim/support.py +9 -0
  398. numba_cuda/numba/cuda/tests/cudasim/test_cudasim_issues.py +111 -0
  399. numba_cuda/numba/cuda/tests/data/__init__.py +2 -0
  400. numba_cuda/numba/cuda/tests/data/cta_barrier.cu +28 -0
  401. numba_cuda/numba/cuda/tests/data/cuda_include.cu +10 -0
  402. numba_cuda/numba/cuda/tests/data/error.cu +12 -0
  403. numba_cuda/numba/cuda/tests/data/include/add.cuh +8 -0
  404. numba_cuda/numba/cuda/tests/data/jitlink.cu +28 -0
  405. numba_cuda/numba/cuda/tests/data/jitlink.ptx +49 -0
  406. numba_cuda/numba/cuda/tests/data/warn.cu +12 -0
  407. numba_cuda/numba/cuda/tests/doc_examples/__init__.py +9 -0
  408. numba_cuda/numba/cuda/tests/doc_examples/ffi/__init__.py +2 -0
  409. numba_cuda/numba/cuda/tests/doc_examples/ffi/functions.cu +54 -0
  410. numba_cuda/numba/cuda/tests/doc_examples/ffi/include/mul.cuh +8 -0
  411. numba_cuda/numba/cuda/tests/doc_examples/ffi/saxpy.cu +14 -0
  412. numba_cuda/numba/cuda/tests/doc_examples/test_cg.py +86 -0
  413. numba_cuda/numba/cuda/tests/doc_examples/test_cpointer.py +68 -0
  414. numba_cuda/numba/cuda/tests/doc_examples/test_cpu_gpu_compat.py +81 -0
  415. numba_cuda/numba/cuda/tests/doc_examples/test_ffi.py +141 -0
  416. numba_cuda/numba/cuda/tests/doc_examples/test_laplace.py +160 -0
  417. numba_cuda/numba/cuda/tests/doc_examples/test_matmul.py +180 -0
  418. numba_cuda/numba/cuda/tests/doc_examples/test_montecarlo.py +119 -0
  419. numba_cuda/numba/cuda/tests/doc_examples/test_random.py +66 -0
  420. numba_cuda/numba/cuda/tests/doc_examples/test_reduction.py +80 -0
  421. numba_cuda/numba/cuda/tests/doc_examples/test_sessionize.py +206 -0
  422. numba_cuda/numba/cuda/tests/doc_examples/test_ufunc.py +53 -0
  423. numba_cuda/numba/cuda/tests/doc_examples/test_vecadd.py +76 -0
  424. numba_cuda/numba/cuda/tests/nocuda/__init__.py +9 -0
  425. numba_cuda/numba/cuda/tests/nocuda/test_dummyarray.py +452 -0
  426. numba_cuda/numba/cuda/tests/nocuda/test_function_resolution.py +48 -0
  427. numba_cuda/numba/cuda/tests/nocuda/test_import.py +63 -0
  428. numba_cuda/numba/cuda/tests/nocuda/test_library_lookup.py +252 -0
  429. numba_cuda/numba/cuda/tests/nocuda/test_nvvm.py +59 -0
  430. numba_cuda/numba/cuda/tests/nrt/__init__.py +9 -0
  431. numba_cuda/numba/cuda/tests/nrt/test_nrt.py +387 -0
  432. numba_cuda/numba/cuda/tests/nrt/test_nrt_refct.py +124 -0
  433. numba_cuda/numba/cuda/tests/support.py +900 -0
  434. numba_cuda/numba/cuda/typeconv/__init__.py +4 -0
  435. numba_cuda/numba/cuda/typeconv/castgraph.py +137 -0
  436. numba_cuda/numba/cuda/typeconv/rules.py +63 -0
  437. numba_cuda/numba/cuda/typeconv/typeconv.py +121 -0
  438. numba_cuda/numba/cuda/types/__init__.py +233 -0
  439. numba_cuda/numba/cuda/types/__init__.pyi +167 -0
  440. numba_cuda/numba/cuda/types/abstract.py +9 -0
  441. numba_cuda/numba/cuda/types/common.py +9 -0
  442. numba_cuda/numba/cuda/types/containers.py +9 -0
  443. numba_cuda/numba/cuda/types/cuda_abstract.py +533 -0
  444. numba_cuda/numba/cuda/types/cuda_common.py +110 -0
  445. numba_cuda/numba/cuda/types/cuda_containers.py +971 -0
  446. numba_cuda/numba/cuda/types/cuda_function_type.py +230 -0
  447. numba_cuda/numba/cuda/types/cuda_functions.py +798 -0
  448. numba_cuda/numba/cuda/types/cuda_iterators.py +120 -0
  449. numba_cuda/numba/cuda/types/cuda_misc.py +569 -0
  450. numba_cuda/numba/cuda/types/cuda_npytypes.py +690 -0
  451. numba_cuda/numba/cuda/types/cuda_scalars.py +280 -0
  452. numba_cuda/numba/cuda/types/ext_types.py +101 -0
  453. numba_cuda/numba/cuda/types/function_type.py +11 -0
  454. numba_cuda/numba/cuda/types/functions.py +9 -0
  455. numba_cuda/numba/cuda/types/iterators.py +9 -0
  456. numba_cuda/numba/cuda/types/misc.py +9 -0
  457. numba_cuda/numba/cuda/types/npytypes.py +9 -0
  458. numba_cuda/numba/cuda/types/scalars.py +9 -0
  459. numba_cuda/numba/cuda/typing/__init__.py +19 -0
  460. numba_cuda/numba/cuda/typing/arraydecl.py +939 -0
  461. numba_cuda/numba/cuda/typing/asnumbatype.py +130 -0
  462. numba_cuda/numba/cuda/typing/bufproto.py +70 -0
  463. numba_cuda/numba/cuda/typing/builtins.py +1209 -0
  464. numba_cuda/numba/cuda/typing/cffi_utils.py +219 -0
  465. numba_cuda/numba/cuda/typing/cmathdecl.py +47 -0
  466. numba_cuda/numba/cuda/typing/collections.py +138 -0
  467. numba_cuda/numba/cuda/typing/context.py +782 -0
  468. numba_cuda/numba/cuda/typing/ctypes_utils.py +125 -0
  469. numba_cuda/numba/cuda/typing/dictdecl.py +63 -0
  470. numba_cuda/numba/cuda/typing/enumdecl.py +74 -0
  471. numba_cuda/numba/cuda/typing/listdecl.py +147 -0
  472. numba_cuda/numba/cuda/typing/mathdecl.py +158 -0
  473. numba_cuda/numba/cuda/typing/npdatetime.py +322 -0
  474. numba_cuda/numba/cuda/typing/npydecl.py +749 -0
  475. numba_cuda/numba/cuda/typing/setdecl.py +115 -0
  476. numba_cuda/numba/cuda/typing/templates.py +1446 -0
  477. numba_cuda/numba/cuda/typing/typeof.py +301 -0
  478. numba_cuda/numba/cuda/ufuncs.py +746 -0
  479. numba_cuda/numba/cuda/utils.py +724 -0
  480. numba_cuda/numba/cuda/vector_types.py +214 -0
  481. numba_cuda/numba/cuda/vectorizers.py +260 -0
  482. numba_cuda-0.22.0.dist-info/METADATA +109 -0
  483. numba_cuda-0.22.0.dist-info/RECORD +487 -0
  484. numba_cuda-0.22.0.dist-info/WHEEL +6 -0
  485. numba_cuda-0.22.0.dist-info/licenses/LICENSE +26 -0
  486. numba_cuda-0.22.0.dist-info/licenses/LICENSE.numba +24 -0
  487. numba_cuda-0.22.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,997 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ import abc
5
+ import os
6
+ from contextlib import contextmanager
7
+ from enum import IntEnum
8
+
9
+ import llvmlite
10
+ from llvmlite import ir
11
+ from numba.cuda import types
12
+ from numba.cuda.core import config
13
+ from numba.cuda import cgutils
14
+ from numba.cuda.datamodel.models import ComplexModel, UnionModel, UniTupleModel
15
+ from numba.cuda.types.ext_types import GridGroup
16
+ from cuda.bindings import runtime
17
+
18
+
19
+ # Check if CUDA Toolkit and llvmlite support polymorphic debug info
20
+ def _get_llvmlite_version():
21
+ """Get llvmlite version as tuple (major, minor)."""
22
+ try:
23
+ version_str = llvmlite.__version__
24
+ # Parse version string like "0.46.0" or "0.46.0dev"
25
+ parts = version_str.split(".")
26
+ if len(parts) < 2:
27
+ return (0, 0)
28
+ major = int(parts[0])
29
+ minor = int(parts[1])
30
+ return (major, minor)
31
+ except (IndexError, AttributeError, ValueError):
32
+ return (0, 0)
33
+
34
+
35
+ def _check_polymorphic_debug_info_support():
36
+ """Check if CTK and llvmlite support polymorphic debug info.
37
+
38
+ Returns:
39
+ tuple: (supported: bool, use_typed_const: bool)
40
+ - supported: Whether feature is supported at all
41
+ - use_typed_const: True for typed constant,
42
+ False for node reference
43
+ """
44
+ # runtime.getLocalRuntimeVersion() returns (cudaError_t, version_int)
45
+ # Example: 13010 = CTK 13.1, 13020 = CTK 13.2
46
+ _, ctk_version_number = runtime.getLocalRuntimeVersion()
47
+ ctk_major = ctk_version_number // 1000
48
+ ctk_minor = (ctk_version_number % 1000) // 10
49
+ ctk_version = (ctk_major, ctk_minor)
50
+
51
+ llvmlite_version = _get_llvmlite_version()
52
+
53
+ # Support not available with CTK 13.1 or older
54
+ if ctk_version <= (13, 1):
55
+ return (False, False)
56
+
57
+ # llvmlite > 0.45: use typed constant
58
+ # llvmlite <= 0.45: use node reference
59
+ use_typed_const = llvmlite_version > (0, 45)
60
+ return (True, use_typed_const)
61
+
62
+
63
+ # Check support and determine mode
64
+ (DEBUG_POLY_SUPPORTED, DEBUG_POLY_USE_TYPED_CONST) = (
65
+ _check_polymorphic_debug_info_support()
66
+ )
67
+
68
+ # Set config based on polymorphic debug info support
69
+ if not hasattr(config, "CUDA_DEBUG_POLY"):
70
+ config.CUDA_DEBUG_POLY = DEBUG_POLY_SUPPORTED
71
+ if not hasattr(config, "CUDA_DEBUG_POLY_USE_TYPED_CONST"):
72
+ config.CUDA_DEBUG_POLY_USE_TYPED_CONST = DEBUG_POLY_USE_TYPED_CONST
73
+
74
+
75
+ class DwarfAddressClass(IntEnum):
76
+ GENERIC = 0x00
77
+ GLOBAL = 0x01
78
+ REGISTER = 0x02
79
+ CONSTANT = 0x05
80
+ LOCAL = 0x06
81
+ PARAMETER = 0x07
82
+ SHARED = 0x08
83
+
84
+
85
+ @contextmanager
86
+ def suspend_emission(builder):
87
+ """Suspends the emission of debug_metadata for the duration of the context
88
+ managed block."""
89
+ ref = builder.debug_metadata
90
+ builder.debug_metadata = None
91
+ try:
92
+ yield
93
+ finally:
94
+ builder.debug_metadata = ref
95
+
96
+
97
+ class AbstractDIBuilder(metaclass=abc.ABCMeta):
98
+ @abc.abstractmethod
99
+ def mark_variable(
100
+ self,
101
+ builder,
102
+ allocavalue,
103
+ name,
104
+ lltype,
105
+ size,
106
+ line,
107
+ datamodel=None,
108
+ argidx=None,
109
+ ):
110
+ """Emit debug info for the variable."""
111
+ pass
112
+
113
+ @abc.abstractmethod
114
+ def mark_location(self, builder, line):
115
+ """Emit source location information to the given IRBuilder."""
116
+ pass
117
+
118
+ @abc.abstractmethod
119
+ def mark_subprogram(self, function, qualname, argnames, argtypes, line):
120
+ """Emit source location information for the given function."""
121
+ pass
122
+
123
+ @abc.abstractmethod
124
+ def initialize(self):
125
+ """Initialize the debug info. An opportunity for the debuginfo to
126
+ prepare any necessary data structures.
127
+ """
128
+
129
+ @abc.abstractmethod
130
+ def finalize(self):
131
+ """Finalize the debuginfo by emitting all necessary metadata."""
132
+ pass
133
+
134
+
135
+ class DummyDIBuilder(AbstractDIBuilder):
136
+ def __init__(self, module, filepath, cgctx, directives_only):
137
+ pass
138
+
139
+ def mark_variable(
140
+ self,
141
+ builder,
142
+ allocavalue,
143
+ name,
144
+ lltype,
145
+ size,
146
+ line,
147
+ datamodel=None,
148
+ argidx=None,
149
+ ):
150
+ pass
151
+
152
+ def mark_location(self, builder, line):
153
+ pass
154
+
155
+ def mark_subprogram(self, function, qualname, argnames, argtypes, line):
156
+ pass
157
+
158
+ def initialize(self):
159
+ pass
160
+
161
+ def finalize(self):
162
+ pass
163
+
164
+
165
+ _BYTE_SIZE = 8
166
+
167
+
168
+ class DIBuilder(AbstractDIBuilder):
169
+ DWARF_VERSION = 4
170
+ DEBUG_INFO_VERSION = 3
171
+ DBG_CU_NAME = "llvm.dbg.cu"
172
+ _DEBUG = False
173
+
174
+ def __init__(self, module, filepath, cgctx, directives_only):
175
+ self.module = module
176
+ self.filepath = os.path.abspath(filepath)
177
+ self.difile = self._di_file()
178
+ self.subprograms = []
179
+ self.cgctx = cgctx
180
+
181
+ if directives_only:
182
+ self.emission_kind = "DebugDirectivesOnly"
183
+ else:
184
+ self.emission_kind = "FullDebug"
185
+
186
+ self.initialize()
187
+
188
+ def initialize(self):
189
+ # Create the compile unit now because it is referenced when
190
+ # constructing subprograms
191
+ self.dicompileunit = self._di_compile_unit()
192
+
193
+ def get_dwarf_address_class(self, addrspace):
194
+ # Map NVVM address space to DWARF address class.
195
+ from numba.cuda.cudadrv import nvvm
196
+
197
+ addrspace_to_addrclass_dict = {
198
+ nvvm.ADDRSPACE_GENERIC: None,
199
+ nvvm.ADDRSPACE_GLOBAL: DwarfAddressClass.GLOBAL,
200
+ nvvm.ADDRSPACE_SHARED: DwarfAddressClass.SHARED,
201
+ nvvm.ADDRSPACE_CONSTANT: DwarfAddressClass.CONSTANT,
202
+ nvvm.ADDRSPACE_LOCAL: DwarfAddressClass.LOCAL,
203
+ }
204
+ return addrspace_to_addrclass_dict.get(addrspace)
205
+
206
+ def _var_type(self, lltype, size, datamodel=None):
207
+ if self._DEBUG:
208
+ print(
209
+ "-->",
210
+ lltype,
211
+ size,
212
+ datamodel,
213
+ getattr(datamodel, "fe_type", "NO FE TYPE"),
214
+ )
215
+ m = self.module
216
+ bitsize = _BYTE_SIZE * size
217
+
218
+ int_type = (ir.IntType,)
219
+ real_type = ir.FloatType, ir.DoubleType
220
+ # For simple numeric types, choose the closest encoding.
221
+ # We treat all integers as unsigned when there's no known datamodel.
222
+ if isinstance(lltype, int_type + real_type):
223
+ if datamodel is None:
224
+ # This is probably something like an `i8*` member of a struct
225
+ name = str(lltype)
226
+ if isinstance(lltype, int_type):
227
+ ditok = "DW_ATE_unsigned"
228
+ else:
229
+ ditok = "DW_ATE_float"
230
+ else:
231
+ # This is probably a known int/float scalar type
232
+ name = str(datamodel.fe_type)
233
+ if isinstance(datamodel.fe_type, types.Integer):
234
+ if datamodel.fe_type.signed:
235
+ ditok = "DW_ATE_signed"
236
+ else:
237
+ ditok = "DW_ATE_unsigned"
238
+ else:
239
+ ditok = "DW_ATE_float"
240
+ mdtype = m.add_debug_info(
241
+ "DIBasicType",
242
+ {
243
+ "name": name,
244
+ "size": bitsize,
245
+ "encoding": ir.DIToken(ditok),
246
+ },
247
+ )
248
+ elif isinstance(datamodel, ComplexModel):
249
+ # TODO: Is there a better way of determining "this is a complex
250
+ # number"?
251
+ #
252
+ # NOTE: Commented below is the way to generate the metadata for a
253
+ # C99 complex type that's directly supported by DWARF. Numba however
254
+ # generates a struct with real/imag cf. CPython to give a more
255
+ # pythonic feel to inspection.
256
+ #
257
+ # mdtype = m.add_debug_info('DIBasicType', {
258
+ # 'name': f"{datamodel.fe_type} ({str(lltype)})",
259
+ # 'size': bitsize,
260
+ # 'encoding': ir.DIToken('DW_ATE_complex_float'),
261
+ # })
262
+ meta = []
263
+ offset = 0
264
+ for ix, name in enumerate(("real", "imag")):
265
+ component = lltype.elements[ix]
266
+ component_size = self.cgctx.get_abi_sizeof(component)
267
+ component_basetype = m.add_debug_info(
268
+ "DIBasicType",
269
+ {
270
+ "name": str(component),
271
+ "size": _BYTE_SIZE * component_size, # bits
272
+ "encoding": ir.DIToken("DW_ATE_float"),
273
+ },
274
+ )
275
+ derived_type = m.add_debug_info(
276
+ "DIDerivedType",
277
+ {
278
+ "tag": ir.DIToken("DW_TAG_member"),
279
+ "name": name,
280
+ "baseType": component_basetype,
281
+ "size": _BYTE_SIZE
282
+ * component_size, # DW_TAG_member size is in bits
283
+ "offset": offset,
284
+ },
285
+ )
286
+ meta.append(derived_type)
287
+ offset += _BYTE_SIZE * component_size # offset is in bits
288
+ mdtype = m.add_debug_info(
289
+ "DICompositeType",
290
+ {
291
+ "tag": ir.DIToken("DW_TAG_structure_type"),
292
+ "name": f"{datamodel.fe_type} ({str(lltype)})",
293
+ "identifier": str(lltype),
294
+ "elements": m.add_metadata(meta),
295
+ "size": offset,
296
+ },
297
+ is_distinct=True,
298
+ )
299
+ elif isinstance(datamodel, UniTupleModel):
300
+ element = lltype.element
301
+ el_size = self.cgctx.get_abi_sizeof(element)
302
+ basetype = self._var_type(element, el_size)
303
+ name = f"{datamodel.fe_type} ({str(lltype)})"
304
+ count = size // el_size
305
+ mdrange = m.add_debug_info(
306
+ "DISubrange",
307
+ {
308
+ "count": count,
309
+ },
310
+ )
311
+ mdtype = m.add_debug_info(
312
+ "DICompositeType",
313
+ {
314
+ "tag": ir.DIToken("DW_TAG_array_type"),
315
+ "baseType": basetype,
316
+ "name": name,
317
+ "size": bitsize,
318
+ "identifier": str(lltype),
319
+ "elements": m.add_metadata([mdrange]),
320
+ },
321
+ )
322
+ elif isinstance(lltype, ir.PointerType):
323
+ model = getattr(datamodel, "_pointee_model", None)
324
+ basetype = self._var_type(
325
+ lltype.pointee, self.cgctx.get_abi_sizeof(lltype.pointee), model
326
+ )
327
+ mdtype = m.add_debug_info(
328
+ "DIDerivedType",
329
+ {
330
+ "tag": ir.DIToken("DW_TAG_pointer_type"),
331
+ "baseType": basetype,
332
+ "size": _BYTE_SIZE * self.cgctx.get_abi_sizeof(lltype),
333
+ },
334
+ )
335
+ elif isinstance(lltype, ir.LiteralStructType):
336
+ # Struct type
337
+ meta = []
338
+ offset = 0
339
+ if datamodel is None or not datamodel.inner_models():
340
+ name = f"Anonymous struct ({str(lltype)})"
341
+ for field_id, element in enumerate(lltype.elements):
342
+ size = self.cgctx.get_abi_sizeof(element)
343
+ basetype = self._var_type(element, size)
344
+ derived_type = m.add_debug_info(
345
+ "DIDerivedType",
346
+ {
347
+ "tag": ir.DIToken("DW_TAG_member"),
348
+ "name": f"<field {field_id}>",
349
+ "baseType": basetype,
350
+ "size": _BYTE_SIZE
351
+ * size, # DW_TAG_member size is in bits
352
+ "offset": offset,
353
+ },
354
+ )
355
+ meta.append(derived_type)
356
+ offset += _BYTE_SIZE * size # offset is in bits
357
+ else:
358
+ name = f"{datamodel.fe_type} ({str(lltype)})"
359
+ for element, field, model in zip(
360
+ lltype.elements, datamodel._fields, datamodel.inner_models()
361
+ ):
362
+ size = self.cgctx.get_abi_sizeof(element)
363
+ basetype = self._var_type(element, size, datamodel=model)
364
+ derived_type = m.add_debug_info(
365
+ "DIDerivedType",
366
+ {
367
+ "tag": ir.DIToken("DW_TAG_member"),
368
+ "name": field,
369
+ "baseType": basetype,
370
+ "size": _BYTE_SIZE
371
+ * size, # DW_TAG_member size is in bits
372
+ "offset": offset,
373
+ },
374
+ )
375
+ meta.append(derived_type)
376
+ offset += _BYTE_SIZE * size # offset is in bits
377
+
378
+ mdtype = m.add_debug_info(
379
+ "DICompositeType",
380
+ {
381
+ "tag": ir.DIToken("DW_TAG_structure_type"),
382
+ "name": name,
383
+ "identifier": str(lltype),
384
+ "elements": m.add_metadata(meta),
385
+ "size": offset,
386
+ },
387
+ is_distinct=True,
388
+ )
389
+ elif isinstance(lltype, ir.ArrayType):
390
+ element = lltype.element
391
+ el_size = self.cgctx.get_abi_sizeof(element)
392
+ basetype = self._var_type(element, el_size)
393
+ count = size // el_size
394
+ mdrange = m.add_debug_info(
395
+ "DISubrange",
396
+ {
397
+ "count": count,
398
+ },
399
+ )
400
+ mdtype = m.add_debug_info(
401
+ "DICompositeType",
402
+ {
403
+ "tag": ir.DIToken("DW_TAG_array_type"),
404
+ "baseType": basetype,
405
+ "name": str(lltype),
406
+ "size": bitsize,
407
+ "identifier": str(lltype),
408
+ "elements": m.add_metadata([mdrange]),
409
+ },
410
+ )
411
+ else:
412
+ # For all other types, describe it as sequence of bytes
413
+ count = size
414
+ mdrange = m.add_debug_info(
415
+ "DISubrange",
416
+ {
417
+ "count": count,
418
+ },
419
+ )
420
+ mdbase = m.add_debug_info(
421
+ "DIBasicType",
422
+ {
423
+ "name": "byte",
424
+ "size": _BYTE_SIZE,
425
+ "encoding": ir.DIToken("DW_ATE_unsigned_char"),
426
+ },
427
+ )
428
+ mdtype = m.add_debug_info(
429
+ "DICompositeType",
430
+ {
431
+ "tag": ir.DIToken("DW_TAG_array_type"),
432
+ "baseType": mdbase,
433
+ "name": str(lltype),
434
+ "size": bitsize,
435
+ "identifier": str(lltype),
436
+ "elements": m.add_metadata([mdrange]),
437
+ },
438
+ )
439
+
440
+ return mdtype
441
+
442
+ def mark_variable(
443
+ self,
444
+ builder,
445
+ allocavalue,
446
+ name,
447
+ lltype,
448
+ size,
449
+ line,
450
+ datamodel=None,
451
+ argidx=None,
452
+ ):
453
+ arg_index = 0 if argidx is None else argidx
454
+ m = self.module
455
+ fnty = ir.FunctionType(ir.VoidType(), [ir.MetaDataType()] * 3)
456
+ decl = cgutils.get_or_insert_function(m, fnty, "llvm.dbg.declare")
457
+
458
+ mdtype = self._var_type(lltype, size, datamodel=datamodel)
459
+ name = name.replace(".", "$") # for gdb to work correctly
460
+ mdlocalvar = m.add_debug_info(
461
+ "DILocalVariable",
462
+ {
463
+ "name": name,
464
+ "arg": arg_index,
465
+ "scope": self.subprograms[-1],
466
+ "file": self.difile,
467
+ "line": line,
468
+ "type": mdtype,
469
+ },
470
+ )
471
+ mdexpr = m.add_debug_info("DIExpression", {})
472
+
473
+ return builder.call(decl, [allocavalue, mdlocalvar, mdexpr])
474
+
475
+ def mark_location(self, builder, line):
476
+ builder.debug_metadata = self._add_location(line)
477
+
478
+ def mark_subprogram(self, function, qualname, argnames, argtypes, line):
479
+ name = qualname
480
+ argmap = dict(zip(argnames, argtypes))
481
+ di_subp = self._add_subprogram(
482
+ name=name,
483
+ linkagename=function.name,
484
+ line=line,
485
+ function=function,
486
+ argmap=argmap,
487
+ )
488
+ function.set_metadata("dbg", di_subp)
489
+
490
+ def finalize(self):
491
+ dbgcu = cgutils.get_or_insert_named_metadata(
492
+ self.module, self.DBG_CU_NAME
493
+ )
494
+ dbgcu.add(self.dicompileunit)
495
+ self._set_module_flags()
496
+
497
+ #
498
+ # Internal APIs
499
+ #
500
+
501
+ def _set_module_flags(self):
502
+ """Set the module flags metadata"""
503
+ module = self.module
504
+ mflags = cgutils.get_or_insert_named_metadata(
505
+ module, "llvm.module.flags"
506
+ )
507
+ # Set *require* behavior to warning
508
+ # See http://llvm.org/docs/LangRef.html#module-flags-metadata
509
+ require_warning_behavior = self._const_int(2)
510
+ if self.DWARF_VERSION is not None:
511
+ dwarf_version = module.add_metadata(
512
+ [
513
+ require_warning_behavior,
514
+ "Dwarf Version",
515
+ self._const_int(self.DWARF_VERSION),
516
+ ]
517
+ )
518
+ if dwarf_version not in mflags.operands:
519
+ mflags.add(dwarf_version)
520
+ debuginfo_version = module.add_metadata(
521
+ [
522
+ require_warning_behavior,
523
+ "Debug Info Version",
524
+ self._const_int(self.DEBUG_INFO_VERSION),
525
+ ]
526
+ )
527
+ if debuginfo_version not in mflags.operands:
528
+ mflags.add(debuginfo_version)
529
+
530
+ def _add_subprogram(self, name, linkagename, line, function, argmap):
531
+ """Emit subprogram metadata"""
532
+ subp = self._di_subprogram(name, linkagename, line, function, argmap)
533
+ self.subprograms.append(subp)
534
+ return subp
535
+
536
+ def _add_location(self, line):
537
+ """Emit location metatdaa"""
538
+ loc = self._di_location(line)
539
+ return loc
540
+
541
+ @classmethod
542
+ def _const_int(cls, num, bits=32):
543
+ """Util to create constant int in metadata"""
544
+ return ir.IntType(bits)(num)
545
+
546
+ @classmethod
547
+ def _const_bool(cls, boolean):
548
+ """Util to create constant boolean in metadata"""
549
+ return ir.IntType(1)(boolean)
550
+
551
+ #
552
+ # Helpers to emit the metadata nodes
553
+ #
554
+
555
+ def _di_file(self):
556
+ return self.module.add_debug_info(
557
+ "DIFile",
558
+ {
559
+ "directory": os.path.dirname(self.filepath),
560
+ "filename": os.path.basename(self.filepath),
561
+ },
562
+ )
563
+
564
+ def _di_compile_unit(self):
565
+ return self.module.add_debug_info(
566
+ "DICompileUnit",
567
+ {
568
+ "language": ir.DIToken("DW_LANG_C_plus_plus"),
569
+ "file": self.difile,
570
+ # Numba has to pretend to be clang to ensure the prologue is skipped
571
+ # correctly in gdb. See:
572
+ # https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/amd64-tdep.c;h=e563d369d8cb3eb3c2f732c2fa850ec70ba8d63b;hb=a4b0231e179607e47b1cdf1fe15c5dc25e482fad#l2521
573
+ # Note the "producer_is_llvm" call to specialise the prologue
574
+ # handling, this is defined here:
575
+ # https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/producer.c;h=cdfd80d904c09394febd18749bb90359b2d128cc;hb=a4b0231e179607e47b1cdf1fe15c5dc25e482fad#l124
576
+ # and to get a match for this condition the 'producer' must start
577
+ # with "clang ", hence the following...
578
+ "producer": "clang (Numba)",
579
+ "runtimeVersion": 0,
580
+ "isOptimized": config.OPT != 0,
581
+ "emissionKind": ir.DIToken(self.emission_kind),
582
+ },
583
+ is_distinct=True,
584
+ )
585
+
586
+ def _di_subroutine_type(self, line, function, argmap):
587
+ # The function call conv needs encoding.
588
+ llfunc = function
589
+ md = []
590
+
591
+ for idx, llarg in enumerate(llfunc.args):
592
+ if not llarg.name.startswith("arg."):
593
+ name = llarg.name.replace(".", "$") # for gdb to work correctly
594
+ lltype = llarg.type
595
+ size = self.cgctx.get_abi_sizeof(lltype)
596
+ mdtype = self._var_type(lltype, size, datamodel=None)
597
+ md.append(mdtype)
598
+
599
+ for idx, (name, nbtype) in enumerate(argmap.items()):
600
+ name = name.replace(".", "$") # for gdb to work correctly
601
+ datamodel = self.cgctx.data_model_manager[nbtype]
602
+ lltype = self.cgctx.get_value_type(nbtype)
603
+ size = self.cgctx.get_abi_sizeof(lltype)
604
+ mdtype = self._var_type(lltype, size, datamodel=datamodel)
605
+ md.append(mdtype)
606
+
607
+ return self.module.add_debug_info(
608
+ "DISubroutineType",
609
+ {
610
+ "types": self.module.add_metadata(md),
611
+ },
612
+ )
613
+
614
+ def _di_subprogram(self, name, linkagename, line, function, argmap):
615
+ return self.module.add_debug_info(
616
+ "DISubprogram",
617
+ {
618
+ "name": name,
619
+ "linkageName": linkagename,
620
+ "scope": self.difile,
621
+ "file": self.difile,
622
+ "line": line,
623
+ "type": self._di_subroutine_type(line, function, argmap),
624
+ "isLocal": False,
625
+ "isDefinition": True,
626
+ "scopeLine": line,
627
+ "isOptimized": config.OPT != 0,
628
+ "unit": self.dicompileunit,
629
+ },
630
+ is_distinct=True,
631
+ )
632
+
633
+ def _di_location(self, line):
634
+ return self.module.add_debug_info(
635
+ "DILocation",
636
+ {
637
+ "line": line,
638
+ "column": 1,
639
+ "scope": self.subprograms[-1],
640
+ },
641
+ )
642
+
643
+
644
+ class CUDADIBuilder(DIBuilder):
645
+ def __init__(self, module, filepath, cgctx, directives_only):
646
+ super().__init__(module, filepath, cgctx, directives_only)
647
+ # Cache for local variable metadata type and line deduplication
648
+ self._vartypelinemap = {}
649
+ # Variable address space dictionary
650
+ self._var_addrspace_map = {}
651
+
652
+ def _set_addrspace_map(self, map):
653
+ self._var_addrspace_map = map
654
+
655
+ def _var_type(self, lltype, size, datamodel=None):
656
+ is_bool = False
657
+ is_int_literal = False
658
+ is_grid_group = False
659
+ m = self.module
660
+
661
+ if isinstance(lltype, ir.IntType):
662
+ if datamodel is None:
663
+ if size == 1:
664
+ name = str(lltype)
665
+ is_bool = True
666
+ else:
667
+ name = str(datamodel.fe_type)
668
+ if isinstance(datamodel.fe_type, types.Boolean):
669
+ is_bool = True
670
+ if isinstance(datamodel.fe_type, types.BooleanLiteral):
671
+ name = "bool"
672
+ elif isinstance(datamodel.fe_type, types.Integer):
673
+ if isinstance(datamodel.fe_type, types.IntegerLiteral):
674
+ name = f"int{_BYTE_SIZE * size}"
675
+ is_int_literal = True
676
+ elif isinstance(datamodel.fe_type, GridGroup):
677
+ is_grid_group = True
678
+
679
+ if is_bool or is_int_literal or is_grid_group:
680
+ bitsize = _BYTE_SIZE * size
681
+ # Boolean type workaround until upstream Numba is fixed
682
+ if is_bool:
683
+ ditok = "DW_ATE_boolean"
684
+ elif is_int_literal:
685
+ ditok = "DW_ATE_signed"
686
+ # GridGroup type should use numba.cuda implementation
687
+ elif is_grid_group:
688
+ ditok = "DW_ATE_unsigned"
689
+
690
+ return m.add_debug_info(
691
+ "DIBasicType",
692
+ {
693
+ "name": name,
694
+ "size": bitsize,
695
+ "encoding": ir.DIToken(ditok),
696
+ },
697
+ )
698
+
699
+ if isinstance(datamodel, UnionModel):
700
+ # UnionModel is handled here to represent polymorphic types
701
+ meta = []
702
+ maxwidth = 0
703
+ for field, model in zip(
704
+ datamodel._fields, datamodel.inner_models()
705
+ ):
706
+ # Ignore the "tag" field, focus on the "payload" field which
707
+ # contains the data types in memory
708
+ if field == "payload":
709
+ # Store metadata dictionaries to create members later
710
+ member_metadata_dicts = []
711
+
712
+ for index, mod in enumerate(model.inner_models()):
713
+ dtype = mod.get_value_type()
714
+ membersize = self.cgctx.get_abi_sizeof(dtype)
715
+ basetype = self._var_type(
716
+ dtype, membersize, datamodel=mod
717
+ )
718
+ if isinstance(mod.fe_type, types.Literal):
719
+ typename = str(mod.fe_type.literal_type)
720
+ else:
721
+ typename = str(mod.fe_type)
722
+ # Use a prefix "_" on type names as field names
723
+ membername = "_" + typename
724
+ memberwidth = _BYTE_SIZE * membersize
725
+ # Build the metadata dictionary
726
+ metadata_dict = {
727
+ "tag": ir.DIToken("DW_TAG_member"),
728
+ "name": membername,
729
+ "baseType": basetype,
730
+ # DW_TAG_member size is in bits
731
+ "size": memberwidth,
732
+ }
733
+ if config.CUDA_DEBUG_POLY:
734
+ # Polymorphic debug info with DW_TAG_variant
735
+ # extraData depends on llvmlite version
736
+ if config.CUDA_DEBUG_POLY_USE_TYPED_CONST:
737
+ metadata_dict["extraData"] = ir.IntType(8)(
738
+ index
739
+ )
740
+ else:
741
+ # Use metadata node reference
742
+ metadata_dict["extraData"] = m.add_metadata(
743
+ [ir.IntType(8)(index)]
744
+ )
745
+ # Add offset to each variant member
746
+ # Offset equals the element's own width
747
+ metadata_dict["offset"] = memberwidth
748
+ member_metadata_dicts.append(metadata_dict)
749
+ if memberwidth > maxwidth:
750
+ maxwidth = memberwidth
751
+
752
+ # Create the member DIDerivedTypes
753
+ for metadata_dict in member_metadata_dicts:
754
+ derived_type = m.add_debug_info(
755
+ "DIDerivedType", metadata_dict
756
+ )
757
+ meta.append(derived_type)
758
+
759
+ if config.CUDA_DEBUG_POLY:
760
+ # Polymorphic variable debug info generation
761
+ wrapper_struct_size = 2 * maxwidth
762
+ # Generate unique discriminator name based on composite type
763
+ variant_elements_metadata = m.add_metadata(meta)
764
+ discriminator_unique_id = str(id(variant_elements_metadata))
765
+ discriminator_name = f"discriminator-{discriminator_unique_id}"
766
+ discriminator = m.add_debug_info(
767
+ "DIDerivedType",
768
+ {
769
+ "tag": ir.DIToken("DW_TAG_member"),
770
+ "name": discriminator_name,
771
+ "baseType": m.add_debug_info(
772
+ "DIBasicType",
773
+ {
774
+ "name": "int",
775
+ "size": _BYTE_SIZE,
776
+ "encoding": ir.DIToken("DW_ATE_unsigned"),
777
+ },
778
+ ),
779
+ "size": _BYTE_SIZE,
780
+ "flags": ir.DIToken("DIFlagArtificial"),
781
+ },
782
+ )
783
+ # Create the final variant_part with actual members
784
+ variant_unique_identifier = discriminator_unique_id
785
+ variant_part_type = m.add_debug_info(
786
+ "DICompositeType",
787
+ {
788
+ "file": self.difile,
789
+ "tag": ir.DIToken("DW_TAG_variant_part"),
790
+ "name": "variant_part",
791
+ "identifier": variant_unique_identifier,
792
+ "elements": variant_elements_metadata,
793
+ "size": maxwidth,
794
+ "discriminator": discriminator,
795
+ },
796
+ )
797
+ # Create elements metadata for wrapper struct
798
+ elements_metadata = m.add_metadata(
799
+ [discriminator, variant_part_type]
800
+ )
801
+ unique_identifier = str(id(elements_metadata))
802
+ wrapper_struct = m.add_debug_info(
803
+ "DICompositeType",
804
+ {
805
+ "file": self.difile,
806
+ "tag": ir.DIToken("DW_TAG_structure_type"),
807
+ "name": "variant_wrapper_struct",
808
+ "identifier": unique_identifier,
809
+ "elements": elements_metadata,
810
+ "size": wrapper_struct_size,
811
+ },
812
+ )
813
+ return wrapper_struct
814
+ else:
815
+ fake_union_name = "dbg_poly_union"
816
+ return m.add_debug_info(
817
+ "DICompositeType",
818
+ {
819
+ "file": self.difile,
820
+ "tag": ir.DIToken("DW_TAG_union_type"),
821
+ "name": fake_union_name,
822
+ "identifier": str(lltype),
823
+ "elements": m.add_metadata(meta),
824
+ "size": maxwidth,
825
+ },
826
+ is_distinct=True,
827
+ )
828
+
829
+ # Check if there's actually address space info to handle
830
+ addrspace = getattr(self, "_addrspace", None)
831
+ if (
832
+ isinstance(lltype, ir.LiteralStructType)
833
+ and datamodel is not None
834
+ and datamodel.inner_models()
835
+ and addrspace not in (None, 0)
836
+ ):
837
+ # Process struct with datamodel that has address space info
838
+ meta = []
839
+ offset = 0
840
+ for element, field, model in zip(
841
+ lltype.elements, datamodel._fields, datamodel.inner_models()
842
+ ):
843
+ size_field = self.cgctx.get_abi_sizeof(element)
844
+ if isinstance(element, ir.PointerType) and field == "data":
845
+ # Create pointer type with correct address space
846
+ pointee_size = self.cgctx.get_abi_sizeof(element.pointee)
847
+ pointee_model = getattr(model, "_pointee_model", None)
848
+ pointee_type = self._var_type(
849
+ element.pointee, pointee_size, datamodel=pointee_model
850
+ )
851
+ meta_ptr = {
852
+ "tag": ir.DIToken("DW_TAG_pointer_type"),
853
+ "baseType": pointee_type,
854
+ "size": _BYTE_SIZE * size_field,
855
+ }
856
+ dwarf_addrclass = self.get_dwarf_address_class(addrspace)
857
+ if dwarf_addrclass is not None:
858
+ meta_ptr["dwarfAddressSpace"] = int(dwarf_addrclass)
859
+ basetype = m.add_debug_info("DIDerivedType", meta_ptr)
860
+ else:
861
+ basetype = self._var_type(
862
+ element, size_field, datamodel=model
863
+ )
864
+ derived_type = m.add_debug_info(
865
+ "DIDerivedType",
866
+ {
867
+ "tag": ir.DIToken("DW_TAG_member"),
868
+ "name": field,
869
+ "baseType": basetype,
870
+ "size": _BYTE_SIZE * size_field,
871
+ "offset": offset,
872
+ },
873
+ )
874
+ meta.append(derived_type)
875
+ offset += _BYTE_SIZE * size_field
876
+
877
+ return m.add_debug_info(
878
+ "DICompositeType",
879
+ {
880
+ "tag": ir.DIToken("DW_TAG_structure_type"),
881
+ "name": f"{datamodel.fe_type}",
882
+ "elements": m.add_metadata(meta),
883
+ "size": offset,
884
+ },
885
+ is_distinct=True,
886
+ )
887
+ # For other cases, use upstream Numba implementation
888
+ return super()._var_type(lltype, size, datamodel=datamodel)
889
+
890
+ def _di_subroutine_type(self, line, function, argmap):
891
+ # The function call conv needs encoding.
892
+ llfunc = function
893
+ md = []
894
+
895
+ # Create metadata type for return value
896
+ if len(llfunc.args) > 0:
897
+ lltype = llfunc.args[0].type
898
+ size = self.cgctx.get_abi_sizeof(lltype)
899
+ mdtype = self._var_type(lltype, size, datamodel=None)
900
+ md.append(mdtype)
901
+
902
+ # Create metadata type for arguments
903
+ for idx, (name, nbtype) in enumerate(argmap.items()):
904
+ datamodel = self.cgctx.data_model_manager[nbtype]
905
+ lltype = self.cgctx.get_value_type(nbtype)
906
+ size = self.cgctx.get_abi_sizeof(lltype)
907
+ mdtype = self._var_type(lltype, size, datamodel=datamodel)
908
+ md.append(mdtype)
909
+
910
+ return self.module.add_debug_info(
911
+ "DISubroutineType",
912
+ {
913
+ "types": self.module.add_metadata(md),
914
+ },
915
+ )
916
+
917
+ def mark_variable(
918
+ self,
919
+ builder,
920
+ allocavalue,
921
+ name,
922
+ lltype,
923
+ size,
924
+ line,
925
+ datamodel=None,
926
+ argidx=None,
927
+ ):
928
+ if name.startswith("$") or "." in name:
929
+ # Do not emit llvm.dbg.declare on user variable alias
930
+ return
931
+ else:
932
+ int_type = (ir.IntType,)
933
+ real_type = ir.FloatType, ir.DoubleType
934
+ if isinstance(lltype, int_type + real_type):
935
+ # Start with scalar variable, swtiching llvm.dbg.declare
936
+ # to llvm.dbg.value
937
+ return
938
+ else:
939
+ # Look up address space for this variable
940
+ self._addrspace = self._var_addrspace_map.get(name)
941
+ try:
942
+ return super().mark_variable(
943
+ builder,
944
+ allocavalue,
945
+ name,
946
+ lltype,
947
+ size,
948
+ line,
949
+ datamodel,
950
+ argidx,
951
+ )
952
+ finally:
953
+ # Clean up address space info
954
+ self._addrspace = None
955
+
956
+ def update_variable(
957
+ self,
958
+ builder,
959
+ value,
960
+ name,
961
+ lltype,
962
+ size,
963
+ line,
964
+ datamodel=None,
965
+ argidx=None,
966
+ ):
967
+ m = self.module
968
+ fnty = ir.FunctionType(ir.VoidType(), [ir.MetaDataType()] * 3)
969
+ decl = cgutils.get_or_insert_function(m, fnty, "llvm.dbg.value")
970
+
971
+ mdtype = self._var_type(lltype, size, datamodel)
972
+ index = name.find(".")
973
+ if index >= 0:
974
+ name = name[:index]
975
+ # Merge DILocalVariable nodes with same name and type but different
976
+ # lines. Use the cached [(name, type) -> line] info to deduplicate
977
+ # metadata. Use the lltype as part of key.
978
+ key = (name, lltype)
979
+ if key in self._vartypelinemap:
980
+ line = self._vartypelinemap[key]
981
+ else:
982
+ self._vartypelinemap[key] = line
983
+ arg_index = 0 if argidx is None else argidx
984
+ mdlocalvar = m.add_debug_info(
985
+ "DILocalVariable",
986
+ {
987
+ "name": name,
988
+ "arg": arg_index,
989
+ "scope": self.subprograms[-1],
990
+ "file": self.difile,
991
+ "line": line,
992
+ "type": mdtype,
993
+ },
994
+ )
995
+ mdexpr = m.add_debug_info("DIExpression", {})
996
+
997
+ return builder.call(decl, [value, mdlocalvar, mdexpr])