Optimal retiming of regular processor arrays