# GPU-Accelerated Fock Matrix Computation with Efficient Reduction
## 3 Related Works
Schwarz screening is performed before computing ERIs on the GPU, avoiding conditional branching in device codes and enhancing parallel computation performance. Furthermore, a double-stream ERI reduction method exploited the eight-fold symmetry while avoiding explicit thread synchronization overhead. The following year, [PERSON] et al. [20] extended their work to a GPU implementation of the entire SCF procedure, including one-electron integrals, and further scaled it to multiple GPUs. The dynamic load balancing for ERI evaluation was adapted for multi-GPU environments, and hierarchical memory usage was optimized to improve memory bandwidth utilization. For the reduction in Equation (24), thread-local GPU registers were used as buffers to accumulate intermediate values, significantly reducing the number of atomic operations required for updates to the Fock matrix in global memory. However, a challenge arises with the ERI kernels for high angular momentum, where the register usage increases, leading to decreased GPU occupancy and memory access efficiency. In 2023, [PERSON] et al. [24] explored a heterogeneous computing approach to assemble the Fock matrix using a hybrid of CPUs and GPUs. A global task queue was employed to dynamically assign low angular momentum ERIs to the GPU and high angular momentum ERIs to the CPU. While the CPU implementation fully exploits the eight-fold symmetry of ERIs, the GPU implementation, similar to the approach by [PERSON] et al. [12], computes the \(\mathbf{J}\)- and \(\mathbf{K}\)-matrices separately to avoid memory contention from atomic operation during the Fock matrix updates. In 2024, [PERSON] et al. [27] developed two optimized algorithms, \"opt-UM\" and \"opt-Brc\", building upon the work of [PERSON] et al. [12] and [PERSON] et al. [20], respectively. The opt-Brc algorithm fully utilizes the eight-fold symmetry of ERIs using Equation (24) and reduces atomic operations by partially performing ERI reductions in thread-local GPU registers. In the opt-UM algorithm, the \(\mathbf{J}\)- and \(\mathbf{K}\)-matrices are computed separately. For \(\mathbf{J}\)-matrix construction, a warp-wise reduction using shared memory is employed. For \(\mathbf{K}\)-matrix construction, the number of ERIs computed was significantly reduced by utilizingthe exponential decay of density matrix elements with increasing the distance between basis functions. Both algorithms incorporate screening based not only on the Schwarz upper bound but also on the density matrix. While the reduction of ERIs in the Fock matrix construction has been refined over the years, the use of atomic operations remains unavoidable in parallel computations on both CPUs and GPUs. Particularly when exploiting the eight-fold symmetry of ERIs using Equation (24), the memory contention issue caused by atomic operations from a large number of threads remains unresolved. Previous studies have primarily focused on reducing the number of atomic additions to the Fock matrix, achieving this through techniques such as the reduction of thread-local buffers. However, on GPUs with higher parallelism compared to CPUs, the number of ERIs that can be aggregated per thread is limited. Even with the thread-local partial reduction, \(O(M^{4})\) atomic operations persist in updating the Fock matrix using GPUs, and these operations concentrate on a small memory space of \(O(M^{2})\). To address this, we avoid the memory contention by distributing the addresses accessed by each thread rather than reducing the number of atomic operations.