in gpu version, y is a 1d array