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,532 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ // SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ /*
5
+ * This file and _hashtable.h are from CPython 3.5. The symbols have been
6
+ * renamed from _Py_hashxxx to _Numba_hashxxx to avoid name clashes with
7
+ * the CPython definitions (including at runtime through dynamic linking).
8
+ * Those CPython APIs are private and can change in incompatible ways at
9
+ * any time.
10
+ *
11
+ * Command line used for renaming:
12
+ * $ sed -i -r 's/\b_Py_(has[h]table)/_Numba_\1/ig' numba/_hashtable.h numba/_hashtable.c
13
+ */
14
+
15
+ /* The implementation of the hash table (_Numba_hashtable_t) is based on the cfuhash
16
+ project:
17
+ http://sourceforge.net/projects/libcfu/
18
+
19
+ Copyright of cfuhash:
20
+ ----------------------------------
21
+ Creation date: 2005-06-24 21:22:40
22
+ Authors: Don
23
+ Change log:
24
+
25
+ Copyright (c) 2005 Don Owens
26
+ All rights reserved.
27
+
28
+ This code is released under the BSD license:
29
+
30
+ Redistribution and use in source and binary forms, with or without
31
+ modification, are permitted provided that the following conditions
32
+ are met:
33
+
34
+ * Redistributions of source code must retain the above copyright
35
+ notice, this list of conditions and the following disclaimer.
36
+
37
+ * Redistributions in binary form must reproduce the above
38
+ copyright notice, this list of conditions and the following
39
+ disclaimer in the documentation and/or other materials provided
40
+ with the distribution.
41
+
42
+ * Neither the name of the author nor the names of its
43
+ contributors may be used to endorse or promote products derived
44
+ from this software without specific prior written permission.
45
+
46
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
47
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
48
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
49
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
50
+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
51
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
57
+ OF THE POSSIBILITY OF SUCH DAMAGE.
58
+ ----------------------------------
59
+ */
60
+
61
+ #include "_pymodule.h"
62
+ #include "_hashtable.h"
63
+
64
+ #define HASHTABLE_MIN_SIZE 16
65
+ #define HASHTABLE_HIGH 0.50
66
+ #define HASHTABLE_LOW 0.10
67
+ #define HASHTABLE_REHASH_FACTOR 2.0 / (HASHTABLE_LOW + HASHTABLE_HIGH)
68
+
69
+ #define BUCKETS_HEAD(SLIST) \
70
+ ((_Numba_hashtable_entry_t *)_Py_SLIST_HEAD(&(SLIST)))
71
+ #define TABLE_HEAD(HT, BUCKET) \
72
+ ((_Numba_hashtable_entry_t *)_Py_SLIST_HEAD(&(HT)->buckets[BUCKET]))
73
+ #define ENTRY_NEXT(ENTRY) \
74
+ ((_Numba_hashtable_entry_t *)_Py_SLIST_ITEM_NEXT(ENTRY))
75
+ #define HASHTABLE_ITEM_SIZE(HT) \
76
+ (sizeof(_Numba_hashtable_entry_t) + (HT)->data_size)
77
+
78
+ /* Forward declaration */
79
+ static void hashtable_rehash(_Numba_hashtable_t *ht);
80
+
81
+ static void
82
+ _Py_slist_init(_Py_slist_t *list)
83
+ {
84
+ list->head = NULL;
85
+ }
86
+
87
+ static void
88
+ _Py_slist_prepend(_Py_slist_t *list, _Py_slist_item_t *item)
89
+ {
90
+ item->next = list->head;
91
+ list->head = item;
92
+ }
93
+
94
+ static void
95
+ _Py_slist_remove(_Py_slist_t *list, _Py_slist_item_t *previous,
96
+ _Py_slist_item_t *item)
97
+ {
98
+ if (previous != NULL)
99
+ previous->next = item->next;
100
+ else
101
+ list->head = item->next;
102
+ }
103
+
104
+ extern "C" Py_uhash_t
105
+ _Numba_hashtable_hash_int(const void *key)
106
+ {
107
+ return (Py_uhash_t)key;
108
+ }
109
+
110
+ extern "C" Py_uhash_t
111
+ _Numba_hashtable_hash_ptr(const void *key)
112
+ {
113
+ return (Py_uhash_t)_Py_HashPointer((void *)key);
114
+ }
115
+
116
+ extern "C" int
117
+ _Numba_hashtable_compare_direct(const void *key, const _Numba_hashtable_entry_t *entry)
118
+ {
119
+ return entry->key == key;
120
+ }
121
+
122
+ /* makes sure the real size of the buckets array is a power of 2 */
123
+ static size_t
124
+ round_size(size_t s)
125
+ {
126
+ size_t i;
127
+ if (s < HASHTABLE_MIN_SIZE)
128
+ return HASHTABLE_MIN_SIZE;
129
+ i = 1;
130
+ while (i < s)
131
+ i <<= 1;
132
+ return i;
133
+ }
134
+
135
+ extern "C" _Numba_hashtable_t *
136
+ _Numba_hashtable_new_full(size_t data_size, size_t init_size,
137
+ _Numba_hashtable_hash_func hash_func,
138
+ _Numba_hashtable_compare_func compare_func,
139
+ _Numba_hashtable_copy_data_func copy_data_func,
140
+ _Numba_hashtable_free_data_func free_data_func,
141
+ _Numba_hashtable_get_data_size_func get_data_size_func,
142
+ _Numba_hashtable_allocator_t *allocator)
143
+ {
144
+ _Numba_hashtable_t *ht;
145
+ size_t buckets_size;
146
+ _Numba_hashtable_allocator_t alloc;
147
+
148
+ if (allocator == NULL) {
149
+ alloc.malloc = PyMem_RawMalloc;
150
+ alloc.free = PyMem_RawFree;
151
+ }
152
+ else
153
+ alloc = *allocator;
154
+
155
+ ht = (_Numba_hashtable_t *)alloc.malloc(sizeof(_Numba_hashtable_t));
156
+ if (ht == NULL)
157
+ return ht;
158
+
159
+ ht->num_buckets = round_size(init_size);
160
+ ht->entries = 0;
161
+ ht->data_size = data_size;
162
+
163
+ buckets_size = ht->num_buckets * sizeof(ht->buckets[0]);
164
+ ht->buckets = (_Py_slist_t *) alloc.malloc(buckets_size);
165
+ if (ht->buckets == NULL) {
166
+ alloc.free(ht);
167
+ return NULL;
168
+ }
169
+ memset(ht->buckets, 0, buckets_size);
170
+
171
+ ht->hash_func = hash_func;
172
+ ht->compare_func = compare_func;
173
+ ht->copy_data_func = copy_data_func;
174
+ ht->free_data_func = free_data_func;
175
+ ht->get_data_size_func = get_data_size_func;
176
+ ht->alloc = alloc;
177
+ return ht;
178
+ }
179
+
180
+ extern "C" _Numba_hashtable_t *
181
+ _Numba_hashtable_new(size_t data_size,
182
+ _Numba_hashtable_hash_func hash_func,
183
+ _Numba_hashtable_compare_func compare_func)
184
+ {
185
+ return _Numba_hashtable_new_full(data_size, HASHTABLE_MIN_SIZE,
186
+ hash_func, compare_func,
187
+ NULL, NULL, NULL, NULL);
188
+ }
189
+
190
+ extern "C" size_t
191
+ _Numba_hashtable_size(_Numba_hashtable_t *ht)
192
+ {
193
+ size_t size;
194
+ size_t hv;
195
+
196
+ size = sizeof(_Numba_hashtable_t);
197
+
198
+ /* buckets */
199
+ size += ht->num_buckets * sizeof(_Numba_hashtable_entry_t *);
200
+
201
+ /* entries */
202
+ size += ht->entries * HASHTABLE_ITEM_SIZE(ht);
203
+
204
+ /* data linked from entries */
205
+ if (ht->get_data_size_func) {
206
+ for (hv = 0; hv < ht->num_buckets; hv++) {
207
+ _Numba_hashtable_entry_t *entry;
208
+
209
+ for (entry = TABLE_HEAD(ht, hv); entry; entry = ENTRY_NEXT(entry)) {
210
+ void *data;
211
+
212
+ data = _Numba_HASHTABLE_ENTRY_DATA_AS_VOID_P(entry);
213
+ size += ht->get_data_size_func(data);
214
+ }
215
+ }
216
+ }
217
+ return size;
218
+ }
219
+
220
+ #ifdef Py_DEBUG
221
+ extern "C" void
222
+ _Numba_hashtable_print_stats(_Numba_hashtable_t *ht)
223
+ {
224
+ size_t size;
225
+ size_t chain_len, max_chain_len, total_chain_len, nchains;
226
+ _Numba_hashtable_entry_t *entry;
227
+ size_t hv;
228
+ double load;
229
+
230
+ size = _Numba_hashtable_size(ht);
231
+
232
+ load = (double)ht->entries / ht->num_buckets;
233
+
234
+ max_chain_len = 0;
235
+ total_chain_len = 0;
236
+ nchains = 0;
237
+ for (hv = 0; hv < ht->num_buckets; hv++) {
238
+ entry = TABLE_HEAD(ht, hv);
239
+ if (entry != NULL) {
240
+ chain_len = 0;
241
+ for (; entry; entry = ENTRY_NEXT(entry)) {
242
+ chain_len++;
243
+ }
244
+ if (chain_len > max_chain_len)
245
+ max_chain_len = chain_len;
246
+ total_chain_len += chain_len;
247
+ nchains++;
248
+ }
249
+ }
250
+ printf("hash table %p: entries=%"
251
+ PY_FORMAT_SIZE_T "u/%" PY_FORMAT_SIZE_T "u (%.0f%%), ",
252
+ ht, ht->entries, ht->num_buckets, load * 100.0);
253
+ if (nchains)
254
+ printf("avg_chain_len=%.1f, ", (double)total_chain_len / nchains);
255
+ printf("max_chain_len=%" PY_FORMAT_SIZE_T "u, %" PY_FORMAT_SIZE_T "u kB\n",
256
+ max_chain_len, size / 1024);
257
+ }
258
+ #endif
259
+
260
+ /* Get an entry. Return NULL if the key does not exist. */
261
+ extern "C" _Numba_hashtable_entry_t *
262
+ _Numba_hashtable_get_entry(_Numba_hashtable_t *ht, const void *key)
263
+ {
264
+ Py_uhash_t key_hash;
265
+ size_t index;
266
+ _Numba_hashtable_entry_t *entry;
267
+
268
+ key_hash = ht->hash_func(key);
269
+ index = key_hash & (ht->num_buckets - 1);
270
+
271
+ for (entry = TABLE_HEAD(ht, index); entry != NULL; entry = ENTRY_NEXT(entry)) {
272
+ if (entry->key_hash == key_hash && ht->compare_func(key, entry))
273
+ break;
274
+ }
275
+
276
+ return entry;
277
+ }
278
+
279
+ static int
280
+ _hashtable_pop_entry(_Numba_hashtable_t *ht, const void *key, void *data, size_t data_size)
281
+ {
282
+ Py_uhash_t key_hash;
283
+ size_t index;
284
+ _Numba_hashtable_entry_t *entry, *previous;
285
+
286
+ key_hash = ht->hash_func(key);
287
+ index = key_hash & (ht->num_buckets - 1);
288
+
289
+ previous = NULL;
290
+ for (entry = TABLE_HEAD(ht, index); entry != NULL; entry = ENTRY_NEXT(entry)) {
291
+ if (entry->key_hash == key_hash && ht->compare_func(key, entry))
292
+ break;
293
+ previous = entry;
294
+ }
295
+
296
+ if (entry == NULL)
297
+ return 0;
298
+
299
+ _Py_slist_remove(&ht->buckets[index], (_Py_slist_item_t *)previous,
300
+ (_Py_slist_item_t *)entry);
301
+ ht->entries--;
302
+
303
+ if (data != NULL)
304
+ _Numba_HASHTABLE_ENTRY_READ_DATA(ht, data, data_size, entry);
305
+ ht->alloc.free(entry);
306
+
307
+ if ((float)ht->entries / (float)ht->num_buckets < HASHTABLE_LOW)
308
+ hashtable_rehash(ht);
309
+ return 1;
310
+ }
311
+
312
+ /* Add a new entry to the hash. The key must not be present in the hash table.
313
+ Return 0 on success, -1 on memory error. */
314
+ extern "C" int
315
+ _Numba_hashtable_set(_Numba_hashtable_t *ht, const void *key,
316
+ void *data, size_t data_size)
317
+ {
318
+ Py_uhash_t key_hash;
319
+ size_t index;
320
+ _Numba_hashtable_entry_t *entry;
321
+
322
+ assert(data != NULL || data_size == 0);
323
+ #ifndef NDEBUG
324
+ /* Don't write the assertion on a single line because it is interesting
325
+ to know the duplicated entry if the assertion failed. The entry can
326
+ be read using a debugger. */
327
+ entry = _Numba_hashtable_get_entry(ht, key);
328
+ assert(entry == NULL);
329
+ #endif
330
+
331
+ key_hash = ht->hash_func(key);
332
+ index = key_hash & (ht->num_buckets - 1);
333
+
334
+ entry = (_Numba_hashtable_entry_t *) ht->alloc.malloc(HASHTABLE_ITEM_SIZE(ht));
335
+ if (entry == NULL) {
336
+ /* memory allocation failed */
337
+ return -1;
338
+ }
339
+
340
+ entry->key = (void *)key;
341
+ entry->key_hash = key_hash;
342
+
343
+ assert(data_size == ht->data_size);
344
+ memcpy(_Numba_HASHTABLE_ENTRY_DATA(entry), data, data_size);
345
+
346
+ _Py_slist_prepend(&ht->buckets[index], (_Py_slist_item_t*)entry);
347
+ ht->entries++;
348
+
349
+ if ((float)ht->entries / (float)ht->num_buckets > HASHTABLE_HIGH)
350
+ hashtable_rehash(ht);
351
+ return 0;
352
+ }
353
+
354
+ /* Get data from an entry. Copy entry data into data and return 1 if the entry
355
+ exists, return 0 if the entry does not exist. */
356
+ extern "C" int
357
+ _Numba_hashtable_get(_Numba_hashtable_t *ht, const void *key, void *data, size_t data_size)
358
+ {
359
+ _Numba_hashtable_entry_t *entry;
360
+
361
+ assert(data != NULL);
362
+
363
+ entry = _Numba_hashtable_get_entry(ht, key);
364
+ if (entry == NULL)
365
+ return 0;
366
+ _Numba_HASHTABLE_ENTRY_READ_DATA(ht, data, data_size, entry);
367
+ return 1;
368
+ }
369
+
370
+ extern "C" int
371
+ _Numba_hashtable_pop(_Numba_hashtable_t *ht, const void *key, void *data, size_t data_size)
372
+ {
373
+ assert(data != NULL);
374
+ assert(ht->free_data_func == NULL);
375
+ return _hashtable_pop_entry(ht, key, data, data_size);
376
+ }
377
+
378
+ /* Delete an entry. The entry must exist. */
379
+ extern "C" void
380
+ _Numba_hashtable_delete(_Numba_hashtable_t *ht, const void *key)
381
+ {
382
+ #ifndef NDEBUG
383
+ int found = _hashtable_pop_entry(ht, key, NULL, 0);
384
+ assert(found);
385
+ #else
386
+ (void)_hashtable_pop_entry(ht, key, NULL, 0);
387
+ #endif
388
+ }
389
+
390
+ /* Prototype for a pointer to a function to be called foreach
391
+ key/value pair in the hash by hashtable_foreach(). Iteration
392
+ stops if a non-zero value is returned. */
393
+ extern "C" int
394
+ _Numba_hashtable_foreach(_Numba_hashtable_t *ht,
395
+ int (*func) (_Numba_hashtable_entry_t *entry, void *arg),
396
+ void *arg)
397
+ {
398
+ _Numba_hashtable_entry_t *entry;
399
+ size_t hv;
400
+
401
+ for (hv = 0; hv < ht->num_buckets; hv++) {
402
+ for (entry = TABLE_HEAD(ht, hv); entry; entry = ENTRY_NEXT(entry)) {
403
+ int res = func(entry, arg);
404
+ if (res)
405
+ return res;
406
+ }
407
+ }
408
+ return 0;
409
+ }
410
+
411
+ static void
412
+ hashtable_rehash(_Numba_hashtable_t *ht)
413
+ {
414
+ size_t buckets_size, new_size, bucket;
415
+ _Py_slist_t *old_buckets = NULL;
416
+ size_t old_num_buckets;
417
+
418
+ new_size = round_size((size_t)(ht->entries * HASHTABLE_REHASH_FACTOR));
419
+ if (new_size == ht->num_buckets)
420
+ return;
421
+
422
+ old_num_buckets = ht->num_buckets;
423
+
424
+ buckets_size = new_size * sizeof(ht->buckets[0]);
425
+ old_buckets = ht->buckets;
426
+ ht->buckets = (_Py_slist_t *) ht->alloc.malloc(buckets_size);
427
+ if (ht->buckets == NULL) {
428
+ /* cancel rehash on memory allocation failure */
429
+ ht->buckets = old_buckets ;
430
+ /* memory allocation failed */
431
+ return;
432
+ }
433
+ memset(ht->buckets, 0, buckets_size);
434
+
435
+ ht->num_buckets = new_size;
436
+
437
+ for (bucket = 0; bucket < old_num_buckets; bucket++) {
438
+ _Numba_hashtable_entry_t *entry, *next;
439
+ for (entry = BUCKETS_HEAD(old_buckets[bucket]); entry != NULL; entry = next) {
440
+ size_t entry_index;
441
+
442
+ assert(ht->hash_func(entry->key) == entry->key_hash);
443
+ next = ENTRY_NEXT(entry);
444
+ entry_index = entry->key_hash & (new_size - 1);
445
+
446
+ _Py_slist_prepend(&ht->buckets[entry_index], (_Py_slist_item_t*)entry);
447
+ }
448
+ }
449
+
450
+ ht->alloc.free(old_buckets);
451
+ }
452
+
453
+ extern "C" void
454
+ _Numba_hashtable_clear(_Numba_hashtable_t *ht)
455
+ {
456
+ _Numba_hashtable_entry_t *entry, *next;
457
+ size_t i;
458
+
459
+ for (i=0; i < ht->num_buckets; i++) {
460
+ for (entry = TABLE_HEAD(ht, i); entry != NULL; entry = next) {
461
+ next = ENTRY_NEXT(entry);
462
+ if (ht->free_data_func)
463
+ ht->free_data_func(_Numba_HASHTABLE_ENTRY_DATA_AS_VOID_P(entry));
464
+ ht->alloc.free(entry);
465
+ }
466
+ _Py_slist_init(&ht->buckets[i]);
467
+ }
468
+ ht->entries = 0;
469
+ hashtable_rehash(ht);
470
+ }
471
+
472
+ extern "C" void
473
+ _Numba_hashtable_destroy(_Numba_hashtable_t *ht)
474
+ {
475
+ size_t i;
476
+
477
+ for (i = 0; i < ht->num_buckets; i++) {
478
+ _Py_slist_item_t *entry = ht->buckets[i].head;
479
+ while (entry) {
480
+ _Py_slist_item_t *entry_next = entry->next;
481
+ if (ht->free_data_func)
482
+ ht->free_data_func(_Numba_HASHTABLE_ENTRY_DATA_AS_VOID_P(entry));
483
+ ht->alloc.free(entry);
484
+ entry = entry_next;
485
+ }
486
+ }
487
+
488
+ ht->alloc.free(ht->buckets);
489
+ ht->alloc.free(ht);
490
+ }
491
+
492
+ /* Return a copy of the hash table */
493
+ extern "C" _Numba_hashtable_t *
494
+ _Numba_hashtable_copy(_Numba_hashtable_t *src)
495
+ {
496
+ _Numba_hashtable_t *dst;
497
+ _Numba_hashtable_entry_t *entry;
498
+ size_t bucket;
499
+ int err;
500
+ void *data, *new_data;
501
+
502
+ dst = _Numba_hashtable_new_full(src->data_size, src->num_buckets,
503
+ src->hash_func, src->compare_func,
504
+ src->copy_data_func, src->free_data_func,
505
+ src->get_data_size_func, &src->alloc);
506
+ if (dst == NULL)
507
+ return NULL;
508
+
509
+ for (bucket=0; bucket < src->num_buckets; bucket++) {
510
+ entry = TABLE_HEAD(src, bucket);
511
+ for (; entry; entry = ENTRY_NEXT(entry)) {
512
+ if (src->copy_data_func) {
513
+ data = _Numba_HASHTABLE_ENTRY_DATA_AS_VOID_P(entry);
514
+ new_data = src->copy_data_func(data);
515
+ if (new_data != NULL)
516
+ err = _Numba_hashtable_set(dst, entry->key,
517
+ &new_data, src->data_size);
518
+ else
519
+ err = 1;
520
+ }
521
+ else {
522
+ data = _Numba_HASHTABLE_ENTRY_DATA(entry);
523
+ err = _Numba_hashtable_set(dst, entry->key, data, src->data_size);
524
+ }
525
+ if (err) {
526
+ _Numba_hashtable_destroy(dst);
527
+ return NULL;
528
+ }
529
+ }
530
+ }
531
+ return dst;
532
+ }
@@ -0,0 +1,135 @@
1
+ // SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ // SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ /*
5
+ * See _hashtable.c for more information about this file.
6
+ */
7
+
8
+ #ifndef Py_HASHTABLE_H
9
+ #define Py_HASHTABLE_H
10
+
11
+ /* The whole API is private */
12
+ #ifndef Py_LIMITED_API
13
+
14
+ typedef struct _Py_slist_item_s {
15
+ struct _Py_slist_item_s *next;
16
+ } _Py_slist_item_t;
17
+
18
+ typedef struct {
19
+ _Py_slist_item_t *head;
20
+ } _Py_slist_t;
21
+
22
+ #define _Py_SLIST_ITEM_NEXT(ITEM) (((_Py_slist_item_t *)ITEM)->next)
23
+
24
+ #define _Py_SLIST_HEAD(SLIST) (((_Py_slist_t *)SLIST)->head)
25
+
26
+ typedef struct {
27
+ /* used by _Numba_hashtable_t.buckets to link entries */
28
+ _Py_slist_item_t _Py_slist_item;
29
+
30
+ const void *key;
31
+ Py_uhash_t key_hash;
32
+
33
+ /* data follows */
34
+ } _Numba_hashtable_entry_t;
35
+
36
+ #define _Numba_HASHTABLE_ENTRY_DATA(ENTRY) \
37
+ ((char *)(ENTRY) + sizeof(_Numba_hashtable_entry_t))
38
+
39
+ #define _Numba_HASHTABLE_ENTRY_DATA_AS_VOID_P(ENTRY) \
40
+ (*(void **)_Numba_HASHTABLE_ENTRY_DATA(ENTRY))
41
+
42
+ #define _Numba_HASHTABLE_ENTRY_READ_DATA(TABLE, DATA, DATA_SIZE, ENTRY) \
43
+ do { \
44
+ assert((DATA_SIZE) == (TABLE)->data_size); \
45
+ memcpy(DATA, _Numba_HASHTABLE_ENTRY_DATA(ENTRY), DATA_SIZE); \
46
+ } while (0)
47
+
48
+ typedef Py_uhash_t (*_Numba_hashtable_hash_func) (const void *key);
49
+ typedef int (*_Numba_hashtable_compare_func) (const void *key, const _Numba_hashtable_entry_t *he);
50
+ typedef void* (*_Numba_hashtable_copy_data_func)(void *data);
51
+ typedef void (*_Numba_hashtable_free_data_func)(void *data);
52
+ typedef size_t (*_Numba_hashtable_get_data_size_func)(void *data);
53
+
54
+ typedef struct {
55
+ /* allocate a memory block */
56
+ void* (*malloc) (size_t size);
57
+
58
+ /* release a memory block */
59
+ void (*free) (void *ptr);
60
+ } _Numba_hashtable_allocator_t;
61
+
62
+ typedef struct {
63
+ size_t num_buckets;
64
+ size_t entries; /* Total number of entries in the table. */
65
+ _Py_slist_t *buckets;
66
+ size_t data_size;
67
+
68
+ _Numba_hashtable_hash_func hash_func;
69
+ _Numba_hashtable_compare_func compare_func;
70
+ _Numba_hashtable_copy_data_func copy_data_func;
71
+ _Numba_hashtable_free_data_func free_data_func;
72
+ _Numba_hashtable_get_data_size_func get_data_size_func;
73
+ _Numba_hashtable_allocator_t alloc;
74
+ } _Numba_hashtable_t;
75
+
76
+ /* hash and compare functions for integers and pointers */
77
+ extern "C" PyAPI_FUNC(Py_uhash_t) _Numba_hashtable_hash_ptr(const void *key);
78
+ extern "C" PyAPI_FUNC(Py_uhash_t) _Numba_hashtable_hash_int(const void *key);
79
+ extern "C" PyAPI_FUNC(int) _Numba_hashtable_compare_direct(const void *key, const _Numba_hashtable_entry_t *entry);
80
+
81
+ extern "C" PyAPI_FUNC(_Numba_hashtable_t *) _Numba_hashtable_new(
82
+ size_t data_size,
83
+ _Numba_hashtable_hash_func hash_func,
84
+ _Numba_hashtable_compare_func compare_func);
85
+ extern "C" PyAPI_FUNC(_Numba_hashtable_t *) _Numba_hashtable_new_full(
86
+ size_t data_size,
87
+ size_t init_size,
88
+ _Numba_hashtable_hash_func hash_func,
89
+ _Numba_hashtable_compare_func compare_func,
90
+ _Numba_hashtable_copy_data_func copy_data_func,
91
+ _Numba_hashtable_free_data_func free_data_func,
92
+ _Numba_hashtable_get_data_size_func get_data_size_func,
93
+ _Numba_hashtable_allocator_t *allocator);
94
+ extern "C" PyAPI_FUNC(_Numba_hashtable_t *) _Numba_hashtable_copy(_Numba_hashtable_t *src);
95
+ extern "C" PyAPI_FUNC(void) _Numba_hashtable_clear(_Numba_hashtable_t *ht);
96
+ extern "C" PyAPI_FUNC(void) _Numba_hashtable_destroy(_Numba_hashtable_t *ht);
97
+
98
+ typedef int (*_Numba_hashtable_foreach_func) (_Numba_hashtable_entry_t *entry, void *arg);
99
+
100
+ extern "C" PyAPI_FUNC(int) _Numba_hashtable_foreach(
101
+ _Numba_hashtable_t *ht,
102
+ _Numba_hashtable_foreach_func func, void *arg);
103
+ extern "C" PyAPI_FUNC(size_t) _Numba_hashtable_size(_Numba_hashtable_t *ht);
104
+
105
+ extern "C" PyAPI_FUNC(_Numba_hashtable_entry_t*) _Numba_hashtable_get_entry(
106
+ _Numba_hashtable_t *ht,
107
+ const void *key);
108
+ extern "C" PyAPI_FUNC(int) _Numba_hashtable_set(
109
+ _Numba_hashtable_t *ht,
110
+ const void *key,
111
+ void *data,
112
+ size_t data_size);
113
+ extern "C" PyAPI_FUNC(int) _Numba_hashtable_get(
114
+ _Numba_hashtable_t *ht,
115
+ const void *key,
116
+ void *data,
117
+ size_t data_size);
118
+ extern "C" PyAPI_FUNC(int) _Numba_hashtable_pop(
119
+ _Numba_hashtable_t *ht,
120
+ const void *key,
121
+ void *data,
122
+ size_t data_size);
123
+ extern "C" PyAPI_FUNC(void) _Numba_hashtable_delete(
124
+ _Numba_hashtable_t *ht,
125
+ const void *key);
126
+
127
+ #define _Numba_HASHTABLE_SET(TABLE, KEY, DATA) \
128
+ _Numba_hashtable_set(TABLE, KEY, &(DATA), sizeof(DATA))
129
+
130
+ #define _Numba_HASHTABLE_GET(TABLE, KEY, DATA) \
131
+ _Numba_hashtable_get(TABLE, KEY, &(DATA), sizeof(DATA))
132
+
133
+ #endif /* Py_LIMITED_API */
134
+
135
+ #endif