Problem Description:
The objective of our project is to parallelize a sequential code such that it can beexecuted for N number of processes. The original source code performs Image Analysis for animage which is treated as a matrix of characters. NOTE : 1 character is a pixel of black and whiteimage.The most computation intensive task of the code was FFT operations. These wereparallelized using the MPI based FFT routines.The major challenge of this task was:
•
Understand the sequential code and investigate parallelization approaches.
•
Understand data distribution requirements of the FFTW routines.
•
Synchronization of tasks to enforce ordering if and when required.We focused mainly on our solution to be scalable. This is because we would be required to testour parallelized code for bigger images which are impossible to be viewed on a single processor.
Parallelization Strategy:
The following steps unfold the various stages of our task parallelization strategy.
Setting up the ‘parallel environment’ and use of MPI FFTW routines:
Firstly, we initialize the Parallel environment using MPI_Init (). Next, We create plans forthe forward and inverse transforms, of type fftwnd_mpi_plan, using function:
fftwnd_mpi_plan fftw2d_mpi_create_plan (MPI_Comm comm,int nx, int ny,fftw_direction dir, int flags);
Distributing the problem/data:
In order to obtain a load balanced form of data distribution for the MPI FFTW routines weuse the following function:
fftwnd_mpi_local_sizes ( fftplan, &local_height,&local_start,&local_ny_after_transpose,&local_y_start_after_transpose,&total_local_size);
This allows us to divide the image horizontally such that each process gets x number of rows andy columns where x<1
st
dimension of image and y always equal to 2
nd
dimension of image.
Figure 1: Slab decomposition for data distribution
Parallelizing Reading the Image:
In accordance with our task parallelization strategy, every process will carry out its taskconcurrently. The image read operation is also parallelized in a similar fashion. The Image is read
Y dimension (always constant)X dimesion along which theimage is divided
Leave a Comment