Launch kernel from kernel with temporary local variable

I’m trying to launch a kernel from a kernel and while I was successful in getting that to work I need to pass it a temporary variable to consume once after the kernel has finished but I get the compiler error “a pointer to local memory cannot be passed to a launch as an argument”

__global__ void Dim(float2* p, float* a){
    const auto i = blockIdx.x * blockDim.x + threadIdx.x;
    if(a[i] > _minbright) a[i] -= _dimstep;
    if(a[i] < _minbright) a[i] = _minbright;
    if(a[i] == 1.0F - _dimstep){
        auto m = 1.0F;
        auto mi = 0;
        LightConnected<<<gridDim.x, blockDim.x>>>(p, a, i, &m, &mi);
        cudaDeviceSynchronize();
        a[mi] = 1.0F;
    }
}
float *m = new float[1];
*m = 1.0f;
int *mi = new int[1];
*mi = 0;
LightConnected<<<gridDim.x, blockDim.x>>>(p, a, i, m, mi);

You probably should also subsequently delete[] these at an appropriate point in your code.

Ah the humble new and delete, I cant believe I didn’t think of that, thanks!