KggmlRuntime
Kotlin entry point to the shared native ggml runtime (kggml_runtime.h).
The native runtime is inherently process-wide (one shared ggml per process, see AGENTS.md §2.1), so this is a stateless facade over a reference-counted native lifecycle rather than an engine singleton: engines remain ordinary instantiable classes that each acquire their own RuntimeHandle and close it with themselves.
Android / JVM Desktop: calls go through the
kggml_runtime_jniJNI bridge. On the JVM the native libraries are loaded from the directory named by thekggml.native.pathsystem property, else extracted from the jar (/kggml/native/<os>-<arch>/), else fromjava.library.path.iOS: calls go straight to the C ABI through Kotlin/Native cinterop, linked against the dynamic
GgmlRuntime.framework(GgmlRuntime.xcframework).
Every native failure surfaces as a typed com.donfuldauer.kggml.core.InferenceException; status codes 0..6 map onto their NativeErrorCode counterparts and runtime-specific codes (100+) onto com.donfuldauer.kggml.core.NativeFailureException with the raw code preserved. A runtime that cannot be loaded at all is reported as a NativeFailureException whose cause is the platform loading error.
Functions
Takes a reference on the native runtime (initializing it on the first reference). Close the returned handle to release it; the runtime shuts down when the last handle is closed.
The backends usable on this device with this build. Always contains ComputeBackend.CPU_ONLY and never ComputeBackend.AUTO.
Every backend kind known to the runtime, CPU first, with compile-time and device availability.
The ggml descriptions (the driver's device names, e.g. "Adreno (TM) 730") of the GPU devices of backend, in the order the engines' gpuDevice options count them. Devices the runtime does not offer (PowerVR) are listed too, so indices stay aligned. Empty for ComputeBackend.CPU_ONLY, ComputeBackend.NPU_COREML and ComputeBackend.AUTO, and for a backend without devices.
Number of logical hardware threads (at least 1).
Version metadata of the loaded native runtime and its pinned ggml.
true while at least one runtime reference is held (by any caller in this process).
Recommended inference thread count: the number of performance cores, always at least 1 and at most hardwareThreadCount. On phones these are the cores of the top tiers (at least 75% of the fastest core's scheduler capacity, at most 4 of them), never the efficiency cores; on Apple silicon the P-cores. The engines use it for BackendConfig.AUTO_THREADS.
Resolves requested against availableBackends using ComputeBackend.resolve.
Why backend is not available on this device with this build, or null when it is (always for ComputeBackend.CPU_ONLY and ComputeBackend.AUTO). Examples: "no Vulkan device", "PowerVR excluded (set KGGML_VULKAN_ALLOW_POWERVR=1 to allow): PowerVR C-Series CXTP-48-1536", "OpenCL is not available (no kggml-runtime-opencl add-on)". Diagnostic text for logs and UIs, not a stable format. The engines report it as InferenceEngine.backendFallbackReason when they fall back from backend.