# Efficient GPU Implementation of the McMurchie-Davidson Method for Shell-Based ERI Computations
## 6 Performance Evaluation
* Second, by looking at the number of shells presented in Table 3, the reader may easily note that for each basis function, the number of shells with the largest azimuthal quantum number is always one. For example, when using the cc-pV6Z basis set, there is only one h-shell. In this scenario, the highest computational cost per shell-based ERI arises from the shell-based ERI involving four h-shells; however, there is only one such shell-based ERI. Therefore, the SBM (STM) algorithm deals with such computation by a single CUDA block (CUDA thread). In contrast, by observing the results from Table 3, the number of basis functions with the largest azimuthal quantum number is 21. Hence, the number of Basis-ERIs formed by four h-orbitals can be calculated as  
\[\frac{21(21+1)(21^{2}+21+2)}{8}=28,014.\]  
Thus, the BBM(BTM) algorithm uses 28,014 CUDA blocks (CUDA threads) for parallel computation. As a result, the shell-based algorithms fail to achieve effective parallelism for certain ERI computations compared to the basis function-based algorithms. The lack of effective parallelism becomes a computational bottleneck, causing the shell-based algorithms to underperform. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline  & & \multicolumn{5}{c}{**Monatonic Hydrogen (H)**} \\ \hline
**Basis Function Set** & **cc-pVDZ** & **cc-pVTZ** & **cc-pVQZ** & **cc-pV5Z** & **cc-pV6Z** \\ \hline  & s-orbitals & 2 & 3 & 4 & 5 & 6 \\  & p-orbitals & 3 & 6 & 9 & 12 & 15 \\  & d-orbitals & 0 & 6 & 12 & 18 & 24 \\ Basis functions & f-orbitals & 0 & 0 & 10 & 20 & 30 \\  & g-orbitals & 0 & 0 & 0 & 15 & 30 \\  & h-orbitals & 0 & 0 & 0 & 0 & 21 \\  & ERIs & 120 & 1035 & 198,765 & 3,088,855 & 32,012,001 \\ \hline  & s-shells & 5 & 7 & 9 & 12 & 15 \\  & p-shells & 1 & 2 & 3 & 4 & 5 \\  & d-shells & 0 & 1 & 2 & 3 & 4 \\ Shells & f-shells & 0 & 0 & 1 & 2 & 3 \\  & g-shells & 0 & 0 & 0 & 1 & 2 \\  & h-shells & 0 & 0 & 0 & 0 & 1 \\  & ERIs & 231 & 1540 & 7260 & 32,131 & 108,345 \\ \hline  & BBM & 1.243 & 4.714 & 54.285 & 972.916 & 14836.465 \\ Computation time [ms] & SBM & 0.955 & 23.412 & 379.478 & 5002.266 & 51,561.765 \\  & BTM & 1.591 & 6.75 & 28.985 & 602.931 & 24,833.564 \\  & STM & 5.408 & 630.327 & 21,516.44 & 340,450.3 & 3,833,350 \\ \hline  & BBM/BTM & 0.781 & 0.698 & 1.872 & 1.613 & 0.597 \\ Speedup rate & SBM/STM & 0.176 & 0.037 & 0.017 & 0.014 & 0.013 \\  & BTM/STM & 0.294 & 0.010 & 0.001 & 0.001 & 0.006 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Computation time of ERIs for monatomic molecules using GPU implementations. Additionally, the implementations that assign one thread per ERI (BTM, STM) were found to be slower than the implementations that assign one block per ERI (BBM, SBM) in most cases. This observation is particularly clear and pronounced between the performance of SBM and STM. Similarly to the above-mentioned insights, we argue that the lack of effective parallelism is one of the key reasons explaining the diminished performance of schemes based on one thread per ERI (BTM, STM). Under similar conditions, the SBM algorithm computes the shell-based ERI involving four h-shells using one CUDA block (i.e., 256 threads), whereas the STM algorithm performs the same computation using only a single CUDA thread. Consequently, the computation time for such ERIs increases significantly, creating a computational bottleneck and resulting in decreased performance. We also compare our proposed implementations with a (naive) CPU implementation (AMD EPYC 7702 processor), in which the Basis-ERIs are evaluated sequentially using the recursive formulae described in Section 3. To show the performance frontiers of the CPU-based implementations, Table 4 shows the obtained results. By observing the results in Table 4, we achieved a speedup of up to 4500x; however, in certain scenarios, the GPU implementation was slower compared to the CPU. The above-mentioned observations indicate that the overhead associated with parallelization outweighed the potential speedup achieved through GPU acceleration.