Fix local memory problem in kernel function.