# GPU-Accelerated Fock Matrix Computation with Efficient Reduction
## 5 Performance Evaluation
Table 5 demonstrates that using the proposed DAR (\(N_{\text{Fock}}=64\)) significantly reduced atomicAdd conflicts across all kernels. The average number of cycles each warp stalled was reduced by up to 84.8%, resulting in a 64.8% reduction in total cycles. Additionally, reducing memory contention with the proposed DAR improved memory access efficiency. The reduction in atomicAdd conflicts enabled more effective utilization of the previously bottlenecked memory bandwidth, resulting in up to a 2.82\(\times\) improvement in L2 cache throughput. Finally, we briefly discuss the relationship between our proposed method and existing GPU-accelerated Fock matrix construction schemes as implemented in established quantum chemistry software. TeraChem [42,43] implements ERI calculations based on the same primitive shell as our data structure, constructing the Fock matrix by building the \(\mathbf{J}\)- and \(\mathbf{K}\)-matrices separately. For the \(\mathbf{J}\)-matrix construction, atomic operations are avoided by allocating separate GPU memory to each GPU kernel. However, for the \(\mathbf{K}\)-matrix, algorithms requiring atomicAdd operations have been considered, and this has been identified as a factor in performance degradation. We speculate that QUICK [14,44] \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**ERI Types**} & **\#Fock Replicas** & **Stall** & **Warp** & **Stall/Warp** & **L2 Cache** \\  & \(\mathbf{N_{\text{Fock}}}\) & **[cycles]** & **[cycles]** & **[\%]** & **[Gyte/s]** \\ \hline \multirow{3}{*}{\([\text{ss}|\text{ss}]\)} & 1 & 5.3 & 12.9 & 41.2 & 467.75 \\  & 64 & 3.0 & 9.3 & 31.9 & 689.54 \\ \cline{2-6}  & & \(-\)43.4\% & \(-\)27.9\% & \(-\)9.3 pp & 1.47\(\times\) \\ \hline \multirow{3}{*}{\([\text{ss}|\text{sp}]\)} & 1 & 23.1 & 31.5 & 73.4 & 626.25 \\  & 64 & 3.5 & 11.1 & 31.7 & 1763.09 \\ \cline{2-6}  & & \(-\)84.8\% & \(-\)64.8\% & \(-\)41.7 pp & 2.82\(\times\) \\ \hline \multirow{3}{*}{\([\text{ss}|\text{pp}]\)} & 1 & 10.6 & 16.1 & 65.6 & 1003.10 \\  & 64 & 2.9 & 8.5 & 34.2 & 1850.04 \\ \cline{2-6}  & & \(-\)72.6\% & \(-\)47.2\% & \(-\)31.4 pp & 1.84\(\times\) \\ \hline \multirow{3}{*}{\([\text{sp}|\text{sp}]\)} & 1 & 26.5 & 33.4 & 79.2 & 1020.25 \\  & 64 & 9.6 & 16.3 & 58.7 & 2169.42 \\ \cline{2-6}  & & \(-\)63.8\% & \(-\)51.2\% & \(-\)20.5 pp & 2.13\(\times\) \\ \hline \multirow{3}{*}{\([\text{sp}|\text{pp}]\)} & 1 & 10.7 & 16.3 & 65.6 & 1182.57 \\  & 64 & 2.6 & 8.3 & 31.6 & 2242.28 \\ \cline{2-6}  & & \(-\)75.7\% & \(-\)49.1\% & \(-\)31.4 pp & 1.90\(\times\) \\ \hline \multirow{3}{*}{\([\text{pp}|\text{pp}]\)} & 1 & 4.8 & 12.5 & 38.0 & 1303.60 \\  & 64 & 2.8 & 8.6 & 32.8 & 1811.86 \\ \cline{2-6}  & & \(-\)41.7\% & \(-\)31.2\% & \(-\)5.2 pp & 1.39\(\times\) \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Profiling results of each CUDA kernel for the ERI task matrix in azobenzene (C\({}_{12}\)H\({}_{10}\)N\({}_{2}\)) with 6-311G basis set. and GPU4 PySCF [45; 46] implement the Fock matrix construction based on contracted shell structures. A contracted shell is a set of basis functions sharing the same total angular momentum \(L\) and orbital center \(\mathbf{A}\), allowing the aggregation in Equation (14) to be performed without atomic operations. This significantly reduces the number of atomicAdd operations, but the \(O(M^{4})\) contracted ERIs typically need to be added to the Fock matrix exclusively. Thus, the memory contention caused by atomicAdd operations remains a challenge in current GPU implementations. Our replicated Fock matrix approach is simple and independent of the ERI evaluation and complex data structures, suggesting it could improve these existing GPU implementations. Furthermore, combining our DAR method with other techniques such as the thread-local reduction [20; 27] has been experimentally shown to further improve the Fock matrix construction performance. We emphasize that our proposed method does not compete with existing GPU implementations but rather has the potential to enhance them.