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.
- _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-312-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-312-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-312-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-312-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-312-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,330 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Function descriptors.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from collections import defaultdict
|
|
9
|
+
import importlib
|
|
10
|
+
|
|
11
|
+
from numba.cuda import types
|
|
12
|
+
from numba.cuda import itanium_mangler
|
|
13
|
+
from numba.cuda.utils import _dynamic_modname, _dynamic_module
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def default_mangler(name, argtypes, *, abi_tags=(), uid=None):
|
|
17
|
+
return itanium_mangler.mangle(name, argtypes, abi_tags=abi_tags, uid=uid)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def qualifying_prefix(modname, qualname):
|
|
21
|
+
"""
|
|
22
|
+
Returns a new string that is used for the first half of the mangled name.
|
|
23
|
+
"""
|
|
24
|
+
# XXX choose a different convention for object mode
|
|
25
|
+
return "{}.{}".format(modname, qualname) if modname else qualname
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class FunctionDescriptor(object):
|
|
29
|
+
"""
|
|
30
|
+
Base class for function descriptors: an object used to carry
|
|
31
|
+
useful metadata about a natively callable function.
|
|
32
|
+
|
|
33
|
+
Note that while `FunctionIdentity` denotes a Python function
|
|
34
|
+
which is being concretely compiled by Numba, `FunctionDescriptor`
|
|
35
|
+
may be more "abstract".
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
__slots__ = (
|
|
39
|
+
"native",
|
|
40
|
+
"modname",
|
|
41
|
+
"qualname",
|
|
42
|
+
"doc",
|
|
43
|
+
"typemap",
|
|
44
|
+
"calltypes",
|
|
45
|
+
"args",
|
|
46
|
+
"kws",
|
|
47
|
+
"restype",
|
|
48
|
+
"argtypes",
|
|
49
|
+
"mangled_name",
|
|
50
|
+
"unique_name",
|
|
51
|
+
"env_name",
|
|
52
|
+
"global_dict",
|
|
53
|
+
"inline",
|
|
54
|
+
"noalias",
|
|
55
|
+
"abi_tags",
|
|
56
|
+
"uid",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def __init__(
|
|
60
|
+
self,
|
|
61
|
+
native,
|
|
62
|
+
modname,
|
|
63
|
+
qualname,
|
|
64
|
+
unique_name,
|
|
65
|
+
doc,
|
|
66
|
+
typemap,
|
|
67
|
+
restype,
|
|
68
|
+
calltypes,
|
|
69
|
+
args,
|
|
70
|
+
kws,
|
|
71
|
+
mangler=None,
|
|
72
|
+
argtypes=None,
|
|
73
|
+
inline=False,
|
|
74
|
+
noalias=False,
|
|
75
|
+
env_name=None,
|
|
76
|
+
global_dict=None,
|
|
77
|
+
abi_tags=(),
|
|
78
|
+
uid=None,
|
|
79
|
+
):
|
|
80
|
+
self.native = native
|
|
81
|
+
self.modname = modname
|
|
82
|
+
self.global_dict = global_dict
|
|
83
|
+
self.qualname = qualname
|
|
84
|
+
self.unique_name = unique_name
|
|
85
|
+
self.doc = doc
|
|
86
|
+
# XXX typemap and calltypes should be on the compile result,
|
|
87
|
+
# not the FunctionDescriptor
|
|
88
|
+
self.typemap = typemap
|
|
89
|
+
self.calltypes = calltypes
|
|
90
|
+
self.args = args
|
|
91
|
+
self.kws = kws
|
|
92
|
+
self.restype = restype
|
|
93
|
+
# Argument types
|
|
94
|
+
if argtypes is not None:
|
|
95
|
+
assert isinstance(argtypes, tuple), argtypes
|
|
96
|
+
self.argtypes = argtypes
|
|
97
|
+
else:
|
|
98
|
+
# Get argument types from the type inference result
|
|
99
|
+
# (note the "arg.FOO" convention as used in typeinfer
|
|
100
|
+
self.argtypes = tuple(self.typemap["arg." + a] for a in args)
|
|
101
|
+
mangler = default_mangler if mangler is None else mangler
|
|
102
|
+
# The mangled name *must* be unique, else the wrong function can
|
|
103
|
+
# be chosen at link time.
|
|
104
|
+
qualprefix = qualifying_prefix(self.modname, self.qualname)
|
|
105
|
+
self.uid = uid
|
|
106
|
+
self.mangled_name = mangler(
|
|
107
|
+
qualprefix,
|
|
108
|
+
self.argtypes,
|
|
109
|
+
abi_tags=abi_tags,
|
|
110
|
+
uid=uid,
|
|
111
|
+
)
|
|
112
|
+
if env_name is None:
|
|
113
|
+
env_name = mangler(
|
|
114
|
+
".NumbaEnv.{}".format(qualprefix),
|
|
115
|
+
self.argtypes,
|
|
116
|
+
abi_tags=abi_tags,
|
|
117
|
+
uid=uid,
|
|
118
|
+
)
|
|
119
|
+
self.env_name = env_name
|
|
120
|
+
self.inline = inline
|
|
121
|
+
self.noalias = noalias
|
|
122
|
+
self.abi_tags = abi_tags
|
|
123
|
+
|
|
124
|
+
def lookup_globals(self):
|
|
125
|
+
"""
|
|
126
|
+
Return the global dictionary of the function.
|
|
127
|
+
It may not match the Module's globals if the function is created
|
|
128
|
+
dynamically (i.e. exec)
|
|
129
|
+
"""
|
|
130
|
+
return self.global_dict or self.lookup_module().__dict__
|
|
131
|
+
|
|
132
|
+
def lookup_module(self):
|
|
133
|
+
"""
|
|
134
|
+
Return the module in which this function is supposed to exist.
|
|
135
|
+
This may be a dummy module if the function was dynamically
|
|
136
|
+
generated or the module can't be found.
|
|
137
|
+
"""
|
|
138
|
+
if self.modname == _dynamic_modname:
|
|
139
|
+
return _dynamic_module
|
|
140
|
+
else:
|
|
141
|
+
try:
|
|
142
|
+
# ensure module exist
|
|
143
|
+
return importlib.import_module(self.modname)
|
|
144
|
+
except ImportError:
|
|
145
|
+
return _dynamic_module
|
|
146
|
+
|
|
147
|
+
def lookup_function(self):
|
|
148
|
+
"""
|
|
149
|
+
Return the original function object described by this object.
|
|
150
|
+
"""
|
|
151
|
+
return getattr(self.lookup_module(), self.qualname)
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def llvm_func_name(self):
|
|
155
|
+
"""
|
|
156
|
+
The LLVM-registered name for the raw function.
|
|
157
|
+
"""
|
|
158
|
+
return self.mangled_name
|
|
159
|
+
|
|
160
|
+
@property
|
|
161
|
+
def llvm_cpython_wrapper_name(self):
|
|
162
|
+
"""
|
|
163
|
+
The LLVM-registered name for a CPython-compatible wrapper of the
|
|
164
|
+
raw function (i.e. a PyCFunctionWithKeywords).
|
|
165
|
+
"""
|
|
166
|
+
return itanium_mangler.prepend_namespace(
|
|
167
|
+
self.mangled_name, ns="cpython"
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
@property
|
|
171
|
+
def llvm_cfunc_wrapper_name(self):
|
|
172
|
+
"""
|
|
173
|
+
The LLVM-registered name for a C-compatible wrapper of the
|
|
174
|
+
raw function.
|
|
175
|
+
"""
|
|
176
|
+
return "cfunc." + self.mangled_name
|
|
177
|
+
|
|
178
|
+
def __repr__(self):
|
|
179
|
+
return "<function descriptor %r>" % (self.unique_name)
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def _get_function_info(cls, func_ir):
|
|
183
|
+
"""
|
|
184
|
+
Returns
|
|
185
|
+
-------
|
|
186
|
+
qualname, unique_name, modname, doc, args, kws, globals
|
|
187
|
+
|
|
188
|
+
``unique_name`` must be a unique name.
|
|
189
|
+
"""
|
|
190
|
+
func = func_ir.func_id.func
|
|
191
|
+
qualname = func_ir.func_id.func_qualname
|
|
192
|
+
# XXX to func_id
|
|
193
|
+
modname = func.__module__
|
|
194
|
+
doc = func.__doc__ or ""
|
|
195
|
+
args = tuple(func_ir.arg_names)
|
|
196
|
+
kws = () # TODO
|
|
197
|
+
global_dict = None
|
|
198
|
+
|
|
199
|
+
if modname is None:
|
|
200
|
+
# Dynamically generated function.
|
|
201
|
+
modname = _dynamic_modname
|
|
202
|
+
# Retain a reference to the dictionary of the function.
|
|
203
|
+
# This disables caching, serialization and pickling.
|
|
204
|
+
global_dict = func_ir.func_id.func.__globals__
|
|
205
|
+
|
|
206
|
+
unique_name = func_ir.func_id.unique_name
|
|
207
|
+
|
|
208
|
+
return qualname, unique_name, modname, doc, args, kws, global_dict
|
|
209
|
+
|
|
210
|
+
@classmethod
|
|
211
|
+
def _from_python_function(
|
|
212
|
+
cls,
|
|
213
|
+
func_ir,
|
|
214
|
+
typemap,
|
|
215
|
+
restype,
|
|
216
|
+
calltypes,
|
|
217
|
+
native,
|
|
218
|
+
mangler=None,
|
|
219
|
+
inline=False,
|
|
220
|
+
noalias=False,
|
|
221
|
+
abi_tags=(),
|
|
222
|
+
):
|
|
223
|
+
(
|
|
224
|
+
qualname,
|
|
225
|
+
unique_name,
|
|
226
|
+
modname,
|
|
227
|
+
doc,
|
|
228
|
+
args,
|
|
229
|
+
kws,
|
|
230
|
+
global_dict,
|
|
231
|
+
) = cls._get_function_info(func_ir)
|
|
232
|
+
|
|
233
|
+
self = cls(
|
|
234
|
+
native,
|
|
235
|
+
modname,
|
|
236
|
+
qualname,
|
|
237
|
+
unique_name,
|
|
238
|
+
doc,
|
|
239
|
+
typemap,
|
|
240
|
+
restype,
|
|
241
|
+
calltypes,
|
|
242
|
+
args,
|
|
243
|
+
kws,
|
|
244
|
+
mangler=mangler,
|
|
245
|
+
inline=inline,
|
|
246
|
+
noalias=noalias,
|
|
247
|
+
global_dict=global_dict,
|
|
248
|
+
abi_tags=abi_tags,
|
|
249
|
+
uid=func_ir.func_id.unique_id,
|
|
250
|
+
)
|
|
251
|
+
return self
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
class PythonFunctionDescriptor(FunctionDescriptor):
|
|
255
|
+
"""
|
|
256
|
+
A FunctionDescriptor subclass for Numba-compiled functions.
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
__slots__ = ()
|
|
260
|
+
|
|
261
|
+
@classmethod
|
|
262
|
+
def from_specialized_function(
|
|
263
|
+
cls,
|
|
264
|
+
func_ir,
|
|
265
|
+
typemap,
|
|
266
|
+
restype,
|
|
267
|
+
calltypes,
|
|
268
|
+
mangler,
|
|
269
|
+
inline,
|
|
270
|
+
noalias,
|
|
271
|
+
abi_tags,
|
|
272
|
+
):
|
|
273
|
+
"""
|
|
274
|
+
Build a FunctionDescriptor for a given specialization of a Python
|
|
275
|
+
function (in nopython mode).
|
|
276
|
+
"""
|
|
277
|
+
return cls._from_python_function(
|
|
278
|
+
func_ir,
|
|
279
|
+
typemap,
|
|
280
|
+
restype,
|
|
281
|
+
calltypes,
|
|
282
|
+
native=True,
|
|
283
|
+
mangler=mangler,
|
|
284
|
+
inline=inline,
|
|
285
|
+
noalias=noalias,
|
|
286
|
+
abi_tags=abi_tags,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
@classmethod
|
|
290
|
+
def from_object_mode_function(cls, func_ir):
|
|
291
|
+
"""
|
|
292
|
+
Build a FunctionDescriptor for an object mode variant of a Python
|
|
293
|
+
function.
|
|
294
|
+
"""
|
|
295
|
+
typemap = defaultdict(lambda: types.pyobject)
|
|
296
|
+
calltypes = typemap.copy()
|
|
297
|
+
restype = types.pyobject
|
|
298
|
+
return cls._from_python_function(
|
|
299
|
+
func_ir, typemap, restype, calltypes, native=False
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
class ExternalFunctionDescriptor(FunctionDescriptor):
|
|
304
|
+
"""
|
|
305
|
+
A FunctionDescriptor subclass for opaque external functions
|
|
306
|
+
(e.g. raw C functions).
|
|
307
|
+
"""
|
|
308
|
+
|
|
309
|
+
__slots__ = ()
|
|
310
|
+
|
|
311
|
+
def __init__(self, name, restype, argtypes):
|
|
312
|
+
args = ["arg%d" % i for i in range(len(argtypes))]
|
|
313
|
+
|
|
314
|
+
def mangler(a, x, abi_tags, uid=None):
|
|
315
|
+
return a
|
|
316
|
+
|
|
317
|
+
super(ExternalFunctionDescriptor, self).__init__(
|
|
318
|
+
native=True,
|
|
319
|
+
modname=None,
|
|
320
|
+
qualname=name,
|
|
321
|
+
unique_name=name,
|
|
322
|
+
doc="",
|
|
323
|
+
typemap=None,
|
|
324
|
+
restype=restype,
|
|
325
|
+
calltypes=None,
|
|
326
|
+
args=args,
|
|
327
|
+
kws=None,
|
|
328
|
+
mangler=mangler,
|
|
329
|
+
argtypes=argtypes,
|
|
330
|
+
)
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Support for lowering generators.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import llvmlite.ir
|
|
9
|
+
from llvmlite.ir import Constant, IRBuilder
|
|
10
|
+
|
|
11
|
+
from numba.cuda import types, config, cgutils
|
|
12
|
+
from numba.cuda.core.funcdesc import FunctionDescriptor
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class GeneratorDescriptor(FunctionDescriptor):
|
|
16
|
+
"""
|
|
17
|
+
The descriptor for a generator's next function.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
__slots__ = ()
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def from_generator_fndesc(cls, func_ir, fndesc, gentype, mangler):
|
|
24
|
+
"""
|
|
25
|
+
Build a GeneratorDescriptor for the generator returned by the
|
|
26
|
+
function described by *fndesc*, with type *gentype*.
|
|
27
|
+
|
|
28
|
+
The generator inherits the env_name from the *fndesc*.
|
|
29
|
+
All emitted functions for the generator shares the same Env.
|
|
30
|
+
"""
|
|
31
|
+
assert isinstance(gentype, types.Generator)
|
|
32
|
+
restype = gentype.yield_type
|
|
33
|
+
args = ["gen"]
|
|
34
|
+
argtypes = (gentype,)
|
|
35
|
+
qualname = fndesc.qualname + ".next"
|
|
36
|
+
unique_name = fndesc.unique_name + ".next"
|
|
37
|
+
self = cls(
|
|
38
|
+
fndesc.native,
|
|
39
|
+
fndesc.modname,
|
|
40
|
+
qualname,
|
|
41
|
+
unique_name,
|
|
42
|
+
fndesc.doc,
|
|
43
|
+
fndesc.typemap,
|
|
44
|
+
restype,
|
|
45
|
+
fndesc.calltypes,
|
|
46
|
+
args,
|
|
47
|
+
fndesc.kws,
|
|
48
|
+
argtypes=argtypes,
|
|
49
|
+
mangler=mangler,
|
|
50
|
+
inline=False,
|
|
51
|
+
env_name=fndesc.env_name,
|
|
52
|
+
)
|
|
53
|
+
return self
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def llvm_finalizer_name(self):
|
|
57
|
+
"""
|
|
58
|
+
The LLVM name of the generator's finalizer function
|
|
59
|
+
(if <generator type>.has_finalizer is true).
|
|
60
|
+
"""
|
|
61
|
+
return "finalize_" + self.mangled_name
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class BaseGeneratorLower(object):
|
|
65
|
+
"""
|
|
66
|
+
Base support class for lowering generators.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
def __init__(self, lower):
|
|
70
|
+
self.context = lower.context
|
|
71
|
+
self.fndesc = lower.fndesc
|
|
72
|
+
self.library = lower.library
|
|
73
|
+
self.func_ir = lower.func_ir
|
|
74
|
+
self.lower = lower
|
|
75
|
+
|
|
76
|
+
self.geninfo = lower.generator_info
|
|
77
|
+
self.gentype = self.get_generator_type()
|
|
78
|
+
self.gendesc = GeneratorDescriptor.from_generator_fndesc(
|
|
79
|
+
lower.func_ir, self.fndesc, self.gentype, self.context.mangler
|
|
80
|
+
)
|
|
81
|
+
# Helps packing non-omitted arguments into a structure
|
|
82
|
+
self.arg_packer = self.context.get_data_packer(self.fndesc.argtypes)
|
|
83
|
+
|
|
84
|
+
self.resume_blocks = {}
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def call_conv(self):
|
|
88
|
+
return self.lower.call_conv
|
|
89
|
+
|
|
90
|
+
def get_args_ptr(self, builder, genptr):
|
|
91
|
+
return cgutils.gep_inbounds(builder, genptr, 0, 1)
|
|
92
|
+
|
|
93
|
+
def get_resume_index_ptr(self, builder, genptr):
|
|
94
|
+
return cgutils.gep_inbounds(
|
|
95
|
+
builder, genptr, 0, 0, name="gen.resume_index"
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
def get_state_ptr(self, builder, genptr):
|
|
99
|
+
return cgutils.gep_inbounds(builder, genptr, 0, 2, name="gen.state")
|
|
100
|
+
|
|
101
|
+
def lower_init_func(self, lower):
|
|
102
|
+
"""
|
|
103
|
+
Lower the generator's initialization function (which will fill up
|
|
104
|
+
the passed-by-reference generator structure).
|
|
105
|
+
"""
|
|
106
|
+
lower.setup_function(self.fndesc)
|
|
107
|
+
|
|
108
|
+
builder = lower.builder
|
|
109
|
+
|
|
110
|
+
# Insert the generator into the target context in order to allow
|
|
111
|
+
# calling from other Numba-compiled functions.
|
|
112
|
+
lower.context.insert_generator(
|
|
113
|
+
self.gentype, self.gendesc, [self.library]
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
# Init argument values
|
|
117
|
+
lower.extract_function_arguments()
|
|
118
|
+
|
|
119
|
+
lower.pre_lower()
|
|
120
|
+
|
|
121
|
+
# Initialize the return structure (i.e. the generator structure).
|
|
122
|
+
retty = self.context.get_return_type(self.gentype)
|
|
123
|
+
# Structure index #0: the initial resume index (0 == start of generator)
|
|
124
|
+
resume_index = self.context.get_constant(types.int32, 0)
|
|
125
|
+
# Structure index #2: the states
|
|
126
|
+
statesty = retty.elements[2]
|
|
127
|
+
|
|
128
|
+
lower.debug_print("# low_init_func incref")
|
|
129
|
+
# Incref all NRT arguments before storing into generator states
|
|
130
|
+
if self.context.enable_nrt:
|
|
131
|
+
for argty, argval in zip(self.fndesc.argtypes, lower.fnargs):
|
|
132
|
+
self.context.nrt.incref(builder, argty, argval)
|
|
133
|
+
|
|
134
|
+
# Filter out omitted arguments
|
|
135
|
+
argsval = self.arg_packer.as_data(builder, lower.fnargs)
|
|
136
|
+
|
|
137
|
+
# Zero initialize states
|
|
138
|
+
statesval = Constant(statesty, None)
|
|
139
|
+
gen_struct = cgutils.make_anonymous_struct(
|
|
140
|
+
builder, [resume_index, argsval, statesval], retty
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
retval = self.box_generator_struct(lower, gen_struct)
|
|
144
|
+
|
|
145
|
+
lower.debug_print("# low_init_func before return")
|
|
146
|
+
self.call_conv.return_value(builder, retval)
|
|
147
|
+
lower.post_lower()
|
|
148
|
+
|
|
149
|
+
def lower_next_func(self, lower):
|
|
150
|
+
"""
|
|
151
|
+
Lower the generator's next() function (which takes the
|
|
152
|
+
passed-by-reference generator structure and returns the next
|
|
153
|
+
yielded value).
|
|
154
|
+
"""
|
|
155
|
+
lower.setup_function(self.gendesc)
|
|
156
|
+
lower.debug_print(
|
|
157
|
+
"# lower_next_func: {0}".format(self.gendesc.unique_name)
|
|
158
|
+
)
|
|
159
|
+
assert self.gendesc.argtypes[0] == self.gentype
|
|
160
|
+
builder = lower.builder
|
|
161
|
+
function = lower.function
|
|
162
|
+
|
|
163
|
+
# Extract argument values and other information from generator struct
|
|
164
|
+
(genptr,) = self.call_conv.get_arguments(function)
|
|
165
|
+
self.arg_packer.load_into(
|
|
166
|
+
builder, self.get_args_ptr(builder, genptr), lower.fnargs
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
self.resume_index_ptr = self.get_resume_index_ptr(builder, genptr)
|
|
170
|
+
self.gen_state_ptr = self.get_state_ptr(builder, genptr)
|
|
171
|
+
|
|
172
|
+
prologue = function.append_basic_block("generator_prologue")
|
|
173
|
+
|
|
174
|
+
# Lower the generator's Python code
|
|
175
|
+
entry_block_tail = lower.lower_function_body()
|
|
176
|
+
|
|
177
|
+
# Add block for StopIteration on entry
|
|
178
|
+
stop_block = function.append_basic_block("stop_iteration")
|
|
179
|
+
builder.position_at_end(stop_block)
|
|
180
|
+
self.call_conv.return_stop_iteration(builder)
|
|
181
|
+
|
|
182
|
+
# Add prologue switch to resume blocks
|
|
183
|
+
builder.position_at_end(prologue)
|
|
184
|
+
# First Python block is also the resume point on first next() call
|
|
185
|
+
self.resume_blocks[0] = lower.blkmap[lower.firstblk]
|
|
186
|
+
|
|
187
|
+
# Create front switch to resume points
|
|
188
|
+
switch = builder.switch(builder.load(self.resume_index_ptr), stop_block)
|
|
189
|
+
for index, block in self.resume_blocks.items():
|
|
190
|
+
switch.add_case(index, block)
|
|
191
|
+
|
|
192
|
+
# Close tail of entry block
|
|
193
|
+
builder.position_at_end(entry_block_tail)
|
|
194
|
+
builder.branch(prologue)
|
|
195
|
+
|
|
196
|
+
def lower_finalize_func(self, lower):
|
|
197
|
+
"""
|
|
198
|
+
Lower the generator's finalizer.
|
|
199
|
+
"""
|
|
200
|
+
fnty = llvmlite.ir.FunctionType(
|
|
201
|
+
llvmlite.ir.VoidType(), [self.context.get_value_type(self.gentype)]
|
|
202
|
+
)
|
|
203
|
+
function = cgutils.get_or_insert_function(
|
|
204
|
+
lower.module, fnty, self.gendesc.llvm_finalizer_name
|
|
205
|
+
)
|
|
206
|
+
entry_block = function.append_basic_block("entry")
|
|
207
|
+
builder = IRBuilder(entry_block)
|
|
208
|
+
|
|
209
|
+
genptrty = self.context.get_value_type(self.gentype)
|
|
210
|
+
genptr = builder.bitcast(function.args[0], genptrty)
|
|
211
|
+
self.lower_finalize_func_body(builder, genptr)
|
|
212
|
+
|
|
213
|
+
def return_from_generator(self, lower):
|
|
214
|
+
"""
|
|
215
|
+
Emit a StopIteration at generator end and mark the generator exhausted.
|
|
216
|
+
"""
|
|
217
|
+
indexval = Constant(self.resume_index_ptr.type.pointee, -1)
|
|
218
|
+
lower.builder.store(indexval, self.resume_index_ptr)
|
|
219
|
+
self.call_conv.return_stop_iteration(lower.builder)
|
|
220
|
+
|
|
221
|
+
def create_resumption_block(self, lower, index):
|
|
222
|
+
block_name = "generator_resume%d" % (index,)
|
|
223
|
+
block = lower.function.append_basic_block(block_name)
|
|
224
|
+
lower.builder.position_at_end(block)
|
|
225
|
+
self.resume_blocks[index] = block
|
|
226
|
+
|
|
227
|
+
def debug_print(self, builder, msg):
|
|
228
|
+
if config.DEBUG_JIT:
|
|
229
|
+
self.context.debug_print(builder, "DEBUGJIT: {0}".format(msg))
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class GeneratorLower(BaseGeneratorLower):
|
|
233
|
+
"""
|
|
234
|
+
Support class for lowering nopython generators.
|
|
235
|
+
"""
|
|
236
|
+
|
|
237
|
+
def get_generator_type(self):
|
|
238
|
+
return self.fndesc.restype
|
|
239
|
+
|
|
240
|
+
def box_generator_struct(self, lower, gen_struct):
|
|
241
|
+
return gen_struct
|
|
242
|
+
|
|
243
|
+
def lower_finalize_func_body(self, builder, genptr):
|
|
244
|
+
"""
|
|
245
|
+
Lower the body of the generator's finalizer: decref all live
|
|
246
|
+
state variables.
|
|
247
|
+
"""
|
|
248
|
+
self.debug_print(builder, "# generator: finalize")
|
|
249
|
+
if self.context.enable_nrt:
|
|
250
|
+
# Always dereference all arguments
|
|
251
|
+
# self.debug_print(builder, "# generator: clear args")
|
|
252
|
+
args_ptr = self.get_args_ptr(builder, genptr)
|
|
253
|
+
for ty, val in self.arg_packer.load(builder, args_ptr):
|
|
254
|
+
self.context.nrt.decref(builder, ty, val)
|
|
255
|
+
|
|
256
|
+
self.debug_print(builder, "# generator: finalize end")
|
|
257
|
+
builder.ret_void()
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class PyGeneratorLower(BaseGeneratorLower):
|
|
261
|
+
"""
|
|
262
|
+
Support class for lowering object mode generators.
|
|
263
|
+
"""
|
|
264
|
+
|
|
265
|
+
def get_generator_type(self):
|
|
266
|
+
"""
|
|
267
|
+
Compute the actual generator type (the generator function's return
|
|
268
|
+
type is simply "pyobject").
|
|
269
|
+
"""
|
|
270
|
+
return types.Generator(
|
|
271
|
+
gen_func=self.func_ir.func_id.func,
|
|
272
|
+
yield_type=types.pyobject,
|
|
273
|
+
arg_types=(types.pyobject,) * self.func_ir.arg_count,
|
|
274
|
+
state_types=(types.pyobject,) * len(self.geninfo.state_vars),
|
|
275
|
+
has_finalizer=True,
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
def box_generator_struct(self, lower, gen_struct):
|
|
279
|
+
"""
|
|
280
|
+
Box the raw *gen_struct* as a Python object.
|
|
281
|
+
"""
|
|
282
|
+
gen_ptr = cgutils.alloca_once_value(lower.builder, gen_struct)
|
|
283
|
+
return lower.pyapi.from_native_generator(
|
|
284
|
+
gen_ptr, self.gentype, lower.envarg
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
def init_generator_state(self, lower):
|
|
288
|
+
"""
|
|
289
|
+
NULL-initialize all generator state variables, to avoid spurious
|
|
290
|
+
decref's on cleanup.
|
|
291
|
+
"""
|
|
292
|
+
lower.builder.store(
|
|
293
|
+
Constant(self.gen_state_ptr.type.pointee, None), self.gen_state_ptr
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
def lower_finalize_func_body(self, builder, genptr):
|
|
297
|
+
"""
|
|
298
|
+
Lower the body of the generator's finalizer: decref all live
|
|
299
|
+
state variables.
|
|
300
|
+
"""
|
|
301
|
+
pyapi = self.context.get_python_api(builder)
|
|
302
|
+
resume_index_ptr = self.get_resume_index_ptr(builder, genptr)
|
|
303
|
+
resume_index = builder.load(resume_index_ptr)
|
|
304
|
+
# If resume_index is 0, next() was never called
|
|
305
|
+
# If resume_index is -1, generator terminated cleanly
|
|
306
|
+
# (note function arguments are saved in state variables,
|
|
307
|
+
# so they don't need a separate cleanup step)
|
|
308
|
+
need_cleanup = builder.icmp_signed(
|
|
309
|
+
">", resume_index, Constant(resume_index.type, 0)
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
with cgutils.if_unlikely(builder, need_cleanup):
|
|
313
|
+
# Decref all live vars (some may be NULL)
|
|
314
|
+
gen_state_ptr = self.get_state_ptr(builder, genptr)
|
|
315
|
+
for state_index in range(len(self.gentype.state_types)):
|
|
316
|
+
state_slot = cgutils.gep_inbounds(
|
|
317
|
+
builder, gen_state_ptr, 0, state_index
|
|
318
|
+
)
|
|
319
|
+
ty = self.gentype.state_types[state_index]
|
|
320
|
+
val = self.context.unpack_value(builder, ty, state_slot)
|
|
321
|
+
pyapi.decref(val)
|
|
322
|
+
|
|
323
|
+
builder.ret_void()
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
class LowerYield(object):
|
|
327
|
+
"""
|
|
328
|
+
Support class for lowering a particular yield point.
|
|
329
|
+
"""
|
|
330
|
+
|
|
331
|
+
def __init__(self, lower, yield_point, live_vars):
|
|
332
|
+
self.lower = lower
|
|
333
|
+
self.context = lower.context
|
|
334
|
+
self.builder = lower.builder
|
|
335
|
+
self.genlower = lower.genlower
|
|
336
|
+
self.gentype = self.genlower.gentype
|
|
337
|
+
|
|
338
|
+
self.gen_state_ptr = self.genlower.gen_state_ptr
|
|
339
|
+
self.resume_index_ptr = self.genlower.resume_index_ptr
|
|
340
|
+
self.yp = yield_point
|
|
341
|
+
self.inst = self.yp.inst
|
|
342
|
+
self.live_vars = live_vars
|
|
343
|
+
self.live_var_indices = [
|
|
344
|
+
lower.generator_info.state_vars.index(v) for v in live_vars
|
|
345
|
+
]
|
|
346
|
+
|
|
347
|
+
def lower_yield_suspend(self):
|
|
348
|
+
self.lower.debug_print("# generator suspend")
|
|
349
|
+
# Save live vars in state
|
|
350
|
+
for state_index, name in zip(self.live_var_indices, self.live_vars):
|
|
351
|
+
state_slot = cgutils.gep_inbounds(
|
|
352
|
+
self.builder, self.gen_state_ptr, 0, state_index
|
|
353
|
+
)
|
|
354
|
+
ty = self.gentype.state_types[state_index]
|
|
355
|
+
# The yield might be in a loop, in which case the state might
|
|
356
|
+
# contain a predicate var that branches back to the loop head, in
|
|
357
|
+
# this case the var is live but in sequential lowering won't have
|
|
358
|
+
# been alloca'd yet, so do this here.
|
|
359
|
+
fetype = self.lower.typeof(name)
|
|
360
|
+
self.lower._alloca_var(name, fetype)
|
|
361
|
+
val = self.lower.loadvar(name)
|
|
362
|
+
# IncRef newly stored value
|
|
363
|
+
if self.context.enable_nrt:
|
|
364
|
+
self.context.nrt.incref(self.builder, ty, val)
|
|
365
|
+
|
|
366
|
+
self.context.pack_value(self.builder, ty, val, state_slot)
|
|
367
|
+
# Save resume index
|
|
368
|
+
indexval = Constant(self.resume_index_ptr.type.pointee, self.inst.index)
|
|
369
|
+
self.builder.store(indexval, self.resume_index_ptr)
|
|
370
|
+
self.lower.debug_print("# generator suspend end")
|
|
371
|
+
|
|
372
|
+
def lower_yield_resume(self):
|
|
373
|
+
# Emit resumption point
|
|
374
|
+
self.genlower.create_resumption_block(self.lower, self.inst.index)
|
|
375
|
+
self.lower.debug_print("# generator resume")
|
|
376
|
+
# Reload live vars from state
|
|
377
|
+
for state_index, name in zip(self.live_var_indices, self.live_vars):
|
|
378
|
+
state_slot = cgutils.gep_inbounds(
|
|
379
|
+
self.builder, self.gen_state_ptr, 0, state_index
|
|
380
|
+
)
|
|
381
|
+
ty = self.gentype.state_types[state_index]
|
|
382
|
+
val = self.context.unpack_value(self.builder, ty, state_slot)
|
|
383
|
+
self.lower.storevar(val, name)
|
|
384
|
+
# Previous storevar is making an extra incref
|
|
385
|
+
if self.context.enable_nrt:
|
|
386
|
+
self.context.nrt.decref(self.builder, ty, val)
|
|
387
|
+
self.lower.debug_print("# generator resume end")
|