# 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
Copy input data to GPU device //Call \(\mathit{inatm\_d1}\) with 2-D decomposition
2. call\(\mathit{inatm\_d1\ll graft}\),\(\mathit{tBlock\gg\)(parameters) //Call \(\mathit{inatm\_d2}\) with 2-D decomposition
3. call\(\mathit{inatm\_d2\ll graft}\),\(\mathit{tBlock\gg\)(parameters) //Call \(\mathit{inatm\_d3}\) with 1-D decomposition
4. call\(\mathit{inatm\_d3\ll m},n\gg\)(parameters) //Call \(\mathit{inatm\_d4}\) with 2-D decomposition
5. call\(\mathit{inatm\_d4\ll graft}\),\(\mathit{tBlock\gg\)(parameters) //Call \(\mathit{cldprmc\_d}\) with 1-D decomposition
6. call\(\mathit{cldprmc\_d\ll m},n\gg\)(parameters) //Call \(\mathit{setcoef\_d1}\) with 2-D decomposition
7. call\(\mathit{setcoef\_d1\ll graft},\mathit{tBlock\gg\)(parameters) //Call \(\mathit{setcoef\_d2}\) with 1-D decomposition
8. call\(\mathit{setcoef\_d2\ll m},n\gg\)(parameters) //Call \(\mathit{taumol\_d}\) with 2-D decomposition
9. call\(\mathit{taumol\_d\ll graft}\),\(\mathit{tBlock\gg\)(parameters) //Call \(\mathit{rtrmmc\_d}\) with 1-D decomposition
10. call\(\mathit{rtrmmc\_d\ll m},n\gg\)(parameters)
```  
**Algorithm 4**CUDA-based acceleration algorithm of RRTMG_LW with 2-D domain decomposition and the implementation of 2-D G-RRTMG_LW. ```
```
```

```
```
```  
```
```
```

```
```
```  
```
```
```

```
```
```  
```
```
```

```
```

## 5 Result and Discussion

To fully investigate the parallel performance of the proposed acceleration algorithms described above, an ideal climate simulation experiment for one model day was conducted. The time step of the RRTMG_LW in the experiment was 1 h.

### Performance of 1-D G-RRTMG_LW

#### 5.1.1 Influence of Block Size

The run-time of the serial RRTMG_LW on one core of an Intel Xeon E5-2680 v2 processor is shown in Table 2. Here, the computing time of the RRTMG_LW on the CPU or GPU, \(T_{rtrng\_lw}\), is calculated by the following formula:

\[T_{rtrng\_lw}=T_{inatm}+T_{cldprmc}+T_{setcoef}+T_{taumol}+T_{rtrtnmc},\]

where \(T_{inatm}\) is the computing time of the subroutine \(inatm\) or kernel \(inatm\_d\) and where \(T_{cldprmc},T_{setcoef},T_{taumol}\), and \(T_{rtrmmc}\) are the corresponding computing time of the other kernels. To explore whether/how the number of threads in a thread block may affect the computation performance for a given scale, the execution time of the G-RRTMG_LW with a tuned number of threads was measured over one GPU. Taking the case of no I/O transfer as an example, Figure 5 portrays the run-time of the 1-D G-RRTMG_LW on one K20 GPU. Indeed, the number of threads per block or block size affected the computation performance to some extent. The G-RRTMG_LW achieved optimal performance when block size was 16. The G-RRTMG_LW on one K40 GPU resulted in a similar rule, as shown in Figure 6. Some conclusions and analysis are drawn as follows. 1. Generally speaking, increasing the block size can hide memory access latency to some extent and can improve the computational performance of parallel algorithms. Therefore, kernels with simple computations usually show optimal performance when the block size is 128 or 256. 2. The kernel \(taumol\) with a large amount of calculation achieved optimal performance when the block size was 16. With the increment of the block size, its computational time increased as a whole. During the 1-D acceleration of \(taumol\), each thread with a large amount of calculation produced numerous temporary and intermediate values, which consumed a great deal of hardware resources. Due to limited hardware resources, each thread will have fewer resources if the block size is larger. Therefore, along with the increase of the block size, the speed of \(taumol\) will be slower. Figure 5: Run-time of the 1-D G-RRTMG_LW on one K20 GPU.