SAR imaging processing programming -- FFTW

Posted by dhiren22 on Fri, 24 Dec 2021 00:50:58 +0100

FFTW overview

Fftw (the fast Fourier transform in the West) is a standard C language assembly for fast computing discrete Fourier transform, which was developed by M.Frigo and S. Johnson of MIT. It can calculate one-dimensional or multi-dimensional real and complex data and DFT of any scale.

FFTW also includes parallel transformation of shared and distributed storage systems. It can automatically adapt to your machine, cache, memory size and number of registers.

FFTW is usually faster than other open source Fourier transform programs. The latest version is FFTW-3.3 8.

The code generator of fftw is written by object-oriented design technology and object-oriented language Caml; It can automatically adapt to the system hardware, so it has strong portability. FFTW2.1.5 support shared memory multithreading parallel and distributed memory MPI parallel. The operation performance of fftw is far ahead of other existing FFT software.

FFTW generates a plan for patterns of any size, and completes the conversion of various patterns by performing various operations on the plan; the internal structure and its complexity are transparent to users; and the speed is fast (internal compilers and code generators suitable for various machines use AST to generate code and optimize themselves at run time, and do not occupy compilation time. Hierarchical storage technology is adopted).

FFTW is widely favored by more and more scientific research and Engineering Computing workers, and provides practical large-scale FFT calculation in the fields of quantum physics, spectral analysis, audio and video stream signal processing, oil exploration, earthquake prediction, weather prediction, probability theory, coding theory, medical fault diagnosis and so on.

On machines equipped with Intel processors, fftw can be used directly after installing MKL math library, and the speed is relatively fast. However, MKL math library cannot be installed on machines without Intel processor. If you want to use fftw, you must compile and install it on your own machine.

Linux system compilation and installation

Installation package: fftw-3.3 8.tar. gz

In the path where the installation package is located, execute the following command once to complete the compilation and installation of fftw

tar -xzvf fftw-3.3.8.tar.gz

cd fftw

./configure --prefix=/home/FFTW LDFLAGS=-L/home/FFTW/lib FC=ifort F77=ifort CC=gcc CXX=g++ --enable-mpi -enable-shared --enable-float

make

make install

It can be modified according to actual needs/ Parameters of configure

Use example

After the FFTW is installed, it can be used. An example of range FFT for SAR imaging is given below.

Related codes and parallel acceleration schemes can leave messages or private messages

/************************************************************************************
*	Distance FFT
* Younger 2021-09-15
************************************************************************************/
int SARImage_CS::RangeFFT(ScmComplex* S)
{
	long i, j, k, l, m, kk, ll, mm, nn;
	long lBlock_Size = 64;                        //Ϊ×ö·½Î»Ïòfft¶ø·ÖµÄ¿é´óС
	unsigned char   fftw_Flags = FFTW_MEASURE;
	
	{
		// Define private variables
		fftwf_plan  sS3_Plan;
		fftwf_complex *sS3_fftwf;
		sS3_fftwf = (fftwf_complex*)fftwf_malloc( Nr * sizeof( fftwf_complex ) );
		sS3_Plan = fftwf_plan_dft_1d( Nr , sS3_fftwf , sS3_fftwf , FFTW_FORWARD , fftw_Flags );				

		
		for ( i = 0; i < Na; i++ )
		{			
			// Take out a distance data and perform FFT transformation
			for ( j = 0; j < Nr; j++ )                           
			{
				sS3_fftwf[j][0] = S[i*Nr+j].re;
				sS3_fftwf[j][1] = S[i*Nr+j].im;
			}	
			fftwf_execute( sS3_Plan );
			
			for ( j = 0; j < Nr; j++ )                           
			{
				S[i*Nr+j].re = sS3_fftwf[j][0];
				S[i*Nr+j].im = sS3_fftwf[j][1];
			}				
		} //end for i
			// Free up space for private variables
		fftwf_free(sS3_fftwf);		
		fftwf_destroy_plan(sS3_Plan);		
	}

	return 0;
}

Topics: FFT