Corrected cuda kernel functions