in gpu version, y is now a 1d array.