# Accelerating Electromagnetic Field Simulations Based on Memory-Optimized CPML-FDTD with OpenACC
###### Abstract  
Although GPUs can offer higher computing power at low power consumption, their low-level programming can be relatively complex and consume programming time. For this reason, directive-based alternatives such as OpenACC could be used to specify high-level parallelism without original code modification, giving very accurate results. Nevertheless, in the FDTD method, absorbing boundary conditions are commonly used. The key to successful performance is correctly implementing the boundary conditions that play an essential role in memory use. This work accelerates the simulations of electromagnetic wave propagation that solve the Maxwell curl equations by FDTD using CMPL boundary in TE mode using OpenACC directives. A gain of acceleration optimizing the use of memory is shows, checking the loops intensities, and the use of single precision to improve the performance is also analyzed, producing an acceleration of around 5X for double precision and 11X for single precision respectively, comparing with the serial vectorized version, without introducing errors in long-term simulations. The scenarios of simulation established are common of interest and are solved at different frequencies supported by a Mid-range cards GeForce RTX 3060 and Titan RTX. CPML; FDTD; Maxwell; OpenACC Article  
Accelerated: 6 November 2022  
10 November 2022  
**Volitecnico:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. **Volitecnico:** 10 November 2022  
that can decrease the performance [9]. Having the right design is essential for acceleration success, so to take advantage of the GPU, the code has to be highly parallel. If this is the case, the FDTD algorithm is very parallelizable [10; 11]. OpenACC is a reliable standard tool for the design of parallel programs for GPU [12]. For this reason some applications have been accelerated using OpenACC, for example, materials modeling [13], Computational Fluid Dynamics Frameworks [14], Mixing Layer Simulation [15], Neural Networks [16], High-order spectral element fluid dynamics solver [17], supersonic flow simulation [18], indoor propagation [19], among some others. Over the last few years, there have been multiple research projects involving the FDTD method concerning its complexity, meshing techniques, and computing time; for example, the use of a spatially filtered FDTD via a subgridding technique to analyze multiscale objects [20]. Similar studies approach the same issue by utilizing space transformations to overcome the conventional FDTD issues in a complex domain [21]. Another approach for this problem is made in [22], where the authors propose a stable, accurate, and fast numerical method by arranging a triangular mesh and using space transformations for electrodynamics problems with arbitrary boundaries. In the same sense, implicit forms of the FDTD have been applied [23; 24; 25]. This shows that there is constant research to obtain improved techniques for the calculation of electromagnetic characteristics in microwave devices, therefore proving to be an essential and relevant scientific problem. For the relevance of the FDTD, many researchers have developed their own codes for specific applications. However, the FDTD is very computing time-consuming. Hence it is necessary to accel the execution time. Waiting for a week for simulation results implies undesirable idle times. This research shows how an own-developed code in FORTRAN can be accelerated using OpenACC directives to reduce the wait time for a simulation. It is necessary because the simulations consume too much time. Being a 2D application is unsuitable for OpenMP because it is memory bound, and a multi-thread CPU implementation doesn't scale; consequently, the exec time is not reduced. This can be analyzed through the computational intensity, which is relatively low, so it is more suitable for a GPU architecture.