---
title: "Backends"
sidebar_label: "Backends"
description: "Kotlin binding reference: Backends."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Backends](index.md)

# Backends

[common]\
object [Backends](index.md)

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](../ComputeApi/index.md).

A refusal comes back as a VALUE, not a throw: [loadStatus](loadStatus.md) and [deviceStatus](deviceStatus.md) return null when the backend serves, else the [ClikaRtException](../ClikaRtException/index.md) 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).

```kotlin
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](deviceCount.md) | [common]<br>fun [deviceCount](deviceCount.md)(api: [ComputeApi](../ComputeApi/index.md)): [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)<br>How many devices the backend exposes here (0 when it is unavailable). |
| [devices](devices.md) | [common]<br>fun [devices](devices.md)(api: [ComputeApi](../ComputeApi/index.md)): [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[Device](../Device/index.md)&gt;<br>The devices the backend exposes here, in index order; empty when the backend is unavailable (a valid answer, not an error). |
| [deviceStatus](deviceStatus.md) | [common]<br>fun [deviceStatus](deviceStatus.md)(api: [ComputeApi](../ComputeApi/index.md)): [ClikaRtException](../ClikaRtException/index.md)?<br>null when the backend loads AND exposes at least one device it can serve; else the refusal, un-thrown (see the class doc). |
| [isAvailable](isAvailable.md) | [common]<br>fun [isAvailable](isAvailable.md)(api: [ComputeApi](../ComputeApi/index.md)): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>Does the backend load and initialize on this device? Brings it up on the first call. |
| [isCompiled](isCompiled.md) | [common]<br>fun [isCompiled](isCompiled.md)(api: [ComputeApi](../ComputeApi/index.md)): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>Was the backend compiled into this build? A build-time fact; loads nothing. |
| [isLoaded](isLoaded.md) | [common]<br>fun [isLoaded](isLoaded.md)(api: [ComputeApi](../ComputeApi/index.md)): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>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](loadStatus.md) | [common]<br>fun [loadStatus](loadStatus.md)(api: [ComputeApi](../ComputeApi/index.md)): [ClikaRtException](../ClikaRtException/index.md)?<br>null when the backend loads; else the refusal, un-thrown (see the class doc). |