change nthreads to ndata in CUDA_KERNEL_LOOP