numba-cuda 0.22.0__cp313-cp313-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.
- _numba_cuda_redirector.pth +4 -0
- _numba_cuda_redirector.py +89 -0
- numba_cuda/VERSION +1 -0
- numba_cuda/__init__.py +6 -0
- numba_cuda/_version.py +11 -0
- numba_cuda/numba/cuda/__init__.py +70 -0
- numba_cuda/numba/cuda/_internal/cuda_bf16.py +16394 -0
- numba_cuda/numba/cuda/_internal/cuda_fp16.py +8112 -0
- numba_cuda/numba/cuda/api.py +580 -0
- numba_cuda/numba/cuda/api_util.py +76 -0
- numba_cuda/numba/cuda/args.py +72 -0
- numba_cuda/numba/cuda/bf16.py +397 -0
- numba_cuda/numba/cuda/cache_hints.py +287 -0
- numba_cuda/numba/cuda/cext/__init__.py +2 -0
- numba_cuda/numba/cuda/cext/_devicearray.cpp +159 -0
- numba_cuda/numba/cuda/cext/_devicearray.cpython-313-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/_devicearray.h +29 -0
- numba_cuda/numba/cuda/cext/_dispatcher.cpp +1098 -0
- numba_cuda/numba/cuda/cext/_dispatcher.cpython-313-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/_hashtable.cpp +532 -0
- numba_cuda/numba/cuda/cext/_hashtable.h +135 -0
- numba_cuda/numba/cuda/cext/_helperlib.c +71 -0
- numba_cuda/numba/cuda/cext/_helperlib.cpython-313-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/_helpermod.c +82 -0
- numba_cuda/numba/cuda/cext/_pymodule.h +38 -0
- numba_cuda/numba/cuda/cext/_typeconv.cpp +206 -0
- numba_cuda/numba/cuda/cext/_typeconv.cpython-313-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/_typeof.cpp +1159 -0
- numba_cuda/numba/cuda/cext/_typeof.h +19 -0
- numba_cuda/numba/cuda/cext/capsulethunk.h +111 -0
- numba_cuda/numba/cuda/cext/mviewbuf.c +385 -0
- numba_cuda/numba/cuda/cext/mviewbuf.cpython-313-aarch64-linux-gnu.so +0 -0
- numba_cuda/numba/cuda/cext/typeconv.cpp +212 -0
- numba_cuda/numba/cuda/cext/typeconv.hpp +101 -0
- numba_cuda/numba/cuda/cg.py +67 -0
- numba_cuda/numba/cuda/cgutils.py +1294 -0
- numba_cuda/numba/cuda/cloudpickle/__init__.py +21 -0
- numba_cuda/numba/cuda/cloudpickle/cloudpickle.py +1598 -0
- numba_cuda/numba/cuda/cloudpickle/cloudpickle_fast.py +17 -0
- numba_cuda/numba/cuda/codegen.py +541 -0
- numba_cuda/numba/cuda/compiler.py +1396 -0
- numba_cuda/numba/cuda/core/analysis.py +758 -0
- numba_cuda/numba/cuda/core/annotations/__init__.py +0 -0
- numba_cuda/numba/cuda/core/annotations/pretty_annotate.py +288 -0
- numba_cuda/numba/cuda/core/annotations/type_annotations.py +305 -0
- numba_cuda/numba/cuda/core/base.py +1332 -0
- numba_cuda/numba/cuda/core/boxing.py +1411 -0
- numba_cuda/numba/cuda/core/bytecode.py +728 -0
- numba_cuda/numba/cuda/core/byteflow.py +2346 -0
- numba_cuda/numba/cuda/core/caching.py +744 -0
- numba_cuda/numba/cuda/core/callconv.py +392 -0
- numba_cuda/numba/cuda/core/codegen.py +171 -0
- numba_cuda/numba/cuda/core/compiler.py +199 -0
- numba_cuda/numba/cuda/core/compiler_lock.py +85 -0
- numba_cuda/numba/cuda/core/compiler_machinery.py +497 -0
- numba_cuda/numba/cuda/core/config.py +650 -0
- numba_cuda/numba/cuda/core/consts.py +124 -0
- numba_cuda/numba/cuda/core/controlflow.py +989 -0
- numba_cuda/numba/cuda/core/entrypoints.py +57 -0
- numba_cuda/numba/cuda/core/environment.py +66 -0
- numba_cuda/numba/cuda/core/errors.py +917 -0
- numba_cuda/numba/cuda/core/event.py +511 -0
- numba_cuda/numba/cuda/core/funcdesc.py +330 -0
- numba_cuda/numba/cuda/core/generators.py +387 -0
- numba_cuda/numba/cuda/core/imputils.py +509 -0
- numba_cuda/numba/cuda/core/inline_closurecall.py +1787 -0
- numba_cuda/numba/cuda/core/interpreter.py +3617 -0
- numba_cuda/numba/cuda/core/ir.py +1812 -0
- numba_cuda/numba/cuda/core/ir_utils.py +2638 -0
- numba_cuda/numba/cuda/core/optional.py +129 -0
- numba_cuda/numba/cuda/core/options.py +262 -0
- numba_cuda/numba/cuda/core/postproc.py +249 -0
- numba_cuda/numba/cuda/core/pythonapi.py +1859 -0
- numba_cuda/numba/cuda/core/registry.py +46 -0
- numba_cuda/numba/cuda/core/removerefctpass.py +123 -0
- numba_cuda/numba/cuda/core/rewrites/__init__.py +26 -0
- numba_cuda/numba/cuda/core/rewrites/ir_print.py +91 -0
- numba_cuda/numba/cuda/core/rewrites/registry.py +104 -0
- numba_cuda/numba/cuda/core/rewrites/static_binop.py +41 -0
- numba_cuda/numba/cuda/core/rewrites/static_getitem.py +189 -0
- numba_cuda/numba/cuda/core/rewrites/static_raise.py +100 -0
- numba_cuda/numba/cuda/core/sigutils.py +68 -0
- numba_cuda/numba/cuda/core/ssa.py +498 -0
- numba_cuda/numba/cuda/core/targetconfig.py +330 -0
- numba_cuda/numba/cuda/core/tracing.py +231 -0
- numba_cuda/numba/cuda/core/transforms.py +956 -0
- numba_cuda/numba/cuda/core/typed_passes.py +867 -0
- numba_cuda/numba/cuda/core/typeinfer.py +1950 -0
- numba_cuda/numba/cuda/core/unsafe/__init__.py +0 -0
- numba_cuda/numba/cuda/core/unsafe/bytes.py +67 -0
- numba_cuda/numba/cuda/core/unsafe/eh.py +67 -0
- numba_cuda/numba/cuda/core/unsafe/refcount.py +98 -0
- numba_cuda/numba/cuda/core/untyped_passes.py +1979 -0
- numba_cuda/numba/cuda/cpython/builtins.py +1153 -0
- numba_cuda/numba/cuda/cpython/charseq.py +1218 -0
- numba_cuda/numba/cuda/cpython/cmathimpl.py +560 -0
- numba_cuda/numba/cuda/cpython/enumimpl.py +103 -0
- numba_cuda/numba/cuda/cpython/iterators.py +167 -0
- numba_cuda/numba/cuda/cpython/listobj.py +1326 -0
- numba_cuda/numba/cuda/cpython/mathimpl.py +499 -0
- numba_cuda/numba/cuda/cpython/numbers.py +1475 -0
- numba_cuda/numba/cuda/cpython/rangeobj.py +289 -0
- numba_cuda/numba/cuda/cpython/slicing.py +322 -0
- numba_cuda/numba/cuda/cpython/tupleobj.py +456 -0
- numba_cuda/numba/cuda/cpython/unicode.py +2865 -0
- numba_cuda/numba/cuda/cpython/unicode_support.py +1597 -0
- numba_cuda/numba/cuda/cpython/unsafe/__init__.py +0 -0
- numba_cuda/numba/cuda/cpython/unsafe/numbers.py +64 -0
- numba_cuda/numba/cuda/cpython/unsafe/tuple.py +92 -0
- numba_cuda/numba/cuda/cuda_paths.py +691 -0
- numba_cuda/numba/cuda/cudadecl.py +543 -0
- numba_cuda/numba/cuda/cudadrv/__init__.py +14 -0
- numba_cuda/numba/cuda/cudadrv/devicearray.py +954 -0
- numba_cuda/numba/cuda/cudadrv/devices.py +249 -0
- numba_cuda/numba/cuda/cudadrv/driver.py +3238 -0
- numba_cuda/numba/cuda/cudadrv/drvapi.py +435 -0
- numba_cuda/numba/cuda/cudadrv/dummyarray.py +562 -0
- numba_cuda/numba/cuda/cudadrv/enums.py +613 -0
- numba_cuda/numba/cuda/cudadrv/error.py +48 -0
- numba_cuda/numba/cuda/cudadrv/libs.py +220 -0
- numba_cuda/numba/cuda/cudadrv/linkable_code.py +184 -0
- numba_cuda/numba/cuda/cudadrv/mappings.py +14 -0
- numba_cuda/numba/cuda/cudadrv/ndarray.py +26 -0
- numba_cuda/numba/cuda/cudadrv/nvrtc.py +193 -0
- numba_cuda/numba/cuda/cudadrv/nvvm.py +756 -0
- numba_cuda/numba/cuda/cudadrv/rtapi.py +13 -0
- numba_cuda/numba/cuda/cudadrv/runtime.py +34 -0
- numba_cuda/numba/cuda/cudaimpl.py +983 -0
- numba_cuda/numba/cuda/cudamath.py +149 -0
- numba_cuda/numba/cuda/datamodel/__init__.py +7 -0
- numba_cuda/numba/cuda/datamodel/cuda_manager.py +66 -0
- numba_cuda/numba/cuda/datamodel/cuda_models.py +1446 -0
- numba_cuda/numba/cuda/datamodel/cuda_packer.py +224 -0
- numba_cuda/numba/cuda/datamodel/cuda_registry.py +22 -0
- numba_cuda/numba/cuda/datamodel/cuda_testing.py +153 -0
- numba_cuda/numba/cuda/datamodel/manager.py +11 -0
- numba_cuda/numba/cuda/datamodel/models.py +9 -0
- numba_cuda/numba/cuda/datamodel/packer.py +9 -0
- numba_cuda/numba/cuda/datamodel/registry.py +11 -0
- numba_cuda/numba/cuda/datamodel/testing.py +11 -0
- numba_cuda/numba/cuda/debuginfo.py +997 -0
- numba_cuda/numba/cuda/decorators.py +294 -0
- numba_cuda/numba/cuda/descriptor.py +35 -0
- numba_cuda/numba/cuda/device_init.py +155 -0
- numba_cuda/numba/cuda/deviceufunc.py +1021 -0
- numba_cuda/numba/cuda/dispatcher.py +2463 -0
- numba_cuda/numba/cuda/errors.py +72 -0
- numba_cuda/numba/cuda/extending.py +697 -0
- numba_cuda/numba/cuda/flags.py +178 -0
- numba_cuda/numba/cuda/fp16.py +357 -0
- numba_cuda/numba/cuda/include/12/cuda_bf16.h +5118 -0
- numba_cuda/numba/cuda/include/12/cuda_bf16.hpp +3865 -0
- numba_cuda/numba/cuda/include/12/cuda_fp16.h +5363 -0
- numba_cuda/numba/cuda/include/12/cuda_fp16.hpp +3483 -0
- numba_cuda/numba/cuda/include/13/cuda_bf16.h +5118 -0
- numba_cuda/numba/cuda/include/13/cuda_bf16.hpp +3865 -0
- numba_cuda/numba/cuda/include/13/cuda_fp16.h +5363 -0
- numba_cuda/numba/cuda/include/13/cuda_fp16.hpp +3483 -0
- numba_cuda/numba/cuda/initialize.py +24 -0
- numba_cuda/numba/cuda/intrinsics.py +531 -0
- numba_cuda/numba/cuda/itanium_mangler.py +214 -0
- numba_cuda/numba/cuda/kernels/__init__.py +2 -0
- numba_cuda/numba/cuda/kernels/reduction.py +265 -0
- numba_cuda/numba/cuda/kernels/transpose.py +65 -0
- numba_cuda/numba/cuda/libdevice.py +3386 -0
- numba_cuda/numba/cuda/libdevicedecl.py +20 -0
- numba_cuda/numba/cuda/libdevicefuncs.py +1060 -0
- numba_cuda/numba/cuda/libdeviceimpl.py +88 -0
- numba_cuda/numba/cuda/locks.py +19 -0
- numba_cuda/numba/cuda/lowering.py +1980 -0
- numba_cuda/numba/cuda/mathimpl.py +374 -0
- numba_cuda/numba/cuda/memory_management/__init__.py +4 -0
- numba_cuda/numba/cuda/memory_management/memsys.cu +99 -0
- numba_cuda/numba/cuda/memory_management/memsys.cuh +22 -0
- numba_cuda/numba/cuda/memory_management/nrt.cu +212 -0
- numba_cuda/numba/cuda/memory_management/nrt.cuh +48 -0
- numba_cuda/numba/cuda/memory_management/nrt.py +390 -0
- numba_cuda/numba/cuda/memory_management/nrt_context.py +438 -0
- numba_cuda/numba/cuda/misc/appdirs.py +594 -0
- numba_cuda/numba/cuda/misc/cffiimpl.py +24 -0
- numba_cuda/numba/cuda/misc/coverage_support.py +43 -0
- numba_cuda/numba/cuda/misc/dump_style.py +41 -0
- numba_cuda/numba/cuda/misc/findlib.py +75 -0
- numba_cuda/numba/cuda/misc/firstlinefinder.py +96 -0
- numba_cuda/numba/cuda/misc/gdb_hook.py +240 -0
- numba_cuda/numba/cuda/misc/literal.py +28 -0
- numba_cuda/numba/cuda/misc/llvm_pass_timings.py +412 -0
- numba_cuda/numba/cuda/misc/special.py +94 -0
- numba_cuda/numba/cuda/models.py +56 -0
- numba_cuda/numba/cuda/np/arraymath.py +5130 -0
- numba_cuda/numba/cuda/np/arrayobj.py +7635 -0
- numba_cuda/numba/cuda/np/extensions.py +11 -0
- numba_cuda/numba/cuda/np/linalg.py +3087 -0
- numba_cuda/numba/cuda/np/math/__init__.py +0 -0
- numba_cuda/numba/cuda/np/math/cmathimpl.py +558 -0
- numba_cuda/numba/cuda/np/math/mathimpl.py +487 -0
- numba_cuda/numba/cuda/np/math/numbers.py +1461 -0
- numba_cuda/numba/cuda/np/npdatetime.py +969 -0
- numba_cuda/numba/cuda/np/npdatetime_helpers.py +217 -0
- numba_cuda/numba/cuda/np/npyfuncs.py +1808 -0
- numba_cuda/numba/cuda/np/npyimpl.py +1027 -0
- numba_cuda/numba/cuda/np/numpy_support.py +798 -0
- numba_cuda/numba/cuda/np/polynomial/__init__.py +4 -0
- numba_cuda/numba/cuda/np/polynomial/polynomial_core.py +242 -0
- numba_cuda/numba/cuda/np/polynomial/polynomial_functions.py +380 -0
- numba_cuda/numba/cuda/np/ufunc/__init__.py +4 -0
- numba_cuda/numba/cuda/np/ufunc/decorators.py +203 -0
- numba_cuda/numba/cuda/np/ufunc/sigparse.py +68 -0
- numba_cuda/numba/cuda/np/ufunc/ufuncbuilder.py +65 -0
- numba_cuda/numba/cuda/np/ufunc_db.py +1282 -0
- numba_cuda/numba/cuda/np/unsafe/__init__.py +0 -0
- numba_cuda/numba/cuda/np/unsafe/ndarray.py +84 -0
- numba_cuda/numba/cuda/nvvmutils.py +254 -0
- numba_cuda/numba/cuda/printimpl.py +126 -0
- numba_cuda/numba/cuda/random.py +308 -0
- numba_cuda/numba/cuda/reshape_funcs.cu +156 -0
- numba_cuda/numba/cuda/serialize.py +267 -0
- numba_cuda/numba/cuda/simulator/__init__.py +63 -0
- numba_cuda/numba/cuda/simulator/_internal/__init__.py +4 -0
- numba_cuda/numba/cuda/simulator/_internal/cuda_bf16.py +2 -0
- numba_cuda/numba/cuda/simulator/api.py +179 -0
- numba_cuda/numba/cuda/simulator/bf16.py +4 -0
- numba_cuda/numba/cuda/simulator/compiler.py +38 -0
- numba_cuda/numba/cuda/simulator/cudadrv/__init__.py +11 -0
- numba_cuda/numba/cuda/simulator/cudadrv/devicearray.py +462 -0
- numba_cuda/numba/cuda/simulator/cudadrv/devices.py +122 -0
- numba_cuda/numba/cuda/simulator/cudadrv/driver.py +66 -0
- numba_cuda/numba/cuda/simulator/cudadrv/drvapi.py +7 -0
- numba_cuda/numba/cuda/simulator/cudadrv/dummyarray.py +7 -0
- numba_cuda/numba/cuda/simulator/cudadrv/error.py +10 -0
- numba_cuda/numba/cuda/simulator/cudadrv/libs.py +10 -0
- numba_cuda/numba/cuda/simulator/cudadrv/linkable_code.py +61 -0
- numba_cuda/numba/cuda/simulator/cudadrv/nvrtc.py +11 -0
- numba_cuda/numba/cuda/simulator/cudadrv/nvvm.py +32 -0
- numba_cuda/numba/cuda/simulator/cudadrv/runtime.py +22 -0
- numba_cuda/numba/cuda/simulator/dispatcher.py +11 -0
- numba_cuda/numba/cuda/simulator/kernel.py +320 -0
- numba_cuda/numba/cuda/simulator/kernelapi.py +509 -0
- numba_cuda/numba/cuda/simulator/memory_management/__init__.py +4 -0
- numba_cuda/numba/cuda/simulator/memory_management/nrt.py +21 -0
- numba_cuda/numba/cuda/simulator/reduction.py +19 -0
- numba_cuda/numba/cuda/simulator/tests/support.py +4 -0
- numba_cuda/numba/cuda/simulator/vector_types.py +65 -0
- numba_cuda/numba/cuda/simulator_init.py +18 -0
- numba_cuda/numba/cuda/stubs.py +624 -0
- numba_cuda/numba/cuda/target.py +505 -0
- numba_cuda/numba/cuda/testing.py +347 -0
- numba_cuda/numba/cuda/tests/__init__.py +62 -0
- numba_cuda/numba/cuda/tests/benchmarks/__init__.py +0 -0
- numba_cuda/numba/cuda/tests/benchmarks/test_kernel_launch.py +119 -0
- numba_cuda/numba/cuda/tests/cloudpickle_main_class.py +9 -0
- numba_cuda/numba/cuda/tests/core/serialize_usecases.py +113 -0
- numba_cuda/numba/cuda/tests/core/test_itanium_mangler.py +83 -0
- numba_cuda/numba/cuda/tests/core/test_serialize.py +371 -0
- numba_cuda/numba/cuda/tests/cudadrv/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_array_attr.py +147 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_context_stack.py +161 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_array_slicing.py +397 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_auto_context.py +24 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_devicerecord.py +180 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_driver.py +313 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_memory.py +191 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_cuda_ndarray.py +621 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_deallocations.py +247 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_detect.py +100 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +200 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_events.py +53 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_host_alloc.py +72 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_init.py +138 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_inline_ptx.py +43 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_is_fp16.py +15 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_linkable_code.py +58 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +348 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_managed_alloc.py +128 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_module_callbacks.py +301 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py +174 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_nvrtc.py +28 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_nvvm_driver.py +185 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_pinned.py +39 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_profiler.py +23 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_reset_device.py +38 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_runtime.py +48 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_select_device.py +44 -0
- numba_cuda/numba/cuda/tests/cudadrv/test_streams.py +127 -0
- numba_cuda/numba/cuda/tests/cudapy/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/cudapy/cache_usecases.py +231 -0
- numba_cuda/numba/cuda/tests/cudapy/cache_with_cpu_usecases.py +50 -0
- numba_cuda/numba/cuda/tests/cudapy/cg_cache_usecases.py +36 -0
- numba_cuda/numba/cuda/tests/cudapy/complex_usecases.py +116 -0
- numba_cuda/numba/cuda/tests/cudapy/enum_usecases.py +59 -0
- numba_cuda/numba/cuda/tests/cudapy/extensions_usecases.py +62 -0
- numba_cuda/numba/cuda/tests/cudapy/jitlink.ptx +28 -0
- numba_cuda/numba/cuda/tests/cudapy/overload_usecases.py +33 -0
- numba_cuda/numba/cuda/tests/cudapy/recursion_usecases.py +104 -0
- numba_cuda/numba/cuda/tests/cudapy/test_alignment.py +47 -0
- numba_cuda/numba/cuda/tests/cudapy/test_analysis.py +1122 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array.py +344 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_alignment.py +268 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_args.py +203 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_methods.py +63 -0
- numba_cuda/numba/cuda/tests/cudapy/test_array_reductions.py +360 -0
- numba_cuda/numba/cuda/tests/cudapy/test_atomics.py +1815 -0
- numba_cuda/numba/cuda/tests/cudapy/test_bfloat16.py +599 -0
- numba_cuda/numba/cuda/tests/cudapy/test_bfloat16_bindings.py +377 -0
- numba_cuda/numba/cuda/tests/cudapy/test_blackscholes.py +160 -0
- numba_cuda/numba/cuda/tests/cudapy/test_boolean.py +27 -0
- numba_cuda/numba/cuda/tests/cudapy/test_byteflow.py +98 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cache_hints.py +210 -0
- numba_cuda/numba/cuda/tests/cudapy/test_caching.py +683 -0
- numba_cuda/numba/cuda/tests/cudapy/test_casting.py +265 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cffi.py +42 -0
- numba_cuda/numba/cuda/tests/cudapy/test_compiler.py +718 -0
- numba_cuda/numba/cuda/tests/cudapy/test_complex.py +370 -0
- numba_cuda/numba/cuda/tests/cudapy/test_complex_kernel.py +23 -0
- numba_cuda/numba/cuda/tests/cudapy/test_const_string.py +142 -0
- numba_cuda/numba/cuda/tests/cudapy/test_constmem.py +178 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cooperative_groups.py +193 -0
- numba_cuda/numba/cuda/tests/cudapy/test_copy_propagate.py +131 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cuda_array_interface.py +438 -0
- numba_cuda/numba/cuda/tests/cudapy/test_cuda_jit_no_types.py +94 -0
- numba_cuda/numba/cuda/tests/cudapy/test_datetime.py +101 -0
- numba_cuda/numba/cuda/tests/cudapy/test_debug.py +105 -0
- numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +978 -0
- numba_cuda/numba/cuda/tests/cudapy/test_debuginfo_types.py +476 -0
- numba_cuda/numba/cuda/tests/cudapy/test_device_func.py +500 -0
- numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +820 -0
- numba_cuda/numba/cuda/tests/cudapy/test_enums.py +152 -0
- numba_cuda/numba/cuda/tests/cudapy/test_errors.py +111 -0
- numba_cuda/numba/cuda/tests/cudapy/test_exception.py +170 -0
- numba_cuda/numba/cuda/tests/cudapy/test_extending.py +1088 -0
- numba_cuda/numba/cuda/tests/cudapy/test_extending_types.py +71 -0
- numba_cuda/numba/cuda/tests/cudapy/test_fastmath.py +265 -0
- numba_cuda/numba/cuda/tests/cudapy/test_flow_control.py +1433 -0
- numba_cuda/numba/cuda/tests/cudapy/test_forall.py +57 -0
- numba_cuda/numba/cuda/tests/cudapy/test_freevar.py +34 -0
- numba_cuda/numba/cuda/tests/cudapy/test_frexp_ldexp.py +69 -0
- numba_cuda/numba/cuda/tests/cudapy/test_globals.py +62 -0
- numba_cuda/numba/cuda/tests/cudapy/test_gufunc.py +474 -0
- numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scalar.py +167 -0
- numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scheduling.py +92 -0
- numba_cuda/numba/cuda/tests/cudapy/test_idiv.py +39 -0
- numba_cuda/numba/cuda/tests/cudapy/test_inline.py +170 -0
- numba_cuda/numba/cuda/tests/cudapy/test_inspect.py +255 -0
- numba_cuda/numba/cuda/tests/cudapy/test_intrinsics.py +1219 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ipc.py +263 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ir.py +598 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ir_utils.py +276 -0
- numba_cuda/numba/cuda/tests/cudapy/test_iterators.py +101 -0
- numba_cuda/numba/cuda/tests/cudapy/test_lang.py +68 -0
- numba_cuda/numba/cuda/tests/cudapy/test_laplace.py +123 -0
- numba_cuda/numba/cuda/tests/cudapy/test_libdevice.py +194 -0
- numba_cuda/numba/cuda/tests/cudapy/test_lineinfo.py +220 -0
- numba_cuda/numba/cuda/tests/cudapy/test_localmem.py +173 -0
- numba_cuda/numba/cuda/tests/cudapy/test_make_function_to_jit_function.py +364 -0
- numba_cuda/numba/cuda/tests/cudapy/test_mandel.py +47 -0
- numba_cuda/numba/cuda/tests/cudapy/test_math.py +842 -0
- numba_cuda/numba/cuda/tests/cudapy/test_matmul.py +76 -0
- numba_cuda/numba/cuda/tests/cudapy/test_minmax.py +78 -0
- numba_cuda/numba/cuda/tests/cudapy/test_montecarlo.py +25 -0
- numba_cuda/numba/cuda/tests/cudapy/test_multigpu.py +145 -0
- numba_cuda/numba/cuda/tests/cudapy/test_multiprocessing.py +39 -0
- numba_cuda/numba/cuda/tests/cudapy/test_multithreads.py +82 -0
- numba_cuda/numba/cuda/tests/cudapy/test_nondet.py +53 -0
- numba_cuda/numba/cuda/tests/cudapy/test_operator.py +504 -0
- numba_cuda/numba/cuda/tests/cudapy/test_optimization.py +93 -0
- numba_cuda/numba/cuda/tests/cudapy/test_overload.py +402 -0
- numba_cuda/numba/cuda/tests/cudapy/test_powi.py +128 -0
- numba_cuda/numba/cuda/tests/cudapy/test_print.py +193 -0
- numba_cuda/numba/cuda/tests/cudapy/test_py2_div_issue.py +37 -0
- numba_cuda/numba/cuda/tests/cudapy/test_random.py +117 -0
- numba_cuda/numba/cuda/tests/cudapy/test_record_dtype.py +614 -0
- numba_cuda/numba/cuda/tests/cudapy/test_recursion.py +130 -0
- numba_cuda/numba/cuda/tests/cudapy/test_reduction.py +94 -0
- numba_cuda/numba/cuda/tests/cudapy/test_retrieve_autoconverted_arrays.py +83 -0
- numba_cuda/numba/cuda/tests/cudapy/test_serialize.py +86 -0
- numba_cuda/numba/cuda/tests/cudapy/test_slicing.py +40 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sm.py +457 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sm_creation.py +233 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ssa.py +454 -0
- numba_cuda/numba/cuda/tests/cudapy/test_stream_api.py +56 -0
- numba_cuda/numba/cuda/tests/cudapy/test_sync.py +277 -0
- numba_cuda/numba/cuda/tests/cudapy/test_tracing.py +200 -0
- numba_cuda/numba/cuda/tests/cudapy/test_transpose.py +90 -0
- numba_cuda/numba/cuda/tests/cudapy/test_typeconv.py +333 -0
- numba_cuda/numba/cuda/tests/cudapy/test_typeinfer.py +538 -0
- numba_cuda/numba/cuda/tests/cudapy/test_ufuncs.py +585 -0
- numba_cuda/numba/cuda/tests/cudapy/test_userexc.py +42 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vector_type.py +485 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize.py +312 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_complex.py +23 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_decor.py +183 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_device.py +40 -0
- numba_cuda/numba/cuda/tests/cudapy/test_vectorize_scalar_arg.py +40 -0
- numba_cuda/numba/cuda/tests/cudapy/test_warning.py +206 -0
- numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +446 -0
- numba_cuda/numba/cuda/tests/cudasim/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/cudasim/support.py +9 -0
- numba_cuda/numba/cuda/tests/cudasim/test_cudasim_issues.py +111 -0
- numba_cuda/numba/cuda/tests/data/__init__.py +2 -0
- numba_cuda/numba/cuda/tests/data/cta_barrier.cu +28 -0
- numba_cuda/numba/cuda/tests/data/cuda_include.cu +10 -0
- numba_cuda/numba/cuda/tests/data/error.cu +12 -0
- numba_cuda/numba/cuda/tests/data/include/add.cuh +8 -0
- numba_cuda/numba/cuda/tests/data/jitlink.cu +28 -0
- numba_cuda/numba/cuda/tests/data/jitlink.ptx +49 -0
- numba_cuda/numba/cuda/tests/data/warn.cu +12 -0
- numba_cuda/numba/cuda/tests/doc_examples/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/__init__.py +2 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/functions.cu +54 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/include/mul.cuh +8 -0
- numba_cuda/numba/cuda/tests/doc_examples/ffi/saxpy.cu +14 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_cg.py +86 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_cpointer.py +68 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_cpu_gpu_compat.py +81 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_ffi.py +141 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_laplace.py +160 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_matmul.py +180 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_montecarlo.py +119 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_random.py +66 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_reduction.py +80 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_sessionize.py +206 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_ufunc.py +53 -0
- numba_cuda/numba/cuda/tests/doc_examples/test_vecadd.py +76 -0
- numba_cuda/numba/cuda/tests/nocuda/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/nocuda/test_dummyarray.py +452 -0
- numba_cuda/numba/cuda/tests/nocuda/test_function_resolution.py +48 -0
- numba_cuda/numba/cuda/tests/nocuda/test_import.py +63 -0
- numba_cuda/numba/cuda/tests/nocuda/test_library_lookup.py +252 -0
- numba_cuda/numba/cuda/tests/nocuda/test_nvvm.py +59 -0
- numba_cuda/numba/cuda/tests/nrt/__init__.py +9 -0
- numba_cuda/numba/cuda/tests/nrt/test_nrt.py +387 -0
- numba_cuda/numba/cuda/tests/nrt/test_nrt_refct.py +124 -0
- numba_cuda/numba/cuda/tests/support.py +900 -0
- numba_cuda/numba/cuda/typeconv/__init__.py +4 -0
- numba_cuda/numba/cuda/typeconv/castgraph.py +137 -0
- numba_cuda/numba/cuda/typeconv/rules.py +63 -0
- numba_cuda/numba/cuda/typeconv/typeconv.py +121 -0
- numba_cuda/numba/cuda/types/__init__.py +233 -0
- numba_cuda/numba/cuda/types/__init__.pyi +167 -0
- numba_cuda/numba/cuda/types/abstract.py +9 -0
- numba_cuda/numba/cuda/types/common.py +9 -0
- numba_cuda/numba/cuda/types/containers.py +9 -0
- numba_cuda/numba/cuda/types/cuda_abstract.py +533 -0
- numba_cuda/numba/cuda/types/cuda_common.py +110 -0
- numba_cuda/numba/cuda/types/cuda_containers.py +971 -0
- numba_cuda/numba/cuda/types/cuda_function_type.py +230 -0
- numba_cuda/numba/cuda/types/cuda_functions.py +798 -0
- numba_cuda/numba/cuda/types/cuda_iterators.py +120 -0
- numba_cuda/numba/cuda/types/cuda_misc.py +569 -0
- numba_cuda/numba/cuda/types/cuda_npytypes.py +690 -0
- numba_cuda/numba/cuda/types/cuda_scalars.py +280 -0
- numba_cuda/numba/cuda/types/ext_types.py +101 -0
- numba_cuda/numba/cuda/types/function_type.py +11 -0
- numba_cuda/numba/cuda/types/functions.py +9 -0
- numba_cuda/numba/cuda/types/iterators.py +9 -0
- numba_cuda/numba/cuda/types/misc.py +9 -0
- numba_cuda/numba/cuda/types/npytypes.py +9 -0
- numba_cuda/numba/cuda/types/scalars.py +9 -0
- numba_cuda/numba/cuda/typing/__init__.py +19 -0
- numba_cuda/numba/cuda/typing/arraydecl.py +939 -0
- numba_cuda/numba/cuda/typing/asnumbatype.py +130 -0
- numba_cuda/numba/cuda/typing/bufproto.py +70 -0
- numba_cuda/numba/cuda/typing/builtins.py +1209 -0
- numba_cuda/numba/cuda/typing/cffi_utils.py +219 -0
- numba_cuda/numba/cuda/typing/cmathdecl.py +47 -0
- numba_cuda/numba/cuda/typing/collections.py +138 -0
- numba_cuda/numba/cuda/typing/context.py +782 -0
- numba_cuda/numba/cuda/typing/ctypes_utils.py +125 -0
- numba_cuda/numba/cuda/typing/dictdecl.py +63 -0
- numba_cuda/numba/cuda/typing/enumdecl.py +74 -0
- numba_cuda/numba/cuda/typing/listdecl.py +147 -0
- numba_cuda/numba/cuda/typing/mathdecl.py +158 -0
- numba_cuda/numba/cuda/typing/npdatetime.py +322 -0
- numba_cuda/numba/cuda/typing/npydecl.py +749 -0
- numba_cuda/numba/cuda/typing/setdecl.py +115 -0
- numba_cuda/numba/cuda/typing/templates.py +1446 -0
- numba_cuda/numba/cuda/typing/typeof.py +301 -0
- numba_cuda/numba/cuda/ufuncs.py +746 -0
- numba_cuda/numba/cuda/utils.py +724 -0
- numba_cuda/numba/cuda/vector_types.py +214 -0
- numba_cuda/numba/cuda/vectorizers.py +260 -0
- numba_cuda-0.22.0.dist-info/METADATA +109 -0
- numba_cuda-0.22.0.dist-info/RECORD +487 -0
- numba_cuda-0.22.0.dist-info/WHEEL +6 -0
- numba_cuda-0.22.0.dist-info/licenses/LICENSE +26 -0
- numba_cuda-0.22.0.dist-info/licenses/LICENSE.numba +24 -0
- numba_cuda-0.22.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Utilities to simplify the boilerplate for native lowering.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import collections
|
|
9
|
+
import contextlib
|
|
10
|
+
from enum import Enum
|
|
11
|
+
|
|
12
|
+
from numba.cuda import typing, cgutils
|
|
13
|
+
from numba.cuda import types
|
|
14
|
+
from numba.cuda.typing.templates import BaseRegistryLoader
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Registry(object):
|
|
18
|
+
"""
|
|
19
|
+
A registry of function and attribute implementations.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, name="unspecified"):
|
|
23
|
+
self.name = name
|
|
24
|
+
self.functions = []
|
|
25
|
+
self.getattrs = []
|
|
26
|
+
self.setattrs = []
|
|
27
|
+
self.casts = []
|
|
28
|
+
self.constants = []
|
|
29
|
+
|
|
30
|
+
def lower(self, func, *argtys):
|
|
31
|
+
"""
|
|
32
|
+
Decorate an implementation of *func* for the given argument types.
|
|
33
|
+
*func* may be an actual global function object, or any
|
|
34
|
+
pseudo-function supported by Numba, such as "getitem".
|
|
35
|
+
|
|
36
|
+
The decorated implementation has the signature
|
|
37
|
+
(context, builder, sig, args).
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def decorate(impl):
|
|
41
|
+
self.functions.append((impl, func, argtys))
|
|
42
|
+
return impl
|
|
43
|
+
|
|
44
|
+
return decorate
|
|
45
|
+
|
|
46
|
+
def _decorate_attr(self, impl, ty, attr, impl_list, decorator):
|
|
47
|
+
real_impl = decorator(impl, ty, attr)
|
|
48
|
+
impl_list.append((real_impl, attr, real_impl.signature))
|
|
49
|
+
return impl
|
|
50
|
+
|
|
51
|
+
def lower_getattr(self, ty, attr):
|
|
52
|
+
"""
|
|
53
|
+
Decorate an implementation of __getattr__ for type *ty* and
|
|
54
|
+
the attribute *attr*.
|
|
55
|
+
|
|
56
|
+
The decorated implementation will have the signature
|
|
57
|
+
(context, builder, typ, val).
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
def decorate(impl):
|
|
61
|
+
return self._decorate_attr(
|
|
62
|
+
impl, ty, attr, self.getattrs, _decorate_getattr
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
return decorate
|
|
66
|
+
|
|
67
|
+
def lower_getattr_generic(self, ty):
|
|
68
|
+
"""
|
|
69
|
+
Decorate the fallback implementation of __getattr__ for type *ty*.
|
|
70
|
+
|
|
71
|
+
The decorated implementation will have the signature
|
|
72
|
+
(context, builder, typ, val, attr). The implementation is
|
|
73
|
+
called for attributes which haven't been explicitly registered
|
|
74
|
+
with lower_getattr().
|
|
75
|
+
"""
|
|
76
|
+
return self.lower_getattr(ty, None)
|
|
77
|
+
|
|
78
|
+
def lower_setattr(self, ty, attr):
|
|
79
|
+
"""
|
|
80
|
+
Decorate an implementation of __setattr__ for type *ty* and
|
|
81
|
+
the attribute *attr*.
|
|
82
|
+
|
|
83
|
+
The decorated implementation will have the signature
|
|
84
|
+
(context, builder, sig, args).
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
def decorate(impl):
|
|
88
|
+
return self._decorate_attr(
|
|
89
|
+
impl, ty, attr, self.setattrs, _decorate_setattr
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
return decorate
|
|
93
|
+
|
|
94
|
+
def lower_setattr_generic(self, ty):
|
|
95
|
+
"""
|
|
96
|
+
Decorate the fallback implementation of __setattr__ for type *ty*.
|
|
97
|
+
|
|
98
|
+
The decorated implementation will have the signature
|
|
99
|
+
(context, builder, sig, args, attr). The implementation is
|
|
100
|
+
called for attributes which haven't been explicitly registered
|
|
101
|
+
with lower_setattr().
|
|
102
|
+
"""
|
|
103
|
+
return self.lower_setattr(ty, None)
|
|
104
|
+
|
|
105
|
+
def lower_cast(self, fromty, toty):
|
|
106
|
+
"""
|
|
107
|
+
Decorate the implementation of implicit conversion between
|
|
108
|
+
*fromty* and *toty*.
|
|
109
|
+
|
|
110
|
+
The decorated implementation will have the signature
|
|
111
|
+
(context, builder, fromty, toty, val).
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
def decorate(impl):
|
|
115
|
+
self.casts.append((impl, (fromty, toty)))
|
|
116
|
+
return impl
|
|
117
|
+
|
|
118
|
+
return decorate
|
|
119
|
+
|
|
120
|
+
def lower_constant(self, ty):
|
|
121
|
+
"""
|
|
122
|
+
Decorate the implementation for creating a constant of type *ty*.
|
|
123
|
+
|
|
124
|
+
The decorated implementation will have the signature
|
|
125
|
+
(context, builder, ty, pyval).
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
def decorate(impl):
|
|
129
|
+
self.constants.append((impl, (ty,)))
|
|
130
|
+
return impl
|
|
131
|
+
|
|
132
|
+
return decorate
|
|
133
|
+
|
|
134
|
+
def __repr__(self):
|
|
135
|
+
return f"Lowering Registry<{self.name}>"
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class RegistryLoader(BaseRegistryLoader):
|
|
139
|
+
"""
|
|
140
|
+
An incremental loader for a target registry.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
registry_items = ("functions", "getattrs", "setattrs", "casts", "constants")
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# Global registry for implementations of builtin operations
|
|
147
|
+
# (functions, attributes, type casts)
|
|
148
|
+
builtin_registry = Registry("builtin_registry")
|
|
149
|
+
|
|
150
|
+
lower_builtin = builtin_registry.lower
|
|
151
|
+
lower_getattr = builtin_registry.lower_getattr
|
|
152
|
+
lower_getattr_generic = builtin_registry.lower_getattr_generic
|
|
153
|
+
lower_setattr = builtin_registry.lower_setattr
|
|
154
|
+
lower_setattr_generic = builtin_registry.lower_setattr_generic
|
|
155
|
+
lower_cast = builtin_registry.lower_cast
|
|
156
|
+
lower_constant = builtin_registry.lower_constant
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _decorate_getattr(impl, ty, attr):
|
|
160
|
+
real_impl = impl
|
|
161
|
+
|
|
162
|
+
if attr is not None:
|
|
163
|
+
|
|
164
|
+
def res(context, builder, typ, value, attr):
|
|
165
|
+
return real_impl(context, builder, typ, value)
|
|
166
|
+
else:
|
|
167
|
+
|
|
168
|
+
def res(context, builder, typ, value, attr):
|
|
169
|
+
return real_impl(context, builder, typ, value, attr)
|
|
170
|
+
|
|
171
|
+
res.signature = (ty,)
|
|
172
|
+
res.attr = attr
|
|
173
|
+
return res
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _decorate_setattr(impl, ty, attr):
|
|
177
|
+
real_impl = impl
|
|
178
|
+
|
|
179
|
+
if attr is not None:
|
|
180
|
+
|
|
181
|
+
def res(context, builder, sig, args, attr):
|
|
182
|
+
return real_impl(context, builder, sig, args)
|
|
183
|
+
else:
|
|
184
|
+
|
|
185
|
+
def res(context, builder, sig, args, attr):
|
|
186
|
+
return real_impl(context, builder, sig, args, attr)
|
|
187
|
+
|
|
188
|
+
res.signature = (ty, types.Any)
|
|
189
|
+
res.attr = attr
|
|
190
|
+
return res
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def fix_returning_optional(context, builder, sig, status, retval):
|
|
194
|
+
# Reconstruct optional return type
|
|
195
|
+
if isinstance(sig.return_type, types.Optional):
|
|
196
|
+
value_type = sig.return_type.type
|
|
197
|
+
optional_none = context.make_optional_none(builder, value_type)
|
|
198
|
+
retvalptr = cgutils.alloca_once_value(builder, optional_none)
|
|
199
|
+
with builder.if_then(builder.not_(status.is_none)):
|
|
200
|
+
optional_value = context.make_optional_value(
|
|
201
|
+
builder,
|
|
202
|
+
value_type,
|
|
203
|
+
retval,
|
|
204
|
+
)
|
|
205
|
+
builder.store(optional_value, retvalptr)
|
|
206
|
+
retval = builder.load(retvalptr)
|
|
207
|
+
return retval
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def user_function(fndesc, libs):
|
|
211
|
+
"""
|
|
212
|
+
A wrapper inserting code calling Numba-compiled *fndesc*.
|
|
213
|
+
"""
|
|
214
|
+
|
|
215
|
+
def imp(context, builder, sig, args):
|
|
216
|
+
func = context.declare_function(builder.module, fndesc)
|
|
217
|
+
# env=None assumes this is a nopython function
|
|
218
|
+
status, retval = context.call_conv.call_function(
|
|
219
|
+
builder, func, fndesc.restype, fndesc.argtypes, args
|
|
220
|
+
)
|
|
221
|
+
with cgutils.if_unlikely(builder, status.is_error):
|
|
222
|
+
context.call_conv.return_status_propagate(builder, status)
|
|
223
|
+
assert sig.return_type == fndesc.restype
|
|
224
|
+
# Reconstruct optional return type
|
|
225
|
+
retval = fix_returning_optional(context, builder, sig, status, retval)
|
|
226
|
+
# If the data representations don't match up
|
|
227
|
+
if retval.type != context.get_value_type(sig.return_type):
|
|
228
|
+
msg = "function returned {0} but expect {1}"
|
|
229
|
+
raise TypeError(msg.format(retval.type, sig.return_type))
|
|
230
|
+
|
|
231
|
+
return impl_ret_new_ref(context, builder, fndesc.restype, retval)
|
|
232
|
+
|
|
233
|
+
imp.signature = fndesc.argtypes
|
|
234
|
+
imp.libs = tuple(libs)
|
|
235
|
+
return imp
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def user_generator(gendesc, libs):
|
|
239
|
+
"""
|
|
240
|
+
A wrapper inserting code calling Numba-compiled *gendesc*.
|
|
241
|
+
"""
|
|
242
|
+
|
|
243
|
+
def imp(context, builder, sig, args):
|
|
244
|
+
func = context.declare_function(builder.module, gendesc)
|
|
245
|
+
# env=None assumes this is a nopython function
|
|
246
|
+
status, retval = context.call_conv.call_function(
|
|
247
|
+
builder, func, gendesc.restype, gendesc.argtypes, args
|
|
248
|
+
)
|
|
249
|
+
# Return raw status for caller to process StopIteration
|
|
250
|
+
return status, retval
|
|
251
|
+
|
|
252
|
+
imp.libs = tuple(libs)
|
|
253
|
+
return imp
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def iterator_impl(iterable_type, iterator_type):
|
|
257
|
+
"""
|
|
258
|
+
Decorator a given class as implementing *iterator_type*
|
|
259
|
+
(by providing an `iternext()` method).
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
def wrapper(cls):
|
|
263
|
+
# These are unbound methods
|
|
264
|
+
iternext = cls.iternext
|
|
265
|
+
|
|
266
|
+
@iternext_impl(RefType.BORROWED)
|
|
267
|
+
def iternext_wrapper(context, builder, sig, args, result):
|
|
268
|
+
(value,) = args
|
|
269
|
+
iterobj = cls(context, builder, value)
|
|
270
|
+
return iternext(iterobj, context, builder, result)
|
|
271
|
+
|
|
272
|
+
lower_builtin("iternext", iterator_type)(iternext_wrapper)
|
|
273
|
+
return cls
|
|
274
|
+
|
|
275
|
+
return wrapper
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
class _IternextResult(object):
|
|
279
|
+
"""
|
|
280
|
+
A result wrapper for iteration, passed by iternext_impl() into the
|
|
281
|
+
wrapped function.
|
|
282
|
+
"""
|
|
283
|
+
|
|
284
|
+
__slots__ = ("_context", "_builder", "_pairobj")
|
|
285
|
+
|
|
286
|
+
def __init__(self, context, builder, pairobj):
|
|
287
|
+
self._context = context
|
|
288
|
+
self._builder = builder
|
|
289
|
+
self._pairobj = pairobj
|
|
290
|
+
|
|
291
|
+
def set_exhausted(self):
|
|
292
|
+
"""
|
|
293
|
+
Mark the iterator as exhausted.
|
|
294
|
+
"""
|
|
295
|
+
self._pairobj.second = self._context.get_constant(types.boolean, False)
|
|
296
|
+
|
|
297
|
+
def set_valid(self, is_valid=True):
|
|
298
|
+
"""
|
|
299
|
+
Mark the iterator as valid according to *is_valid* (which must
|
|
300
|
+
be either a Python boolean or a LLVM inst).
|
|
301
|
+
"""
|
|
302
|
+
if is_valid in (False, True):
|
|
303
|
+
is_valid = self._context.get_constant(types.boolean, is_valid)
|
|
304
|
+
self._pairobj.second = is_valid
|
|
305
|
+
|
|
306
|
+
def yield_(self, value):
|
|
307
|
+
"""
|
|
308
|
+
Mark the iterator as yielding the given *value* (a LLVM inst).
|
|
309
|
+
"""
|
|
310
|
+
self._pairobj.first = value
|
|
311
|
+
|
|
312
|
+
def is_valid(self):
|
|
313
|
+
"""
|
|
314
|
+
Return whether the iterator is marked valid.
|
|
315
|
+
"""
|
|
316
|
+
return self._context.get_argument_value(
|
|
317
|
+
self._builder, types.boolean, self._pairobj.second
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
def yielded_value(self):
|
|
321
|
+
"""
|
|
322
|
+
Return the iterator's yielded value, if any.
|
|
323
|
+
"""
|
|
324
|
+
return self._pairobj.first
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
class RefType(Enum):
|
|
328
|
+
"""
|
|
329
|
+
Enumerate the reference type
|
|
330
|
+
"""
|
|
331
|
+
|
|
332
|
+
"""
|
|
333
|
+
A new reference
|
|
334
|
+
"""
|
|
335
|
+
NEW = 1
|
|
336
|
+
"""
|
|
337
|
+
A borrowed reference
|
|
338
|
+
"""
|
|
339
|
+
BORROWED = 2
|
|
340
|
+
"""
|
|
341
|
+
An untracked reference
|
|
342
|
+
"""
|
|
343
|
+
UNTRACKED = 3
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
def iternext_impl(ref_type=None):
|
|
347
|
+
"""
|
|
348
|
+
Wrap the given iternext() implementation so that it gets passed
|
|
349
|
+
an _IternextResult() object easing the returning of the iternext()
|
|
350
|
+
result pair.
|
|
351
|
+
|
|
352
|
+
ref_type: a numba.targets.imputils.RefType value, the reference type used is
|
|
353
|
+
that specified through the RefType enum.
|
|
354
|
+
|
|
355
|
+
The wrapped function will be called with the following signature:
|
|
356
|
+
(context, builder, sig, args, iternext_result)
|
|
357
|
+
"""
|
|
358
|
+
if ref_type not in [x for x in RefType]:
|
|
359
|
+
raise ValueError("ref_type must be an enum member of imputils.RefType")
|
|
360
|
+
|
|
361
|
+
def outer(func):
|
|
362
|
+
def wrapper(context, builder, sig, args):
|
|
363
|
+
pair_type = sig.return_type
|
|
364
|
+
pairobj = context.make_helper(builder, pair_type)
|
|
365
|
+
func(
|
|
366
|
+
context,
|
|
367
|
+
builder,
|
|
368
|
+
sig,
|
|
369
|
+
args,
|
|
370
|
+
_IternextResult(context, builder, pairobj),
|
|
371
|
+
)
|
|
372
|
+
if ref_type == RefType.NEW:
|
|
373
|
+
impl_ret = impl_ret_new_ref
|
|
374
|
+
elif ref_type == RefType.BORROWED:
|
|
375
|
+
impl_ret = impl_ret_borrowed
|
|
376
|
+
elif ref_type == RefType.UNTRACKED:
|
|
377
|
+
impl_ret = impl_ret_untracked
|
|
378
|
+
else:
|
|
379
|
+
raise ValueError("Unknown ref_type encountered")
|
|
380
|
+
return impl_ret(context, builder, pair_type, pairobj._getvalue())
|
|
381
|
+
|
|
382
|
+
return wrapper
|
|
383
|
+
|
|
384
|
+
return outer
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
def call_getiter(context, builder, iterable_type, val):
|
|
388
|
+
"""
|
|
389
|
+
Call the `getiter()` implementation for the given *iterable_type*
|
|
390
|
+
of value *val*, and return the corresponding LLVM inst.
|
|
391
|
+
"""
|
|
392
|
+
getiter_sig = typing.signature(iterable_type.iterator_type, iterable_type)
|
|
393
|
+
getiter_impl = context.get_function("getiter", getiter_sig)
|
|
394
|
+
return getiter_impl(builder, (val,))
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
def call_iternext(context, builder, iterator_type, val):
|
|
398
|
+
"""
|
|
399
|
+
Call the `iternext()` implementation for the given *iterator_type*
|
|
400
|
+
of value *val*, and return a convenience _IternextResult() object
|
|
401
|
+
reflecting the results.
|
|
402
|
+
"""
|
|
403
|
+
itemty = iterator_type.yield_type
|
|
404
|
+
pair_type = types.Pair(itemty, types.boolean)
|
|
405
|
+
iternext_sig = typing.signature(pair_type, iterator_type)
|
|
406
|
+
iternext_impl = context.get_function("iternext", iternext_sig)
|
|
407
|
+
val = iternext_impl(builder, (val,))
|
|
408
|
+
pairobj = context.make_helper(builder, pair_type, val)
|
|
409
|
+
return _IternextResult(context, builder, pairobj)
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
def call_len(context, builder, ty, val):
|
|
413
|
+
"""
|
|
414
|
+
Call len() on the given value. Return None if len() isn't defined on
|
|
415
|
+
this type.
|
|
416
|
+
"""
|
|
417
|
+
try:
|
|
418
|
+
len_impl = context.get_function(
|
|
419
|
+
len,
|
|
420
|
+
typing.signature(
|
|
421
|
+
types.intp,
|
|
422
|
+
ty,
|
|
423
|
+
),
|
|
424
|
+
)
|
|
425
|
+
except NotImplementedError:
|
|
426
|
+
return None
|
|
427
|
+
else:
|
|
428
|
+
return len_impl(builder, (val,))
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
_ForIterLoop = collections.namedtuple("_ForIterLoop", ("value", "do_break"))
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
@contextlib.contextmanager
|
|
435
|
+
def for_iter(context, builder, iterable_type, val):
|
|
436
|
+
"""
|
|
437
|
+
Simulate a for loop on the given iterable. Yields a namedtuple with
|
|
438
|
+
the given members:
|
|
439
|
+
- `value` is the value being yielded
|
|
440
|
+
- `do_break` is a callable to early out of the loop
|
|
441
|
+
"""
|
|
442
|
+
iterator_type = iterable_type.iterator_type
|
|
443
|
+
iterval = call_getiter(context, builder, iterable_type, val)
|
|
444
|
+
|
|
445
|
+
bb_body = builder.append_basic_block("for_iter.body")
|
|
446
|
+
bb_end = builder.append_basic_block("for_iter.end")
|
|
447
|
+
|
|
448
|
+
def do_break():
|
|
449
|
+
builder.branch(bb_end)
|
|
450
|
+
|
|
451
|
+
builder.branch(bb_body)
|
|
452
|
+
|
|
453
|
+
with builder.goto_block(bb_body):
|
|
454
|
+
res = call_iternext(context, builder, iterator_type, iterval)
|
|
455
|
+
with builder.if_then(builder.not_(res.is_valid()), likely=False):
|
|
456
|
+
builder.branch(bb_end)
|
|
457
|
+
yield _ForIterLoop(res.yielded_value(), do_break)
|
|
458
|
+
builder.branch(bb_body)
|
|
459
|
+
|
|
460
|
+
builder.position_at_end(bb_end)
|
|
461
|
+
if context.enable_nrt:
|
|
462
|
+
context.nrt.decref(builder, iterator_type, iterval)
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
def impl_ret_new_ref(ctx, builder, retty, ret):
|
|
466
|
+
"""
|
|
467
|
+
The implementation returns a new reference.
|
|
468
|
+
"""
|
|
469
|
+
return ret
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
def impl_ret_borrowed(ctx, builder, retty, ret):
|
|
473
|
+
"""
|
|
474
|
+
The implementation returns a borrowed reference.
|
|
475
|
+
This function automatically incref so that the implementation is
|
|
476
|
+
returning a new reference.
|
|
477
|
+
"""
|
|
478
|
+
if ctx.enable_nrt:
|
|
479
|
+
ctx.nrt.incref(builder, retty, ret)
|
|
480
|
+
return ret
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
def impl_ret_untracked(ctx, builder, retty, ret):
|
|
484
|
+
"""
|
|
485
|
+
The return type is not a NRT object.
|
|
486
|
+
"""
|
|
487
|
+
return ret
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
@contextlib.contextmanager
|
|
491
|
+
def force_error_model(context, model_name="numpy"):
|
|
492
|
+
"""
|
|
493
|
+
Temporarily change the context's error model.
|
|
494
|
+
"""
|
|
495
|
+
from numba.cuda.core import callconv
|
|
496
|
+
|
|
497
|
+
old_error_model = context.error_model
|
|
498
|
+
context.error_model = callconv.create_error_model(model_name, context)
|
|
499
|
+
try:
|
|
500
|
+
yield
|
|
501
|
+
finally:
|
|
502
|
+
context.error_model = old_error_model
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
def numba_typeref_ctor(*args, **kwargs):
|
|
506
|
+
"""A stub for use internally by Numba when a call is emitted
|
|
507
|
+
on a TypeRef.
|
|
508
|
+
"""
|
|
509
|
+
raise NotImplementedError("This function should not be executed.")
|