Runtimes
dspk runs every operation on a runtime: cuda (NVIDIA), wgpu (Vulkan / Metal / DirectX, any
GPU) or cpu. The same call gives the same result on each; only the time differs. Every function
takes runtime=; without it, the one dspk.runtime.set chose (default: the first available).
Which runtimes this build has, and which one is in use
import time
import numpy as np
import dspkfrom plating import signals
print("available:", dspk.runtime.available())print("in use: ", dspk.runtime.current())The same operation on every runtime: identical results, different times
s = signals.synthetic(channels=64, seconds=2.0)results, times = {}, {}for rt in dspk.runtime.available(): try: dspk.ops.spatial.car(s.data, runtime=rt) # the first call compiles the kernels (cached on disk) except RuntimeError as e: # compiled in, but no such device on this machine print(f"{rt}: not usable here ({e})") continue start = time.perf_counter() results[rt] = dspk.ops.spatial.car(s.data, runtime=rt) times[rt] = (time.perf_counter() - start) * 1e3first = next(iter(results.values()))for rt, out in results.items(): print(f"{rt:5s} {times[rt]:7.1f} ms max difference from {next(iter(results))}: {np.max(np.abs(out - first)):.1e}")
The whole script is playground/01_basics/01_runtimes.py. Run it with uv run python playground/01_basics/01_runtimes.py.