  In a device-to-device (D2D) underlaid massive MIMO system, D2D transmitters
reuse the uplink spectrum of cellular users (CUs), leading to cochannel
interference. To decrease pilot overhead, we assume pilot reuse (PR) among D2D
pairs. We first derive the minimum-mean-square-error (MMSE) estimation of all
channels and give a lower bound on the ergodic achievable rate of both cellular
and D2D links. To mitigate pilot contamination caused by PR, we then propose a
pilot scheduling and pilot power control algorithm based on the criterion of
minimizing the sum mean-square-error (MSE) of channel estimation of D2D links.
We show that, with an appropriate PR ratio and a well designed pilot scheduling
scheme, each D2D transmitter could transmit its pilot with maximum power. In
addition, we also maximize the sum rate of all D2D links while guaranteeing the
quality of service (QoS) of CUs, and develop an iterative algorithm to obtain a
suboptimal solution. Simulation results show that the effect of pilot
contamination can be greatly decreased by the proposed pilot scheduling
algorithm, and the PR scheme provides significant performance gains over the
conventional orthogonal training scheme in terms of system spectral efficiency.
