# A GPU-Accelerated Method for 3D Nonlinear Kelvin Ship Wake Patterns Simulation
## 4 GPU Parallel Computing Framework
### Parallel Computing Framework Design  
Compute Unified Device Architecture (CUDA) language is used to develop the numerical scheme for computing ship wave patterns. CUDA is a parallel computer platform and programming model developed by NVIDIA, powered by the GPU [23]. The CUDA toolkit includes abundant GPU-accelerated libraries, tools and a runtime library, which can be compiled in the C language, C++ language and Fortran language. In addition, the CUDA source program can be executed on multiple GPUs. By applying the hybrid programming  
Figure 5: The distribution of eigenvalues of \(\mathbf{J_{t}P^{-1}}\) on a \(31\times 11\) mesh for: \(band=1,band=11,band=21\).  
Figure 6: The plot of runtime against the bandwidth computed on a \(121\times 41\) mesh, \(band=b^{\prime}\times(N+1)\).  
model, the parallel computing process consists of a kernel function on the device and serial code on the host CPU. Figure 7 shows the CUDA execution mode and thread hierarchy.  
As for the solver of ship wave patterns, as described above, there are four main parts: building a preconditioner matrix, creating a nonlinear system, inverting a preconditioner matrix and solving linear equations by the GMRES algorithm. Simulation results of the CPU solver proposed by [PERSON] et al. [12] show that creating a nonlinear system and inverting a preconditioner matrix take up most of the time, as shown in Figure 8. This figure shows the computation time distribution of the CPU solver on a 151 \(\times\) 51 mesh case. The total runtime is 185.8 s, in which the runtime of the inverting preconditioner matrix and time requires for the creation of a nonlinear system is 95.8 and 80.4 s, respectively. Each of them takes up nearly half of the total runtime. Therefore, calculations on these two parts parallelly are vital for improving computational efficiency. And building the preconditioner matrix and solving linear equations will also be executed in a GPU to further shorten the program running time.  
Based on the above analysis, the GPU solver of Kelvin ship waves adopts a hybrid programming model. The entire parallel computing proced  
Figure 8: The computation time distribution of a ship wave solver. The alphabet I represents the step of inverting the preconditioner matrix, the alphabet C represents the step of creating a nonlinear system, the alphabet B represents the step of building a preconditioner matrix, the alphabet S represents the step of solving linear equations by the GMRES algorithm and the alphabet O represents the step of other codes in the solver.  
Figure 7: Illustration of CUDA execution mode and thread organization hierarchy [23].  
* Input calculation parameters including the initial guess; the data are transferred from the CPU to GPU;
* According to the calculation parameters, the nonlinear equations are created in the GPU device;
* The banded preconditioner method is applied to build the banded preconditioner matrix in the GPU;
* The QR decomposition algorithm is used to invert the preconditioner matrix, and it saves the decomposition results outside the loop body to avoid repeated QR decomposition of preprocessing;
* The result of \(\mathbf{P^{-1}}\boldsymbol{v}\) is calculated directly using the QR decomposition results; by combining the result of \(\mathbf{P^{-1}}\boldsymbol{v}\) with the approximate solution \(\boldsymbol{u}\) of the nonlinear equations, the finite difference approximation is carried out to obtain the linear equations;
* The GMRES algorithm is used to calculate the linear equations, obtain the correction values and update the approximate solutions \(\boldsymbol{u}\);
* Check the approximate solutions of the nonlinear equations: if the accuracy requirement is not met, back to step 5; if the accuracy requirement is met, the result is transferred from the GPU to the CPU.  
The corresponding calculation flow chart is shown in Figure 9, which shows the calculation procedure more clearly.  
Figure 9: The computational flow chart of GPU implementation.