spectrum: ThreeGppChannelModel optimizations
The following changes provide an optimization of the computation of a new channel matrix when using the ThreeGppChannelModel
class.
Specifically, when generating the channel coefficients a lot of computations which involve terms which are independent from the specific tx and rx antenna elements are repeated for each antenna pair. I propose to pre-compute and (temporarily) store such terms, for the sake of achieving better performance.
Indeed, thanks to these changes most of the heavy lifting is now performed N * M times, instead of N * M * A_tx * A_rx times, where N are the number of clusters, M the number of rays per cluster and A_tx and A_rx the number of antennas at the transmitter and the receiver, respectively. For typical MIMO arrays (where A_tx can easily be 64x64 or more), the performance gain is quite significant.
To back up this claim, I ran a test script (that I attach) which generates 5 channel matrices, for A_tx = 16x16 and A_rx = 64x46. As you can see from the attached results, a three-fold performance benefit can be achieved thanks to these changes.
Mainline ns-3 (~ 1400s): This PR (~ 500s):
In fact, if the maintainers deem this appropriate, I propose to also move to the pre-computation step the evaluation of the terms such as sin (rayZoaRadian[nIndex][mIndex]) * cos (rayAoaRadian[nIndex][mIndex])
, for which the same considerations hold true. I did not introduces these changes yet, as 6 new (local) matrices would need to be defined, thus possibly representing a trade-off between style and performance. However, I would personally side with performance.