Qu

device_used

Builtin index · REPL & diagnostics

result = device_used()

Input: no input · Output: result

What it is

Takes no arguments.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = device_used()no input
result string or number
Returns a struct-like value with two fields: .device (a string, e.g. "cpu" or a GPU device name) and .gpu_dispatches (a number, the count of operations actually dispatched to the GPU). Reports where the accelerated work actually went — a GPU that quietly fell back to the CPU is the failure this catches.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

A = randn(200, 200)
B = randn(200, 200)
C = A * B
d = device_used()
print("device = {d.device}, gpu_dispatches = {d.gpu_dispatches}")
p = gpu_probe_info()
print("gpu available = {p.available}, crossover = {p.crossover}")

from repl-diagnostics

How it works

device_used() -- whether this run has actually dispatched anything to the GPU, and how many times. Distinct from sysinfo().gpu, which says a GPU *exists*. Qu dispatches to it only above a measured crossover, so a machine with a GPU can easily complete a whole script on the CPU -- and reporting "GPU: RTX 4070" next to a timing that never touched it is exactly the misleading claim this exists to prevent.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.