Performance Test: Verified, faster execution time using emmtrix Code Generator
May 27, 2020
Developers and engineers using MATLAB to solve scientific problems can use the MATLAB Coder to compile MATLAB Scripts to C-Code. However, generating C-Code for multicore systems requires further sophisticated optimization and transformation steps. emmtrix Code Generator (eCG) is primarily designed to optimize and generate C-Code for subsequent parallelization steps in emmtrix Parallel Studio (ePS). But single core systems or host applications can also benefit from the eCG compiler source to source transformation framework and its built-in library for numerical algorithms. Performance improvements can be achieved by selecting a fast built-in numerical algorithm and combining it with emmtrix Code Generator, a compiler designed especially for performance optimizations.
As example we set up a performance test comparing the run time of the fast Fourier transform. It’s a well-known algorithm with complexity of O(N log(N)). As a test case we used a small MATLAB Script applying the Fourier transform to a complex random vector of size N. We ran the FFT in a loop with 10^5 iterations. In the first scenario we used the emmtrix built-in FFT in combination with eCG. In the second scenario we used the default FFT from MATLAB in combination with the MATLAB Coder. Due to the factorization impact we used two different sets of sample sizes – one based on the power of 2 (referred to as base 2) and the other based on a mixture of power of 2 and 5 (referred to as base 10) numbers.
The base 2 results are shown in diagram A. For sample sizes up to 4096 eCG achieves a speed up ratio of greater than 2. For larger sample sizes, the speed up still stays slightly below 2.
The base 10 results are shown in diagram B. In this case eCG is much faster than the MATLAB FFT. Since we know that the asymptotic behaviour of the emmtrix FFT is O(Nlog(N)) and is increasing in a linear manner, the MATLAB FFT has a complexity of O(N*N*log(N)) for this kind of factorization. eCG achieves a speed up ratio of more than 5 for large sample sizes.