KernelAbstractions.jl icon indicating copy to clipboard operation
KernelAbstractions.jl copied to clipboard

`get_backend` support for `MVector`

Open mattsignorelli opened this issue 6 months ago • 5 comments

This fails right now:

julia> using KernelAbstractions, StaticArrays

julia> get_backend(MVector(1,2,3))
ERROR: ArgumentError: Implement `KernelAbstractions.get_backend(::MVector{3, Int64})`
Stacktrace:
 [1] get_backend(A::MVector{3, Int64})
   @ KernelAbstractions ~/.julia/packages/KernelAbstractions/C3nYQ/src/KernelAbstractions.jl:522
 [2] top-level scope
   @ REPL[6]:1

mattsignorelli avatar Jun 26 '25 12:06 mattsignorelli

I mean... That kinda seems correct? It could answer with the CPU backend?

vchuravy avatar Jun 26 '25 12:06 vchuravy

It could answer with the CPU backend?

Yes, should it not?

mattsignorelli avatar Jun 26 '25 12:06 mattsignorelli

MVectors are very small and for most scenarios I would expect the overhead of KA not to be worth it, and I would rather receive an error instead of making an implicit bad decision

vchuravy avatar Jun 26 '25 13:06 vchuravy

MVectors are very small and for most scenarios I would expect the overhead of KA not to be worth it,

Thanks to KernelAbstractions, I have a single framework where I can do particle tracking both on the CPU and GPU. This can be anywhere between 1 particle to billions of particles. Each particle is 6 phase space coordinates.

On the CPU, something we do frequently is track a "Taylor-series" type number (see GTPSA.jl) so that we get the transport map expanded around a specific particle as a Taylor series. This is only one particle but the number types are basically Taylor series.

In the spirit of KA, I do not want to have a different framework for tracking 1 particle (which does have benefits when using MVector outside of the tracking part) vs 1 billion particles.

mattsignorelli avatar Jun 26 '25 13:06 mattsignorelli

Part of v0.9.36

vchuravy avatar Jul 01 '25 06:07 vchuravy