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,392 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
from numba.cuda import types
|
|
5
|
+
from numba.cuda import cgutils
|
|
6
|
+
from collections import namedtuple
|
|
7
|
+
|
|
8
|
+
from llvmlite import ir
|
|
9
|
+
|
|
10
|
+
int32_t = ir.IntType(32)
|
|
11
|
+
int64_t = ir.IntType(64)
|
|
12
|
+
errcode_t = int32_t
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Status = namedtuple(
|
|
16
|
+
"Status",
|
|
17
|
+
(
|
|
18
|
+
"code",
|
|
19
|
+
# If the function returned ok (a value or None)
|
|
20
|
+
"is_ok",
|
|
21
|
+
# If the function returned None
|
|
22
|
+
"is_none",
|
|
23
|
+
# If the function errored out (== not is_ok)
|
|
24
|
+
"is_error",
|
|
25
|
+
# If the generator exited with StopIteration
|
|
26
|
+
"is_stop_iteration",
|
|
27
|
+
# If the function errored with an already set exception
|
|
28
|
+
"is_python_exc",
|
|
29
|
+
# If the function errored with a user exception
|
|
30
|
+
"is_user_exc",
|
|
31
|
+
# The pointer to the exception info structure (for user
|
|
32
|
+
# exceptions)
|
|
33
|
+
"excinfoptr",
|
|
34
|
+
),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _const_int(code):
|
|
39
|
+
return ir.Constant(errcode_t, code)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
RETCODE_OK = _const_int(0)
|
|
43
|
+
RETCODE_EXC = _const_int(-1)
|
|
44
|
+
RETCODE_NONE = _const_int(-2)
|
|
45
|
+
# StopIteration
|
|
46
|
+
RETCODE_STOPIT = _const_int(-3)
|
|
47
|
+
|
|
48
|
+
FIRST_USEREXC = 1
|
|
49
|
+
|
|
50
|
+
RETCODE_USEREXC = _const_int(FIRST_USEREXC)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class BaseCallConv(object):
|
|
54
|
+
def __init__(self, context):
|
|
55
|
+
self.context = context
|
|
56
|
+
|
|
57
|
+
def return_optional_value(self, builder, retty, valty, value):
|
|
58
|
+
if valty == types.none:
|
|
59
|
+
# Value is none
|
|
60
|
+
self.return_native_none(builder)
|
|
61
|
+
|
|
62
|
+
elif retty == valty:
|
|
63
|
+
# Value is an optional, need a runtime switch
|
|
64
|
+
optval = self.context.make_helper(builder, retty, value=value)
|
|
65
|
+
|
|
66
|
+
validbit = cgutils.as_bool_bit(builder, optval.valid)
|
|
67
|
+
with builder.if_then(validbit):
|
|
68
|
+
retval = self.context.get_return_value(
|
|
69
|
+
builder, retty.type, optval.data
|
|
70
|
+
)
|
|
71
|
+
self.return_value(builder, retval)
|
|
72
|
+
|
|
73
|
+
self.return_native_none(builder)
|
|
74
|
+
|
|
75
|
+
elif not isinstance(valty, types.Optional):
|
|
76
|
+
# Value is not an optional, need a cast
|
|
77
|
+
if valty != retty.type:
|
|
78
|
+
value = self.context.cast(
|
|
79
|
+
builder, value, fromty=valty, toty=retty.type
|
|
80
|
+
)
|
|
81
|
+
retval = self.context.get_return_value(builder, retty.type, value)
|
|
82
|
+
self.return_value(builder, retval)
|
|
83
|
+
|
|
84
|
+
else:
|
|
85
|
+
raise NotImplementedError(
|
|
86
|
+
"returning {0} for {1}".format(valty, retty)
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def return_native_none(self, builder):
|
|
90
|
+
self._return_errcode_raw(builder, RETCODE_NONE)
|
|
91
|
+
|
|
92
|
+
def return_exc(self, builder):
|
|
93
|
+
self._return_errcode_raw(builder, RETCODE_EXC)
|
|
94
|
+
|
|
95
|
+
def return_stop_iteration(self, builder):
|
|
96
|
+
self._return_errcode_raw(builder, RETCODE_STOPIT)
|
|
97
|
+
|
|
98
|
+
def get_return_type(self, ty):
|
|
99
|
+
"""
|
|
100
|
+
Get the actual type of the return argument for Numba type *ty*.
|
|
101
|
+
"""
|
|
102
|
+
restype = self.context.data_model_manager[ty].get_return_type()
|
|
103
|
+
return restype.as_pointer()
|
|
104
|
+
|
|
105
|
+
def init_call_helper(self, builder):
|
|
106
|
+
"""
|
|
107
|
+
Initialize and return a call helper object for the given builder.
|
|
108
|
+
"""
|
|
109
|
+
ch = self._make_call_helper(builder)
|
|
110
|
+
builder.__call_helper = ch
|
|
111
|
+
return ch
|
|
112
|
+
|
|
113
|
+
def _get_call_helper(self, builder):
|
|
114
|
+
return builder.__call_helper
|
|
115
|
+
|
|
116
|
+
def unpack_exception(self, builder, pyapi, status):
|
|
117
|
+
return pyapi.unserialize(status.excinfoptr)
|
|
118
|
+
|
|
119
|
+
def raise_error(self, builder, pyapi, status):
|
|
120
|
+
"""
|
|
121
|
+
Given a non-ok *status*, raise the corresponding Python exception.
|
|
122
|
+
"""
|
|
123
|
+
bbend = builder.function.append_basic_block()
|
|
124
|
+
|
|
125
|
+
with builder.if_then(status.is_user_exc):
|
|
126
|
+
# Unserialize user exception.
|
|
127
|
+
# Make sure another error may not interfere.
|
|
128
|
+
pyapi.err_clear()
|
|
129
|
+
exc = self.unpack_exception(builder, pyapi, status)
|
|
130
|
+
with cgutils.if_likely(builder, cgutils.is_not_null(builder, exc)):
|
|
131
|
+
pyapi.raise_object(exc) # steals ref
|
|
132
|
+
builder.branch(bbend)
|
|
133
|
+
|
|
134
|
+
with builder.if_then(status.is_stop_iteration):
|
|
135
|
+
pyapi.err_set_none("PyExc_StopIteration")
|
|
136
|
+
builder.branch(bbend)
|
|
137
|
+
|
|
138
|
+
with builder.if_then(status.is_python_exc):
|
|
139
|
+
# Error already raised => nothing to do
|
|
140
|
+
builder.branch(bbend)
|
|
141
|
+
|
|
142
|
+
pyapi.err_set_string(
|
|
143
|
+
"PyExc_SystemError", "unknown error when calling native function"
|
|
144
|
+
)
|
|
145
|
+
builder.branch(bbend)
|
|
146
|
+
|
|
147
|
+
builder.position_at_end(bbend)
|
|
148
|
+
|
|
149
|
+
def decode_arguments(self, builder, argtypes, func):
|
|
150
|
+
"""
|
|
151
|
+
Get the decoded (unpacked) Python arguments with *argtypes*
|
|
152
|
+
from LLVM function *func*. A tuple of LLVM values is returned.
|
|
153
|
+
"""
|
|
154
|
+
raw_args = self.get_arguments(func)
|
|
155
|
+
arginfo = self._get_arg_packer(argtypes)
|
|
156
|
+
return arginfo.from_arguments(builder, raw_args)
|
|
157
|
+
|
|
158
|
+
def _get_arg_packer(self, argtypes):
|
|
159
|
+
"""
|
|
160
|
+
Get an argument packer for the given argument types.
|
|
161
|
+
"""
|
|
162
|
+
return self.context.get_arg_packer(argtypes)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class MinimalCallConv(BaseCallConv):
|
|
166
|
+
"""
|
|
167
|
+
A minimal calling convention, suitable for e.g. GPU targets.
|
|
168
|
+
The implemented function signature is:
|
|
169
|
+
|
|
170
|
+
retcode_t (<Python return type>*, ... <Python arguments>)
|
|
171
|
+
|
|
172
|
+
The return code will be one of the RETCODE_* constants or a
|
|
173
|
+
function-specific user exception id (>= RETCODE_USEREXC).
|
|
174
|
+
|
|
175
|
+
Caller is responsible for allocating a slot for the return value
|
|
176
|
+
(passed as a pointer in the first argument).
|
|
177
|
+
"""
|
|
178
|
+
|
|
179
|
+
def _make_call_helper(self, builder):
|
|
180
|
+
return _MinimalCallHelper()
|
|
181
|
+
|
|
182
|
+
def return_value(self, builder, retval):
|
|
183
|
+
retptr = builder.function.args[0]
|
|
184
|
+
assert retval.type == retptr.type.pointee, (
|
|
185
|
+
str(retval.type),
|
|
186
|
+
str(retptr.type.pointee),
|
|
187
|
+
)
|
|
188
|
+
builder.store(retval, retptr)
|
|
189
|
+
self._return_errcode_raw(builder, RETCODE_OK)
|
|
190
|
+
|
|
191
|
+
def return_user_exc(
|
|
192
|
+
self, builder, exc, exc_args=None, loc=None, func_name=None
|
|
193
|
+
):
|
|
194
|
+
if exc is not None and not issubclass(exc, BaseException):
|
|
195
|
+
raise TypeError(
|
|
196
|
+
"exc should be None or exception class, got %r" % (exc,)
|
|
197
|
+
)
|
|
198
|
+
if exc_args is not None and not isinstance(exc_args, tuple):
|
|
199
|
+
raise TypeError(
|
|
200
|
+
"exc_args should be None or tuple, got %r" % (exc_args,)
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
# Build excinfo struct
|
|
204
|
+
if loc is not None:
|
|
205
|
+
fname = loc._raw_function_name()
|
|
206
|
+
if fname is None:
|
|
207
|
+
# could be exec(<string>) or REPL, try func_name
|
|
208
|
+
fname = func_name
|
|
209
|
+
|
|
210
|
+
locinfo = (fname, loc.filename, loc.line)
|
|
211
|
+
if None in locinfo:
|
|
212
|
+
locinfo = None
|
|
213
|
+
else:
|
|
214
|
+
locinfo = None
|
|
215
|
+
|
|
216
|
+
call_helper = self._get_call_helper(builder)
|
|
217
|
+
exc_id = call_helper._add_exception(exc, exc_args, locinfo)
|
|
218
|
+
self._return_errcode_raw(builder, _const_int(exc_id))
|
|
219
|
+
|
|
220
|
+
def return_status_propagate(self, builder, status):
|
|
221
|
+
self._return_errcode_raw(builder, status.code)
|
|
222
|
+
|
|
223
|
+
def _return_errcode_raw(self, builder, code):
|
|
224
|
+
if isinstance(code, int):
|
|
225
|
+
code = _const_int(code)
|
|
226
|
+
builder.ret(code)
|
|
227
|
+
|
|
228
|
+
def _get_return_status(self, builder, code):
|
|
229
|
+
"""
|
|
230
|
+
Given a return *code*, get a Status instance.
|
|
231
|
+
"""
|
|
232
|
+
norm = builder.icmp_signed("==", code, RETCODE_OK)
|
|
233
|
+
none = builder.icmp_signed("==", code, RETCODE_NONE)
|
|
234
|
+
ok = builder.or_(norm, none)
|
|
235
|
+
err = builder.not_(ok)
|
|
236
|
+
exc = builder.icmp_signed("==", code, RETCODE_EXC)
|
|
237
|
+
is_stop_iteration = builder.icmp_signed("==", code, RETCODE_STOPIT)
|
|
238
|
+
is_user_exc = builder.icmp_signed(">=", code, RETCODE_USEREXC)
|
|
239
|
+
|
|
240
|
+
status = Status(
|
|
241
|
+
code=code,
|
|
242
|
+
is_ok=ok,
|
|
243
|
+
is_error=err,
|
|
244
|
+
is_python_exc=exc,
|
|
245
|
+
is_none=none,
|
|
246
|
+
is_user_exc=is_user_exc,
|
|
247
|
+
is_stop_iteration=is_stop_iteration,
|
|
248
|
+
excinfoptr=None,
|
|
249
|
+
)
|
|
250
|
+
return status
|
|
251
|
+
|
|
252
|
+
def get_function_type(self, restype, argtypes):
|
|
253
|
+
"""
|
|
254
|
+
Get the implemented Function type for *restype* and *argtypes*.
|
|
255
|
+
"""
|
|
256
|
+
arginfo = self._get_arg_packer(argtypes)
|
|
257
|
+
argtypes = list(arginfo.argument_types)
|
|
258
|
+
resptr = self.get_return_type(restype)
|
|
259
|
+
fnty = ir.FunctionType(errcode_t, [resptr] + argtypes)
|
|
260
|
+
return fnty
|
|
261
|
+
|
|
262
|
+
def decorate_function(self, fn, args, fe_argtypes, noalias=False):
|
|
263
|
+
"""
|
|
264
|
+
Set names and attributes of function arguments.
|
|
265
|
+
"""
|
|
266
|
+
assert not noalias
|
|
267
|
+
arginfo = self._get_arg_packer(fe_argtypes)
|
|
268
|
+
arginfo.assign_names(self.get_arguments(fn), ["arg." + a for a in args])
|
|
269
|
+
fn.args[0].name = ".ret"
|
|
270
|
+
|
|
271
|
+
def get_arguments(self, func):
|
|
272
|
+
"""
|
|
273
|
+
Get the Python-level arguments of LLVM *func*.
|
|
274
|
+
"""
|
|
275
|
+
return func.args[1:]
|
|
276
|
+
|
|
277
|
+
def call_function(self, builder, callee, resty, argtys, args):
|
|
278
|
+
"""
|
|
279
|
+
Call the Numba-compiled *callee*.
|
|
280
|
+
"""
|
|
281
|
+
retty = callee.args[0].type.pointee
|
|
282
|
+
retvaltmp = cgutils.alloca_once(builder, retty)
|
|
283
|
+
# initialize return value
|
|
284
|
+
builder.store(cgutils.get_null_value(retty), retvaltmp)
|
|
285
|
+
|
|
286
|
+
arginfo = self._get_arg_packer(argtys)
|
|
287
|
+
args = arginfo.as_arguments(builder, args)
|
|
288
|
+
realargs = [retvaltmp] + list(args)
|
|
289
|
+
code = builder.call(callee, realargs)
|
|
290
|
+
status = self._get_return_status(builder, code)
|
|
291
|
+
retval = builder.load(retvaltmp)
|
|
292
|
+
out = self.context.get_returned_value(builder, resty, retval)
|
|
293
|
+
return status, out
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
class _MinimalCallHelper(object):
|
|
297
|
+
"""
|
|
298
|
+
A call helper object for the "minimal" calling convention.
|
|
299
|
+
User exceptions are represented as integer codes and stored in
|
|
300
|
+
a mapping for retrieval from the caller.
|
|
301
|
+
"""
|
|
302
|
+
|
|
303
|
+
def __init__(self):
|
|
304
|
+
self.exceptions = {}
|
|
305
|
+
|
|
306
|
+
def _add_exception(self, exc, exc_args, locinfo):
|
|
307
|
+
"""
|
|
308
|
+
Add a new user exception to this helper. Returns an integer that can be
|
|
309
|
+
used to refer to the added exception in future.
|
|
310
|
+
|
|
311
|
+
Parameters
|
|
312
|
+
----------
|
|
313
|
+
exc :
|
|
314
|
+
exception type
|
|
315
|
+
exc_args : None or tuple
|
|
316
|
+
exception args
|
|
317
|
+
locinfo : tuple
|
|
318
|
+
location information
|
|
319
|
+
"""
|
|
320
|
+
exc_id = len(self.exceptions) + FIRST_USEREXC
|
|
321
|
+
self.exceptions[exc_id] = exc, exc_args, locinfo
|
|
322
|
+
return exc_id
|
|
323
|
+
|
|
324
|
+
def get_exception(self, exc_id):
|
|
325
|
+
"""
|
|
326
|
+
Get information about a user exception. Returns a tuple of
|
|
327
|
+
(exception type, exception args, location information).
|
|
328
|
+
|
|
329
|
+
Parameters
|
|
330
|
+
----------
|
|
331
|
+
id : integer
|
|
332
|
+
The ID of the exception to look up
|
|
333
|
+
"""
|
|
334
|
+
try:
|
|
335
|
+
return self.exceptions[exc_id]
|
|
336
|
+
except KeyError:
|
|
337
|
+
msg = "unknown error %d in native function" % exc_id
|
|
338
|
+
exc = SystemError
|
|
339
|
+
exc_args = (msg,)
|
|
340
|
+
locinfo = None
|
|
341
|
+
return exc, exc_args, locinfo
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
class ErrorModel(object):
|
|
345
|
+
def __init__(self, call_conv):
|
|
346
|
+
self.call_conv = call_conv
|
|
347
|
+
|
|
348
|
+
def fp_zero_division(self, builder, exc_args=None, loc=None):
|
|
349
|
+
if self.raise_on_fp_zero_division:
|
|
350
|
+
self.call_conv.return_user_exc(
|
|
351
|
+
builder, ZeroDivisionError, exc_args, loc
|
|
352
|
+
)
|
|
353
|
+
return True
|
|
354
|
+
else:
|
|
355
|
+
return False
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
class PythonErrorModel(ErrorModel):
|
|
359
|
+
"""
|
|
360
|
+
The Python error model. Any invalid FP input raises an exception.
|
|
361
|
+
"""
|
|
362
|
+
|
|
363
|
+
raise_on_fp_zero_division = True
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
class NumpyErrorModel(ErrorModel):
|
|
367
|
+
"""
|
|
368
|
+
In the Numpy error model, floating-point errors don't raise an
|
|
369
|
+
exception. The FPU exception state is inspected by Numpy at the
|
|
370
|
+
end of a ufunc's execution and a warning is raised if appropriate.
|
|
371
|
+
|
|
372
|
+
Note there's no easy way to set the FPU exception state from LLVM.
|
|
373
|
+
Instructions known to set an FP exception can be optimized away:
|
|
374
|
+
https://llvm.org/bugs/show_bug.cgi?id=6050
|
|
375
|
+
http://lists.llvm.org/pipermail/llvm-dev/2014-September/076918.html
|
|
376
|
+
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140929/237997.html
|
|
377
|
+
"""
|
|
378
|
+
|
|
379
|
+
raise_on_fp_zero_division = False
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
error_models = {
|
|
383
|
+
"python": PythonErrorModel,
|
|
384
|
+
"numpy": NumpyErrorModel,
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def create_error_model(model_name, context):
|
|
389
|
+
"""
|
|
390
|
+
Create an error model instance for the given target context.
|
|
391
|
+
"""
|
|
392
|
+
return error_models[model_name](context.call_conv)
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
|
|
4
|
+
from abc import abstractmethod, ABCMeta
|
|
5
|
+
from numba.cuda.misc.llvm_pass_timings import PassTimingsCollection
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CodeLibrary(metaclass=ABCMeta):
|
|
9
|
+
"""
|
|
10
|
+
An interface for bundling LLVM code together and compiling it.
|
|
11
|
+
It is tied to a *codegen* instance (e.g. JITCUDACodegen) that will
|
|
12
|
+
determine how the LLVM code is transformed and linked together.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
_finalized = False
|
|
16
|
+
_object_caching_enabled = False
|
|
17
|
+
_disable_inspection = False
|
|
18
|
+
|
|
19
|
+
def __init__(self, codegen: "Codegen", name: str):
|
|
20
|
+
self._codegen = codegen
|
|
21
|
+
self._name = name
|
|
22
|
+
ptc_name = f"{self.__class__.__name__}({self._name!r})"
|
|
23
|
+
self._recorded_timings = PassTimingsCollection(ptc_name)
|
|
24
|
+
# Track names of the dynamic globals
|
|
25
|
+
self._dynamic_globals = []
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def has_dynamic_globals(self):
|
|
29
|
+
self._ensure_finalized()
|
|
30
|
+
return len(self._dynamic_globals) > 0
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def recorded_timings(self):
|
|
34
|
+
return self._recorded_timings
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def codegen(self):
|
|
38
|
+
"""
|
|
39
|
+
The codegen object owning this library.
|
|
40
|
+
"""
|
|
41
|
+
return self._codegen
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def name(self):
|
|
45
|
+
return self._name
|
|
46
|
+
|
|
47
|
+
def __repr__(self):
|
|
48
|
+
return "<Library %r at 0x%x>" % (self.name, id(self))
|
|
49
|
+
|
|
50
|
+
def _raise_if_finalized(self):
|
|
51
|
+
if self._finalized:
|
|
52
|
+
raise RuntimeError(
|
|
53
|
+
"operation impossible on finalized object %r" % (self,)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def _ensure_finalized(self):
|
|
57
|
+
if not self._finalized:
|
|
58
|
+
self.finalize()
|
|
59
|
+
|
|
60
|
+
def create_ir_module(self, name):
|
|
61
|
+
"""
|
|
62
|
+
Create an LLVM IR module for use by this library.
|
|
63
|
+
"""
|
|
64
|
+
self._raise_if_finalized()
|
|
65
|
+
ir_module = self._codegen._create_empty_module(name)
|
|
66
|
+
return ir_module
|
|
67
|
+
|
|
68
|
+
@abstractmethod
|
|
69
|
+
def add_linking_library(self, library):
|
|
70
|
+
"""
|
|
71
|
+
Add a library for linking into this library, without losing
|
|
72
|
+
the original library.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
@abstractmethod
|
|
76
|
+
def add_ir_module(self, ir_module):
|
|
77
|
+
"""
|
|
78
|
+
Add an LLVM IR module's contents to this library.
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
@abstractmethod
|
|
82
|
+
def finalize(self):
|
|
83
|
+
"""
|
|
84
|
+
Finalize the library. After this call, nothing can be added anymore.
|
|
85
|
+
Finalization involves various stages of code optimization and
|
|
86
|
+
linking.
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
@abstractmethod
|
|
90
|
+
def get_function(self, name):
|
|
91
|
+
"""
|
|
92
|
+
Return the function named ``name``.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
@abstractmethod
|
|
96
|
+
def get_llvm_str(self):
|
|
97
|
+
"""
|
|
98
|
+
Get the human-readable form of the LLVM module.
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
@abstractmethod
|
|
102
|
+
def get_asm_str(self):
|
|
103
|
+
"""
|
|
104
|
+
Get the human-readable assembly.
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
#
|
|
108
|
+
# Object cache hooks and serialization
|
|
109
|
+
#
|
|
110
|
+
|
|
111
|
+
def enable_object_caching(self):
|
|
112
|
+
self._object_caching_enabled = True
|
|
113
|
+
self._compiled_object = None
|
|
114
|
+
self._compiled = False
|
|
115
|
+
|
|
116
|
+
def _get_compiled_object(self):
|
|
117
|
+
if not self._object_caching_enabled:
|
|
118
|
+
raise ValueError("object caching not enabled in %s" % (self,))
|
|
119
|
+
if self._compiled_object is None:
|
|
120
|
+
raise RuntimeError("no compiled object yet for %s" % (self,))
|
|
121
|
+
return self._compiled_object
|
|
122
|
+
|
|
123
|
+
def _set_compiled_object(self, value):
|
|
124
|
+
if not self._object_caching_enabled:
|
|
125
|
+
raise ValueError("object caching not enabled in %s" % (self,))
|
|
126
|
+
if self._compiled:
|
|
127
|
+
raise ValueError("library already compiled: %s" % (self,))
|
|
128
|
+
self._compiled_object = value
|
|
129
|
+
self._disable_inspection = True
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class Codegen(metaclass=ABCMeta):
|
|
133
|
+
"""
|
|
134
|
+
Base Codegen class. It is expected that subclasses set the class attribute
|
|
135
|
+
``_library_class``, indicating the CodeLibrary class for the target.
|
|
136
|
+
|
|
137
|
+
Subclasses should also initialize:
|
|
138
|
+
|
|
139
|
+
``self._data_layout``: the data layout for the target.
|
|
140
|
+
``self._target_data``: the binding layer ``TargetData`` for the target.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
@abstractmethod
|
|
144
|
+
def _create_empty_module(self, name):
|
|
145
|
+
"""
|
|
146
|
+
Create a new empty module suitable for the target.
|
|
147
|
+
"""
|
|
148
|
+
|
|
149
|
+
@abstractmethod
|
|
150
|
+
def _add_module(self, module):
|
|
151
|
+
"""
|
|
152
|
+
Add a module to the execution engine. Ownership of the module is
|
|
153
|
+
transferred to the engine.
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
@property
|
|
157
|
+
def target_data(self):
|
|
158
|
+
"""
|
|
159
|
+
The LLVM "target data" object for this codegen instance.
|
|
160
|
+
"""
|
|
161
|
+
return self._target_data
|
|
162
|
+
|
|
163
|
+
def create_library(self, name, **kwargs):
|
|
164
|
+
"""
|
|
165
|
+
Create a :class:`CodeLibrary` object for use with this codegen
|
|
166
|
+
instance.
|
|
167
|
+
"""
|
|
168
|
+
return self._library_class(self, name, **kwargs)
|
|
169
|
+
|
|
170
|
+
def unserialize_library(self, serialized):
|
|
171
|
+
return self._library_class._unserialize(self, serialized)
|