This is horribly inefficient, even for perform code.  You should generate a single inplace elemwise addition kernel and reuse it for each index.  What you are doing now is generating a new kernel for each index (which involves a fork of nvcc each time).