# KernelAbstractions.get\_backend keyword arguments

**URL:** <https://discourse.julialang.org/t/kernelabstractions-get-backend-keyword-arguments/97895>\
**Category:** GPU\
**Created:** [April 25, 2023, 12:50pm UTC](https://discourse.julialang.org/t/kernelabstractions-get-backend-keyword-arguments/97895 "2023-04-25T12:50:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bjarthur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarthur/32/9638_2.png) [@bjarthur](https://discourse.julialang.org/u/bjarthur)\
**Post date:** [April 25, 2023, 12:50pm UTC](https://discourse.julialang.org/t/kernelabstractions-get-backend-keyword-arguments/97895/1 "2023-04-25T12:50:35Z")

</div>

`CUDABackend` accepts two keyword arguments. the default for `prefer_blocks` is false. i have a custom kernel for which i need that to be true. `KernelAbstractions.get_backend` has no way to pass that in. so how do i write vendor agnostic code then?

it seems to me that `get_backend` needs to accept keyword argments too. so in KernelAbstractions.jl:

```julia
get_backend(::Array; kwargs...) = CPU()
etc...

```

and in CUDAKernels.jl:

```julia
KernelAbstractions.get_backend(::CUDA.CuArray; kwargs...) = CUDABackend(kwargs)

```

does that make sense? happy to submit a PR if so.

---

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [April 26, 2023, 2:36am UTC](https://discourse.julialang.org/t/kernelabstractions-get-backend-keyword-arguments/97895/2 "2023-04-26T02:36:23Z")

</div>

Hm …

The issue is that the keyword arguments each backend may accept are indeterminate.

In DiffEqGPU.jl (where I prototyped some of these ideas) I used a package extension: [DiffEqGPU.jl/CUDAExt.jl at 6abad672269e1bd0c57eb0c1b48149a32f04213f · SciML/DiffEqGPU.jl · GitHub](https://github.com/SciML/DiffEqGPU.jl/blob/6abad672269e1bd0c57eb0c1b48149a32f04213f/ext/CUDAExt.jl#L12)

We could “standardize” this in KA as `similar(backend; kwargs...)` and each backend could discard the keyword arguments that don’t apply to it.

Not sure what the best design here is.
