Scaling first-principles plane-wave codes to thousands of processors