In parallel computing, problems are often categorized based on how easily they can be divided into smaller, independent tasks that can be processed in parallel. The two main categories which we will investigate here are embarrassingly parallel and non-embarrassingly parallel problems.
- Embarrassingly Parallel:
- Each task can be executed independently with no or minimal need for communication between tasks.
- The speed-up scales near linearly by adding more compute.
- Non-embarrassingly Parallel:
- Tasks are dependent on one another and require synchronization or communication or data sharing between subproblems.
- Scaling is not trivial, e.g. you might run into diminishing returns sort of problems (e.g. too much communication overhead).
Here, we will look into two algorithms: 1) the Fast Fourier Transform (non-embarrassingly parallel) and 2) Mandelbrot set calculation (embarrassingly parallel).
This project implements the forward Binary Exchange FFT using parallel processing with MPI (Message Passing Interface) and the Bit Reversal technique. The purpose of the project is to benchmark the method against the non-parallel version of it. The algorithm will generate a random sequence of numbers
You need the following installed:
- MPI Library (e.g. OpenMPI)
- GCC or Clang with MPI support
- Clone the repository:
git clone https://github.com/ntat/Parallelization_FFT_Fractals.git cd FFT
- Compile using
mpicc
:mpicc -o myfft fft_final.c -lm
- Run the program with
mpirun
, specifying the number of processes (-np
), which must be a power of two:mpirun -np <num_processes> myfft <N> <debugMode> <printResults>
N
(integer): Input size (must be a power of two).debugMode
(0/1): If1
, saves the FFT input toInputFFT.txt
printResults
(0/1): If1
, saves the FFT output (in correct order / not bit flipped) toOutputFFT.txt
- Example:
mpirun -np 4 myfft 1024 1 1
This will calculate the FFT on 4 processes, and it will return the randomly generated sequence of length N=1024, as well as its FFT calculation in case you need it.
Results compiled on an Intel Xeon Haswell-based cluster.
The Mandelbrot set is computed by iterating the function:
where:
-
$c \in \mathbb{C}$ , represents a point in the complex plane (mapped from a pixel), -
$z_0 = 0$ , - The iteration continues until either
(indicating divergence) or a maximum number of iterations
For each pixel corresponding to the complex number
The image is generated by mapping a rectangular portion of the complex plane to a grid of pixels. Let:
The step sizes along the real and imaginary axes are given by:
where
Zooming is achieved by redefining the boundaries of the complex plane. For a selected pixel
These pixel coordinates are then translated back to complex plane coordinates, resulting in updated boundaries:
This effectively “zooms in” on the region of interest.
The computation is parallelized using MPI by dividing the image into vertical slices. Suppose there are
After each process computes its submatrix of iteration counts, the results are gathered by the master process to form the complete image. The image is then written to a binary file, which can then be visualized using a Python script or a MATLAB script etc.
You need the following installed:
- MPI Library (e.g. OpenMPI)
- GCC or Clang with MPI support
- Clone the repository:
git clone https://github.com/ntat/Parallelization_FFT_Fractals.git cd Fractals_Mandelbrot_Set
- Compile using
mpicc
:mpicc -o mandelbrot mandelbrot.c -lm
- Run the program with
mpirun
, specifying the number of processes (-np
):mpirun -np 4 mandelbrot <x> <y> <zoom_factor>
x
: X Pixel Coordinatey
: Y Pixel Coordinatezoom_factor
: How many pixels around the chosen center (X,Y) will define the zoom window.
- Example (this will zoom into the region centered around pixel (1291, 1860), with a zoom factor of 5:
mpirun -np 4 mandelbrot 1291 1860 5
To get the original mandelbrot in the default boundaries: mpirun -np 4 mandelbrot
The first picture corresponds to the projection on the imaginary plane of the total region of the Mandelbrot Set. Second picture corresponds to the same projection but zoomed around (coordinates: 1291, 1860). Third picture is taken by further zooming around the center of the spiral dome of the second picture (coordinates: 945, 1866).