//clika-runtime/io.clika.runtime/Backends
Backends
[common]
object Backends
Backend discovery: which compute backends this runtime carries, which load on THIS device and why one does not, and the devices each exposes. Every call takes a ComputeApi.
A refusal comes back as a VALUE, not a throw: loadStatus and deviceStatus return null when the backend serves, else the ClikaRtException the runtime would have raised, un-thrown, so an app can show message (the reason in plain words: a missing library, a driver that lacks a required feature) and branch on codeName (BACKEND_DRIVER_ABSENT: this host has no vendor driver or loader for the backend; BACKEND_NOT_LOADED: the backend did not load; BACKEND_UNAVAILABLE: it loaded but exposes no device it can serve).
ClikaRt.load()
val declined = Backends.deviceStatus(ComputeApi.VULKAN)
if (declined == null) {
println("Vulkan devices: " + Backends.devices(ComputeApi.VULKAN))
} else {
println("Vulkan declined: ${declined.message} (${declined.codeName})")
}
Functions
| Name | Summary |
|---|---|
| deviceCount | [common] fun deviceCount(api: ComputeApi): Int How many devices the backend exposes here (0 when it is unavailable). |
| devices | [common] fun devices(api: ComputeApi): List<Device> The devices the backend exposes here, in index order; empty when the backend is unavailable (a valid answer, not an error). |
| deviceStatus | [common] fun deviceStatus(api: ComputeApi): ClikaRtException? null when the backend loads AND exposes at least one device it can serve; else the refusal, un-thrown (see the class doc). |
| isAvailable | [common] fun isAvailable(api: ComputeApi): Boolean Does the backend load and initialize on this device? Brings it up on the first call. |
| isCompiled | [common] fun isCompiled(api: ComputeApi): Boolean Was the backend compiled into this build? A build-time fact; loads nothing. |
| isLoaded | [common] fun isLoaded(api: ComputeApi): Boolean Is the backend loaded and initialized right now? A plain read that never brings a backend up: false for one nothing has used yet, one that failed to come up, and one this build does not carry. |
| loadStatus | [common] fun loadStatus(api: ComputeApi): ClikaRtException? null when the backend loads; else the refusal, un-thrown (see the class doc). |