This one has my head hurting. I’m not even sure how to explain the problem, but I’ll do my best.

I am working on a project using CUDAnative and one of my kernels takes a function as an argument.

I would like to pass additional arguments to this function. If I pass number as an argument it works, but if I pass a variable it doesn’t. Is there a way to “apply” variables as constants? Can this be done with a macro?

This minimual example shows what I mean:

```
using CUDAnative
using CuArrays
function applyfun(x::CuDeviceArray, F::CuDeviceArray, f)
i = ( blockIdx().x - 1) * blockDim().x + threadIdx().x
F[i] = f(x[i])
return nothing
end
nthreads = 512
nblocks = 10
F = cuzeros(nthreads * nblocks)
x = CuArray( LinRange(0, 10, nthreads*nblocks) )
f(x, c) = c*x^2
#This workds
g1(x) = f(x,1)
@cuda blocks=nblocks threads=nthreads applyfun(x, F, g1 )
#This doesn't work
b = 1
g2(x) = f(x,b)
@cuda blocks=nblocks threads=nthreads applyfun(x, F, g2 )
```