Our final project for the 2017/2018 numerical simulations course at the University of Stuttgart.
The objective of this project is the implementation of our previously CPU-based flow solver in OpenCL to exploit the massively parallel architecture of the GPU, ultimatively acheiving a speed-up over the CPU-implementation.
To acheive this, multiple kernels have been created, including kernels for
- the initialization of boundary values,
- calculation of the preliminary velocities
F
andG
, - the solver for the pressure equation (including the calculation of its right-hand-side),
- calculation of the residual,
- calculation of the new velocities,
- and multiple reduction kernels, used, for example, for the calculation of the residual and the visualization.
Furthermore we re-implemented the visualization using OpenGL. This lets us use the data directly available on the GPU, thus we can reduce the amount of data copied between device and host.
This project has the following dependencies:
- OpenCL (calculation)
- OpenGL (visualization)
- SDL2 (window- and OpenGL context-creation)
- GLEW (OpenGL function loading)
As well as dependencies to the following third-party header-only libraries that are included:
cl2.hpp
(https://github.com/KhronosGroup/OpenCL-CLHPP) the official OpenCL C++ wrapperjson.hpp
(https://github.com/nlohmann/json) to write json files for performance-testing
The program can be compiled using cmake
, i.e.
mkdir build && cd build # create build directory
ccmake .. # configure using ccmake
cmake --build .
And then executed (in the build directory) using ./main
.
Run ./main -h
for a short info about the available command line options.
Shortcut | Effect |
---|---|
l | Linear interpolation of between cells |
n | Cell values (no interpolation) |
Shortcut | Effect |
---|---|
1 | Display magnitude of velocity |
2 | Display x-velocity (u, centered) |
3 | Display y-velocity (v, centered) |
4 | Display pressure |
5 | Display vorticity |
6 | Display stream function |
Shortcut | Effect |
---|---|
F1 | Display cell x-velocity (u, non-centered) |
F2 | Display cell y-velocity (v, non-centered) |
F3 | Display preliminary cell x-velocity (f, non-centered) |
F4 | Display preliminary cell y-velocity (g, non-centered) |
F5 | Display right-hand-side of pressure equation |
F6 | Display boundary types |
The default parameters and geometry are left unchanged from previous exercise-sheets. Additionally one can load a parameter and geometry files using
./path/to/build/main -p <parameter-file> -g <geometry-file>
The syntax of parameter and geometry-files is also left unchanged from the previous exercises, and can, for example, be generated by the Magrathea
program provided to us in exercise three.