Skip to main content

//clika-runtime/io.clika.runtime/Backends

Backends

[jvm]
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 ClikaRtGen.COMPUTE_API_* value (the api of a Device) and needs ClikaRt.load first.

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_NOT_LOADED: the backend did not load; BACKEND_UNAVAILABLE: it loaded but exposes no device it can serve).

ClikaRt.load()
val declined = Backends.deviceStatus(ClikaRtGen.COMPUTE_API_VULKAN)
if (declined == null) {
println("Vulkan devices: " + Backends.devices(ClikaRtGen.COMPUTE_API_VULKAN))
} else {
println("Vulkan declined: ${declined.message} (${declined.codeName})")
}

Functions​

NameSummary
deviceCount[jvm]
fun deviceCount(api: Int): Int
How many devices the backend exposes here (0 when it is unavailable).
devices[jvm]
fun devices(api: Int): List<Device>
The devices the backend exposes here, in index order; empty when the backend is unavailable (a valid answer, not an error).
deviceStatus[jvm]
fun deviceStatus(api: Int): 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[jvm]
fun isAvailable(api: Int): Boolean
Does the backend load and initialize on this device? Brings it up on the first call.
isCompiled[jvm]
fun isCompiled(api: Int): Boolean
Was the backend compiled into this build? A build-time fact; loads nothing.
isLoaded[jvm]
fun isLoaded(api: Int): 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[jvm]
fun loadStatus(api: Int): ClikaRtException?
null when the backend loads; else the refusal, un-thrown (see the class doc).
properties[jvm]
fun properties(device: Device): DeviceProperties
The static capabilities of device: its name, DeviceProperties.kind (where it sits relative to the host), driver and runtime versions, compute geometry, memory, and the dtypes the hardware accelerates.