Compute end of kernel dynamically