# A Layered Method Based on Depth of Focus for Rapid Generation of Computer-Generated Holograms
## 3 Performance
This is easy to explain because both methods have a separate computation that needs to be performed for each triangle, and the computational effort for this part of the computation is not affected by factors such as the shape or size of the triangles, so the computational effort grows linearly with the number of triangles. To further increase the computational speed of the proposed method, using GPU parallel computing was considered. Therefore, the parallelized program of the proposed method and the parallelized program of the resolved polygon method were implemented through CUDA C++ for comparison. The GPU used was the NVIDIA GeForce RTX 3060 Laptop GPU. The experimental platform, development environment, and experimental parameters were the same as those of the computational performance experiment on the CPU above. The experimental results are shown in Table 4 and Figure 8. Table 4 shows the computational time consumption of the proposed method and the analytical polygon-based method, as well as the ratio of the time consumption of the analytical polygon-based method to that of the proposed method when computed on a GPU. Figure 8 shows the change in computation time with the number of triangles for both methods when computed on a GPU. The proposed method experiences a more efficient computation on GPUs; generating a hologram of 30,000 triangles only takes about 0.5 s. Further, the acceleration ratio of the proposed method over the analytic polygon-based method gradually increases as the number of triangles increases. This indicates that the computational efficiency of the analytic polygon-based method is more sensitive to the number of triangles. In contrast, the proposed method is less affected by the number of triangles. This is mainly because \begin{table}
\begin{tabular}{c c c c} \hline \hline
**The Number of** & **The Proposed** & \multicolumn{2}{c}{**The Analytical**} & \multirow{2}{*}{**Acceleration Ratio**} \\
**Triangles** & **Method** & **Polygon-Based Method** & \\ \hline
4704 & 0.33 s & 4.83 s & 14.64 \\
9408 & 0.36 s & 9.45 s & 26.25 \\
14,112 & 0.41 s & 14.17 s & 34.56 \\
18,816 & 0.45 s & 18.85 s & 41.89 \\
23,520 & 0.49 s & 23.54 s & 48.04 \\
28,224 & 0.53 s & 28.31 s & 53.42 \\
32,928 & 0.57 s & 33.05 s & 57.98 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Comparison of time consumption between two methods on a GPU. Figure 8: The curve depicting the relationship between the time taken and the number of triangles for two different methods on a GPU. GPUs are good at simple operations such as addition and subtraction, while they are weak at complex operations such as calculating sine, cosine, and exponentials. There are a lot of complex exponential operations used in the analytic polygon-based method, which is the shortcoming of the GPU. In the proposed method, only the hierarchical projection is involved in the number of triangles. These calculations can be performed using basic mathematical calculations only and can be highly parallelized. Therefore, the proposed method can perform the computations extremely fast on GPUs. However, since this method is an approximation, it is more suitable for scenarios that require high computational speed but lower accuracy requirements. It is worth noting that the computation speed of the proposed method is not solely dependent on the number of triangles in the input object. This is because the method includes calculations such as the fast Fourier transform for each layer, meaning that the computation speed is also related to the number of layers into which the three-dimensional object is divided. The depth of focus and the length of the object determine the number of layers, while the depth of focus is related to the wavelength of light, the LCOS (liquid crystal on silicon) size, and the diffraction distance, all physical parameters that will affect the calculation speed of the proposed method. However, the number of triangles remains the main factor affecting the calculation speed.