# GPU-Accelerated Fock Matrix Computation with Efficient Reduction
## 5 Performance Evaluation  
We evaluated the performance of the Fock matrix construction method proposed in Section 4 through numerical experiments using various molecules and basis sets as inputs. Our primary contribution, the Distributed Atomic Reduction method (DAR: Section 4.2) builds upon the GPU parallelization of ERIs explained in Section 4.1. First, we examined the influence of the proposed DAR on the accuracy of the computed RHF energies using several molecules. Subsequently, we measured the total computation time including both evaluating ERIs and updating the Fock matrix in a single SCF iteration. Our DAR can be combined with the Thread-Local Reduction (TLR: Section 4.3) technique employed in previous work [20; 27], and we also compared the computation time when using TLR in conjunction with DAR. In addition to measuring the computation time for the Fock matrix construction, we also profiled each CUDA kernel using Nsight Compute. Based on the \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline  & **Destination** & \([\mathbf{ss}|\mathbf{ss}]\) & \([\mathbf{ss}|\mathbf{sp}]\) & \([\mathbf{ss}|\mathbf{pp}]\) & \([\mathbf{sp}|\mathbf{sp}]\) & \([\mathbf{sp}|\mathbf{pp}]\) & \([\mathbf{pp}|\mathbf{pp}]\) \\ \hline \multirow{6}{*}{Reduction rate} & \(F_{\mu\
u}\) & 1 & 1/3 & 1/9 & 1/3 & 1/9 & 1/9 \\  & \(F_{\lambda\
u}\) & 1 & 1 & 1 & 1/3 & 1/3 & 1/9 \\  & \(F_{\mu\lambda}\) & 1 & 1/3 & 1/3 & 1/9 & 1/9 & 1/9 \\  & \(F_{\
u\
u}\) & 1 & 1 & 1/3 & 1 & 1/3 & 1/9 \\  & \(F_{\mu\
u}\) & 1 & 1 & 1/3 & 1/3 & 1/9 & 1/9 \\  & \(F_{\
u\lambda}\) & 1 & 1/3 & 1/3 & 1/3 & 1/3 & 1/9 \\ \hline \#Additional register variables & 0 & 3 & 16 & 16 & 36 & 54 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Reduction rate of the atomicAdd operations achieved by thread-local reduction and the associated increase in register usage. profiles, we discuss how the proposed method for avoiding atomicAdd conflicts contributes to reducing memory contention. Our GPU implementation has been developed by the CUDA version 11.2 and C++17 compiled with GCC version 10.5.0, using an A100 Tensor Core GPU (NVIDIA, Santa Clara, CA, United States) with 80 GB device memory and a Xeon Gold 6338 CPU (Intel, Santa Clara, CA, United States). The cutoff threshold for Schwarz screening was set to \(\theta=1.0\times 10^{-12}\). The computation time was measured with 256 threads per CUDA block. Performance was compared by doubling the number of Fock matrix replicas \(N_{\text{Fock}}\), from 1 to 256. The case of \(N_{\text{Fock}}=1\) corresponds to the conventional approach where atomicAdd operations concentrate on a single Fock matrix, and it serves as the baseline. In parallel processing, such as GPU computing, the order of floating-point operations like addition and subtraction can vary, potentially affecting the accuracy of computed results. Our proposed DAR method computes the Fock matrix by accumulating integral values into multiple Fock replicas and then summing these replica matrices. This alters the order of floating-point operations compared to the standard implementation, which directly constructs the single Fock matrix. We numerically examined whether this change in operation order introduces any loss of accuracy due to effects such as cancellation of significant digits. Table 2 shows the converged energies in the Restricted Hartree-Fock (RHF) method for different numbers of Fock replicas using our DAR method. In this experiment, the convergence criterion for the SCF procedure is set to an energy difference of less than \(1.0\times 10^{-10}\). For all molecules in the table, the maximum absolute error in the RHF energy due to the use of DAR is of the order of \(10^{-11}\) or less, indicating that the proposed method has a negligible impact on the convergence of the SCF procedure. Tables 3 and 4 present the computation times for the Fock matrix construction on a GPU. These results are for small molecules with the 6-31G basis set and medium-sized molecules with the STO-3G basis set, respectively.