## 2 Materials and Methods
### Analysis of the Different Alternatives  
Off-line analysis of data using software tools such as MATLAB and programming languages such as Python are widespread in the scientific community [16]. Nevertheless, an alternative programming and deployment alternative must be used when a reduced execution time is needed to implement the algorithm in a real-time experiment (for example, in a nuclear fusion-related diagnostic) [17]. In addition, the use of graphical processing units (GPUs) has emerged as a powerful solution for massive data processing, especially in image processing with 1D or 2D detectors and cameras [18; 19].  
There are two different actions intended to reduce algorithm execution time. Firstly, the algorithm's steps must be identified, and secondly, the optimization options need to be evaluated. The methodology used to accelerate the algorithm execution follows these steps:  
* MATLAB code analysis, which has an extension of approximately 2500 lines. This code uses high-level functions from MATLAB's toolboxes that solve curve fitting, 1D and 2D interpolations, and median and Gaussian image filtering. Unfortunately, from most parts of these functions, MathWorks does not provide the source code, complicating the implementation of the final solution.
* The code profiling analysis with the specific MATLAB tool to identify the time needed to execute the different algorithm phases. The algorithm is based on executing several configurable iterations, and the execution time depends on this.
* The analysis of the different options to shorten the execution time of the different code sections according to two different scenarios:
* Use of MATLAB:
* Use of MATLAB Executable Files (MEX);
* Use of parallel computing toolbox;
* Use of MATLAB-optimized libraries;
* Using GPUs in MATLAB (not all functions support GPU acceleration, and using GPU arrays in MATLAB is not efficient if the arrays are small).
* Use of other programming languages, rewriting the code in C++ with the help of optimized libraries for heterogeneous platforms:
* CPU: ArrayFire, ALGLIB, libigl, armadillo, Intel MKL, IPP;
* GPU: ArrayFire, CUDA (NVCC compiler, cuBLAS libraries, etc.);  
Figure 7: Final radiation profile as a function of the flux function \(\psi\in[0,1]\).  
FPGA: Use of IntelFPGA/XILINX acceleration techniques.
* Identification and selection of the most suitable hardware platform to accelerate a specific portion of the algorithm. Due to some functions' complexity, the most suitable hardware is considered to be a heterogeneous solution using an Intel multicore CPU and an NVIDIA GPU.
* Selection of the software to be used for the implementation considered criteria such as being Open Source, the best performance for CPU or GPU, and the possibility of using different programming languages.  
Upon all these criteria, after a deep analysis, the solution was implemented by building a C++ application using the ArrayFire [20], ALGLIB [21], and MATIO [22] libraries, running in a commercial off-the-shelf (COTS) industrial computer with an Intel(r) CoreTM ip 10980 XE CPU @ 3 GHz, 128 GiB of RAM, and an NVIDIA RTX2080 SUPER GPU. The operating systems used for the development and testing were: Ubuntu 18.04 LTS and a REDHAT 7.4 with the ITER CODAC Core System version 6.3 installed.  
The basic description of the libraries selected is explained in the following paragraphs.