A "Fair Fight" performance comparison between Single-Threaded CPU, Multi-Threaded CPU (OpenMP), and GPU (OpenGL Compute Shader).
The task is
- CPU Single: Standard C++ loop.
- CPU OpenMP: Uses
#pragma omp parallel forto utilize all available cores (e.g., 16 threads). - GPU: OpenGL 4.6 Compute Shader (Naive implementation).
- CPU Single: ~1900 ms
- CPU OpenMP: ~200 ms (Speedup: ~9x)
- GPU: ~100 ms (Speedup vs OpenMP: ~2x)
- Scoop
- Visual Studio (MSVC)
- OpenGL 4.3+ capable GPU
scoop install cmake vcpkg
vcpkg integrate install
vcpkg install glfw3 glad --triplet=x64-windows
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="$env:USERPROFILE/scoop/apps/vcpkg/current/scripts/buildsystems/vcpkg.cmake"
cmake --build build --config Release
.\build\Release\gpgpu_vs_omp.exe