Crystal Palace have completed the signing of striker Dwight Gayle from Peterborough United for £4.5m.