# Using a GPU to Accelerate a Longwave Radiative Transfer Model with Efficient CUDA-Based Methods
## 4 GPU-Enabled Acceleration Algorithms
### Acceleration Algorithm with Two-Dimensional Domain Decomposition
Some conclusions and analysis are drawn as follows. 1. In the same way, the K40 GPU had stronger computing power than the K20 GPU, the 2-D G-RRTMG_LW on the K40 GPU showed better performance. 2. The 2-D _setcoef_ and _taumol_ showed excellent performance improvements compared to their 1-D versions, especially _taumol_. There was no data dependence in _taumol_ with intensive computing, so a finer-grained parallelization of _taumol_ was executed when more threads were used. ### I/O Transfer

I/O transfer between CPU and GPU is inevitable. The run-time and speedup of the 2-D G-RRTMG_LW with I/O transfer on the K20 and K40 GPUs are shown in Table 4. The I/O transfer times on the K20 cluster were 61.39 s and, on the K40 cluster, was 59.3 s. Using one K40 GPU in the case with I/O transfer, the 2-D G-RRTMG_LW achieved a speedup of 6.87\(\times\). Some conclusions and analysis are drawn as follows. 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_1w_ must 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 2-D G-RRTMG_LW was invoked repeatedly 16 \(\times\) 24 = 384 times in the experiment. For each invocation, the input and output of the three-dimensional arrays must be updated between the CPU and GPU, so the I/O transfer incurs a high communication cost. \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 \\ _cldpmcc_ & 5.27 & 0.0020 & 2635.00 \\ _setcoef_ & 14.52 & 0.3360 & **43.21** \\ _taumol_ & 169.68 & 4.1852 & **40.54** \\ _rrtmc_ & 252.80 & 21.5148 & 11.75 \\ _rrtmg_1w_ & 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** \\ _rrtmmc_ & 252.80 & 16.6292 & 15.20 \\ _rrtmg_1w_ & 647.12 & 34.9384 & **18.52** \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Run-time and speedup of the 2-D G-RRTMG_LW on one GPU, where the block size = 128 and _ncol_ = 2048. After the 2-D acceleration for the RRTMG_LW, its computational time in the case without I/O transfer was fairly shorter, so the I/O transfer cost was a huge bottleneck for the maximum level of performance improvement of the G-RRTMG_LW. In the future, compressing data and improving network bandwidth will be beneficial for reducing this I/O transfer cost. ### Discussion

1. The WRF RRTMG_LW on eight CPU cores achieved a speedup of 7.58\(\times\) compared to its counterpart running on one CPU core [28]. Using one K40 GPU in the case without I/O transfer, the 2-D G-RRTMG_LW achieved a speedup of 18.52\(\times\). This shows that the RRTMG_LW on one GPU can still obtain a better performance improvement than on one CPU with eight cores. 2. The RRTM_LW on the C2050 obtained an 18.2\(\times\) speedup [13]. This shows that the 2-D G-RRTMG_LW obtained a similar speedup with the RRTM_LW accelerated in CUDA Fortran. 3. The CUDA Fortran version of the RRTM_LW in the GRAPES_Meso model obtained a 14.3\(\times\) speedup [27], but the CUDA C version of the RRTMG_SW obtained a 202\(\times\) speedup [31]. The reasons are as follows. (a) [PERSON] et al. ran the original serial RRTM_LW on Intel Xeon 5500 and ran its GPU version on NVIDIA Tesla C1060. [PERSON] et al. ran the original serial RRTMG_SW on Intel Xeon E5-2603 and ran its GPU version on NVIDIA K40. Xeon 5500 has higher computing performance than Xeon E5-2603. Moreover, K40 has higher computing performance than Tesla C1060. Therefore, [PERSON] et al. obtained higher speedup. (b) [PERSON] et al. used CUDA Fortran to write the GPU code. [PERSON] et al. used CUDA C to write the GPU code.