Skip to content

KernelAbstractions kernels ​

Loading KernelAbstractions runs each loop of the Parallel executor as one kernel on a backend. It also adds the Adapt.jl rules that carry coefficient wrappers and built-in modifiers into a kernel. It works without a GPU package, here on the CPU backend, though Threaded is faster there. A new modifier type that holds arrays needs an Adapt.adapt_structure method.

julia
using ComposableRecurrences, KernelAbstractions
using ComposableRecurrences: EXECUTOR, Parallel
using Base.ScopedValues: with
r = Recurrence([0.5, 0.3])
R, h = fill(1.1, 3, 4), ones(3, 2)
y = with(() -> r(R; history = h), EXECUTOR => Parallel(CPU()))
y ≈ r(R; history = h)

# output

true

Known issues ​

SymptomWorkaround
An error inside a loop body loses its type on the CPU backendRerun under Serial() to see it

Executors are compared in Executors; device arrays need the GPUArrays extension.