# A Neural Network-Inspired Matrix Formulation of Chemical Kinetics for Acceleration on GPUs
## 3 GPU Performance Analysis
### Speedup  
The corresponding GPU speedup curves are shown in Figure 6 in both logarithmic (left) and linear (right) scales. The CPU baseline from which the speedup is derived is the C++ Cantera function getNetProductionRates evaluated with one MPI rank. The speedup is intended to capture the tangible offloading effect for a single MPI rank (or OpenMP thread) in the common case of a one-to-one correspondence between MPI process and GPU. Although the Cantera CPU baseline does not present the fairest comparison here (the arithmetic operations in Cantera are not vectorized in the same way as those defined in Section 2.1), it is routinely used in numerical reacting flow simulations for kinetics and thermodynamics routines. As such, using this baseline to derive the GPU speedup provides valuable information on the practical impact of a CPU-to-GPU offload for many existing applications that use Cantera or comparable libraries such as Chemkin. Although the CPU reference values used to compute the speedup in Figure 6 come from the Cantera functions, the matrix-based forms were also evaluated on the CPU to assess the effect of the Cantera implementations on the perception of GPU speedup. It was found that for the same mechanisms, the matrix-based formulations implemented on the CPU provided roughly a factor of 2 speedup over the CPU-based Cantera functions for most cell counts. In other words, the GPU speedup discussed below drops by roughly a factor of 2 when comparing against the matrix-based formulation on the CPU instead of the Cantera function, though the saturation trends remain the same. To reiterate, the speedups themselves are secondary to the relative trends displayed between the individual reaction mechanism curves. As shown in Figure 6, the speedup increases linearly with cell number until the saturated regime is reached, wherein the speedup stagnates at reasonably high values across the board. This general trend is expected since the saturated regime is defined by a GPU compute time that increases linearly with \(N_{\text{C}}\) (Figure 4). The consequence is that the maximum speedup is reached for lower values of \(N_{\text{C}}\) as mechanism complexity increases, as per the location of the saturation point. The converged speedup values are high overall, varying between \(100\times\) to \(500\times\) at their maximum. However, due to the dependence on the CPU implementation, the mechanism trends with respect to speedup are not as intuitive as those present in the absolute compute time curves of Figure 4. For instance, the pre-saturated regime (e.g., \(N_{\text{C}}=10\)) shows increasing speedup with mechanism complexity, but this trend is absent in the saturated regime. Instead, in the saturated regime, the behaviors can be split into two groups. The first group concerns mechanism Classes A and B, which concentrate in the regions of 400-500\(\times\) speedup. For these mechanisms the speedup trends are related directly to the reaction mechanism distributions seen in Figure 3. In other words, for Classes A and B, similar distribution types converge to similar saturated speedups. For example, Mechanisms B1 and B3 converge near 500\(\times\) and observe near-identical reaction distributions--the same is true for Mechanisms A1 and B2, which converge near 400\(\times\). The implication is that the GPU based speedup relies not only on the number of reactions, but also on reaction types encountered in the mechanism. This is the central focus of Section 3.3. The second group is tied to the larger mechanisms of Class C, where the aforementioned trends break down. Though still high, the saturated speedups in Figure 6 progressively drop from C1 to C2. This drop relates directly to the connection between: (a) the presence of the overbearing reaction matrix (\(N_{C}\times N_{R}\) matrix) multiplications encountered in Equation (2), which constitute a bottleneck for large mechanisms; and (b) the mechanism sparsity as measured by the number of elements in the matrix \(\
u\).