Density-functional theory of surface diffusion and epitaxial growth of metals