# Accelerating Electromagnetic Field Simulations Based on Memory-Optimized CPML-FDTD with OpenACC
## 4 Simulation Settings and Results
### Free Space Propagation

Table 6: Execution times obtained using the RTX 3060 and Titan RTX, expressed in mm:ss, for the free space propagation. \begin{table}
\begin{tabular}{l l l l} \hline \hline
**Version** & **2.45 Ghz** & **5.00 Ghz** & **20.00 Ghz** \\ \hline CPU-MD (double) RTX 3060 & 1.00X & 1.00X & 1.00X \\ CPU-VD (double) RTX 3060 & 0.90X & 0.87X & 0.87X \\ GPU-MD (double) RTX 3060 & 5.06X & 5.28X & 5.30X \\ GPU-VD (double) RTX 3060 & 2.14X & 1.74X & 1.70X \\ GPU-MS (single) RTX 3060 & 11.27X & 10.31X & 11.64X \\ GPU-VS (single) RTX 3060 & 3.54X & 2.99X & 3.02X \\ GPU-MD (double) Titan RTX & 5.39X & 5.38X & 5.48X \\ GPU-VD (double) Titan RTX & 1.91X & 1.95X & 2.03X \\ GPU-MS (single) Titan RTX & 11.81X & 6.89X & 6.93X \\ GPU-VS (single) Titan RTX & 4.13X & 2.73X & 2.78X \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Speed-up factors calculated using as a base the utilized execution time by CPU-MD, for the open free space simulation. Figure 6: Free space propagation experiment. The orange dot indicates the position of the source, while green dots show the location of the control points. The simulation results for the 2.45 GHz case are depicted in Figure 10. Very similar results are obtained for the 5.00 GHz and 20.00 GHz cases. The purpose of using OpenACC is accelerating the execution. However, the quality of the solution obtained with the GPU should be verified. An advantage of the CPU over the GPU is its direct access to storage devices and much more flexible management of memory so that in the CPU, the information of the variables in points of interest can be recorded at each time step (viewers) but not in the GPU. Figure 8: Comparison between the computation times (\(\times\)10) obtained for propagation in open free space at 5.00 Ghz. Figure 7: Comparison between the computation times obtained for propagation in open free space at 2.45 Ghz. Figure 9: Comparison between the computation times (\(\times\)10) obtained for propagation in open free space at 20.00 Ghz. In Table 8 are shown the calculated MSE between the control points values of the CPU in double precision versus the fastest GPUs execution (single precision). It must take into account that the comparison between the control points is not at all time steps, since information is only transferred every certain number of time steps. Nevertheless, for a viewer, the solution was compared with the reference solution, which matches precisely when the values are copied to the CPU memory, validating the precision along the time Figure 11.  
Figure 11: Comparison of the solution along the time obtained in the GPU vs. CPU in viewer 3. Very similar solutions were obtained for viewers 1 and 2. The solution can only be compared when the information is transferred to the CPU. Figure 10: Snapshots of the electric field distribution (\(E_{z}\)) for the free space at 2.45 GHz frequency. (**A–C**) show the images at 150, 650, and 700 time-steps, respectively. The simulation was carried out during 1160 time steps. The numerical reliability of the fastest execution (GPU-MS), produced by the GPUs is compared with its sequential counterpart in the CPU. The most error-prone precision is the single-precision due to only has seven significant digits after the decimal point. Figure 12 show the absolute errors calculated for the last snapshots of the simulations. As can be observed, the error are in the expected range of \(10^{-6}\sim 10^{-7}\). The GPUs give exactly the same numerical solution.