The FractalSharp distributed system project consists of implementing Mandelbrot set using a distributed system. It can be run in several ways:
- On 1 single process
- On a multitude of processes
- On several interconnected machines
Once the image of the Mandelbrot fractal has been calculated, it is displayed on screen and the user can draw a rectangle (keeping the same ratio as the base image) to recalculate the Mandelbrot set, generate the zoomed image and display it.
The distributed system part of FractalSharp is implemented using MPI (Message Passing Interface). In addition, FractalSharp uses two different programming languages:
- FractalSharp and FractalSharpMPI are two programs written in C# for Windows. MPI, we used MPI.NET from Microsoft. FractalSharp is designed and adapted for Windows, but we need to run our program on Linux computers in order to use the cluster made available to us. However, MPI.NET is very complex to compile on Linux and dotnet is not available on the computers provided. So there are :
- FractalPlusPlus and FractalPlusPlusMPI are two programs written in C++ and are mainly designed for Linux, to run on the cluster provided.
The problem can easily be broken down into two crucial points:
- The image generated by calculating the Mandelbrot set must be created by a separate program (the ...MPI versions of the programs) because you can't restart an MPI calculation from a program that just finished its MPI calculation (MPI processes finish the main program and cannot be recreated).
- The image display and the part of the MPI program that requests the Mandelbrot set calculation program must both be in a different Thread, as waiting for mouse clicks to draw the rectangle on the image would block the MPI calculation.
The aim of our program is to propose a performance analysis of the addition of MPI in the calculation of a fractal based on the Mandelbrot set. We have 3 different test conditions:
- C# (Windows)
- C++ (Windows)
- C++ (Linux)
Based on these 3 conditions, we will run 6 different tests:
- Unzoomed 640x630 image
- 640x360 zoomed image
- Unzoomed 1280x720 image
- Zoomed 1280x720 image
- Unzoomed 4K (3840x2160) image
- 4K (3840x2160) zoomed image
- Very high-quality image (16000x9000) unzoomed
On these first 5 tests, we took the following numbers of processes:
- C# - from 1 to 8
- C++ Windows - from 1 to 8
- C++ Linux - from 1 to 8 then 12, 16, 32 and 64
In the last image, only the C++ Linux tests have been performed.
In this first test, we have an unzoomed 640x630 image. Performance on Windows will only be tested up to 8 processes, as our current configuration doesn't allow us to test on more.
The performance of C# and C++ Linux gets worse as the number of processes increases because since the image is very small, the time required to move data is greater than the time saved by parallelizing calculations. The C++ Windows version delivers excellent performance.
In this second test, we have a 640x630 zoomed image. On a small image, zoomed-in performance is more or less the same as on a zoomed-out image.
In this third test, we have an unzoomed 1280x720 image. On this medium-sized image, we're starting to see significant differences. The performance of the C# program on Windows degrades very quickly. However, on the same operating system, C++ achieves slightly better performance by increasing the number of MPI processes. However the performance does not justify the use of MPI and 8 different processes. The other big difference is on Linux with C++. Up to now, performance has been fairly constant up to 16 processes, but deteriorated enormously beyond that. degraded dramatically beyond that. On this image, performance, like on Windows, is better up to 16 processes, degrading beyond that, but much less so. This suggests that performance beyond performance beyond 16 processes would be very good on large images.
In this fourth test, we have a zoomed-in 1280x720 image. There is no significant between the zoomed and unzoomed images.
In this fifth test, we have an unzoomed 4K image. From now on, we won't be focusing on C# performance, but C++ performance is becoming increasingly interesting.
Times in seconds are starting to get bigger and bigger, and Windows and Linux performance are getting closer and closer together. The previous hypothesis is beginning to be confirmed, now performance are worse with few MPI processes, and become much better the more processes are added. There is now very little difference beyond 16 processes.
In this sixth test, we have a zoomed-in 4K image. There's little change compared to the unzoomed image, but the difference in performance between C++ Windows and Linux disappears a little more.
In this seventh and final test, we have a zoomed-in 16000x9000 image. On this image, we wanted to demonstrate our hypothesis. We have therefore only collected C++ Linux data. On this very large image, we can see a clear difference between using MPI and not using MPI. We also observe very good performance when using 64 processes (the more processes you use, the better the performance).
To launch the program, we'll first compile it. Since FractalSharp and FractalPlusPlus are two different programs, we will detail the compilation steps for each.
- Go to the Source Code folder in the archive, or (optionally) clone from git https://github.com/samlach2222/FractalSharp.git
FractalSharp (Windows)
- Launch this batch file to install MPI and SDL :
REQUIREMENTS/Install SDL and MPI.bat
. - Install Visual Studio, then launch the project with the
FractalSharp.sln
file. - Right-click on the solution, then
Generate solution
. - Go to the
.\FractalSharp\bin\[Release|Debug]\net8.0-windows7.0\
folder.
FractalPlusPlus (Windows)
- Launch this batch file to install MPI and SDL :
REQUIREMENTS/Install SDL and MPI.bat
. - Install Visual Studio, then launch the project with the
FractalPlus.sln
file. - Right-click on the solution, then
Generate solution
. - Go to the
.\x64\[Release|Debug]\
folder.
FractalPlusPlus (Linux)
- Run the installation program with the command
./build_linux.sh
. - Go to the
.\build_linux\
folder.
We can now launch the program. On each version, there are two ways to launch the program. The first is the classic one, i.e. launch the GUI program (with the graphical display). Here, you can zoom in by drawing a rectangle. The second way to launch the program is to use only the MPI part, in which case the program is launched with command line arguments.
On Windows:
GUI β Run FractalSharp.exe or FractalPlusGUI.exe (depending on the desired programming language).
MPI β Run the FractalSharpMPI.exe or FractalPlusMPI.exe program (depending on the desired programming language) as follows:
mpiexec -n [NumberMPIProcess] [FractalSharpMPI.exe | FractalPlusMPI.exe] [SizeX] [SizeY] [minComplexX] [maxComplexX] [minComplexY] [maxComplexY]
On Linux:
GUI β Run the ./FractalPlusPlusGUI program.
MPI β Run the ./FractalPlusPlusMPI program as follows:
mpiexec -hostfile [FilenameHost] -n [NumberMPIProcess] ./FractalPlusPlusMPI [SizeX] [SizeY] [minComplexX] [maxComplexX] [minComplexY] [maxComplexY]
Test data:
For the GUI version, there isn't really any test data. This version is mainly used to check that it's working properly. You are free to zoom in as you wish. However, at some point (between the 3rd and 4th zoom), the program displays only black. This is because we have reached the maximum number of decimal places for our calculation algorithm.
For the MPI version, the recommended test data are as follows:
- Calculation of an unzoomed FullHD image:
SizeX = 1920 SizeY = 1080 minComplexX = -2 maxComplexX = 2 minComplexY = -1.125 maxComplexY = 1.125
- Calculation of a zoomed FullHD image:
SizeX = 1920 SizeY = 1080 minComplexX = -1.828 maxComplexX = -1.64 minComplexY = -0.057 maxComplexY = 0.049
- Calculation of an unzoomed 16000*9000 image:
SizeX = 16000 SizeY = 9000 minComplexX = -2 maxComplexX = 2 minComplexY = -1.125 maxComplexY = 1.125