# A Novel GPU-Based Acceleration Algorithm for a Longwave Radiative Transfer Model
## 5 Algorithm Implementation
### trrnmc_d
Because of discontinuous access for these arrays using a do-loop form, the transposition cost too much time. However, the _inatm_ with an acceleration in the _g-point_ dimension has no do-loops, as shown in Algorithm 6, so it can show an excellent performance improvement. 3. There are \(11\) kernels in the current _rtrnmc_, but only two of them have a composite decomposition in the horizontal, vertical and _g-point_ dimensions. The two kernels only cost about 17% computational time, so the current _rtrnmc_ did not achieve a noticeable performance improvement compared with its 1D version. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Subroutines** & **CPU Time (S)** & **K20 Time (S)** & **Speedup** \\ \hline _inatm_ & 150.48 & 18.2060 & 8.27 \\ _cldpmc_ & 5.27 & 0.0020 & 2635.00 \\ _setcoef_ & 14.52 & 0.3360 & **43.21** \\ _taumol_ & 169.68 & 4.1852 & **40.54** \\ _rtrnmc_ & 252.80 & 21.5148 & 11.75 \\ _rtrng\_Iw_ & 647.12 & 44.2440 & **14.63** \\ \hline
**Subroutines** & **CPU Time (S)** & **K40 Time (S)** & **Speedup** \\ \hline _inatm_ & 150.48 & 14.9068 & 10.09 \\ _cldpmc_ & 5.27 & 0.0020 & 2635 \\ _setcoef_ & 14.52 & 0.2480 & **58.55** \\ _taumol_ & 169.68 & 3.1524 & **53.83** \\ _rtrnmc_ & 252.80 & 16.6292 & 15.20 \\ _rtrng\_Iw_ & 647.12 & 34.9384 & **18.52** \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Runtime and speedup of the RRTMG_LW 2D acceleration algorithm on one GPU. Here, the block size = 128 and _ncol_ = 2048; _inatm_, _cldpmc_, and _rtrnmc_ are with a 1D decomposition; _setcoef_ and _taumol_ are with a 2D decomposition. \begin{table}
\begin{tabular}{c} \hline \hline
**if**((iplon\(\geq\)1. **and.** iplon\(\leq\)ncol) **and.** (lay\(\geq\)lxtrop(iplon)+1 **and.** lay\(\leq\)nlayers) **and.** (ig\(\geq\)1 **and.** ig\(\leq\)ngl)) then \\ \(\text{ind0\_1}\) = ((ip(iplon, lay) - 13) * 5 + (if(iplon, lay) - 1)) * nspb(1) + 1 \\ \(\text{ind1\_1}\) = ((ip(iplon, lay) - 12) * 5 + (if(iplon, lay) - 1)) * nspb(1) + 1 \\ \(\text{ind1\_1}\) = \(\text{indrr(iplon, lay)}\) \\ \(\text{indm\_1}\) = \(\text{indrr(iplon, lay)}\) \\ \(\text{pp\_1}\) = \(\text{pavel(iplon, lay)}\) \\ \(\text{corradij\_1}\) = \(1\)\text{\_r8} - \(0.15\)\text{\_r8} * (pp\_1 / 95.6\)\text{\_r8}) \\ \(\text{scalen2\_1}\) = \(\text{colbrd(iplon, lay)}\) * scaleminorn2(iplon, lay) \\ \hline \hline \end{tabular}
\end{table} 
Table 3: A piece of code in _taumol_. When compared to its counterpart running on 10 CPU cores of an Intel Xeon E5-2680 v2, the speedup of the G-RRTMG_LW on the K20 GPU is shown in Table 5. In this case, using one K20 GPU in the case without I/O transfer, the G-RRTMG_LW achieved a speedup of 2.35\(\times\). This shows that running the RRTMG_LW on one K20 GPU still has a better computing performance than on 10 cores of a CPU. ### I/O Transfer

I/O transfer between the CPU and GPU is inevitable. The runtime and speedup of the G-RRTMG_LW with I/O transfer on the K20 and K40 GPUs are shown in Table 6. The I/O transfer time on the K20 cluster was 61.39 s, while it was 59.3 s on the K40 cluster. Using one K40 GPU in the case with I/O transfer, the G-RRTMG_LW achieved a speedup of 8.07\(\times\). Some conclusions and analysis are drawn below. (1) In the simulation with one model day, the RRTMG_LW required integral calculations 24 times. During each integration for all 128\(\times\)256 grid points, the subroutine \(rrtmg\_lw\) had to be invoked 16 (128\(\times\)256/\(ncol\)) times when \(ncol\) is 2048. Due to the memory limitation of the GPU, the maximum value of \(ncol\) on the K40 GPU was 2048. This means that the G-RRTMG_LW was invoked repeatedly 16\(\times\)24 = 384 times in the experiment. For each invocation, the input and output of the 3D arrays must be updated between the CPU and GPU, so the I/O transfer incurs a high communication cost. (2) The computational time of the G-RRTMG_LW in the case without I/O transfer was fairly short, so the I/O transfer cost exhibited a huge bottleneck for the maximum level of performance improvement of the G-RRTMG_LW.