This is an OpenCL implementation of Gaussian Elimination method for solving systems of linear equations (Ax = b).
This project compares strategies for GPU-accelerated Gaussian Elimination, from naive implementations to two optimized versions. The focus is on performance analysis, and to understand GPU performance characteristics through benchmarking results.
The project includes the necessary code and library, and the report itself contains the detailed analysis.
Computational Complexity: O(n³/3) floating-point operations
.
├── gaussianElimination.cpp # Naive GPU implementation (baseline)
├── optimizedGaussianElimination.cpp # Optimized implementations (2 strategies)
├── GaussianEliminationCI.cpp # Compute-intensive variant for analysis
├── basicKernels.ocl # Basic OpenCL kernels
├── optimizedKernels.ocl # Optimized OpenCL kernels
└── README.md # This file
- Standard Gaussian Elimination with partial pivoting
- Used for correctness verification
- Performance baseline for speedup calculations
- File: All
.cppfiles contain CPU reference implementation
- Basic parallelization: one work item per row
- Sequential back substitution
- No optimization
- Purpose: Baseline GPU performance
- File:
gaussianElimination.cpp - Kernels:
forwardElimination,backSubstitutioninbasicKernels.ocl
- Caches pivot row in local/shared memory
- Reduces global memory traffic
- Dynamic shared memory allocation
- Cooperative data loading
- File:
optimizedGaussianElimination.cpp - Kernel:
forwardEliminationBlockedinoptimizedKernels.ocl
- One thread per matrix element
- Optimized memory access patterns
- Maximizes memory bandwidth utilization
- Minimal thread divergence
- File:
optimizedGaussianElimination.cpp - Kernel:
forwardEliminationCoalescedinoptimizedKernels.ocl
- Controllable computation intensity
- Studies memory vs compute-bound behavior
- Analyzes operational intensity impact
- File:
GaussianEliminationCI.cpp - Kernel:
forwardEliminationCoalescedIntensiveinoptimizedKernels.ocl
- OpenCL SDK (AMD, NVIDIA, or Intel)
- C++ compiler with C++11 support
- JC utility library (for OpenCL helpers)
- CMake would be ideal to establish the project structure
- Use Visual Studio Code to compile and run locally
# Naive implementation
./gaussianElimination -p 0 -d 0 -n 512
# Optimized with blocked strategy
./optimizedGaussian -p 0 -d 0 -n 512 -s blocked
# Optimized with coalesced strategy
./optimizedGaussian -p 0 -d 0 -n 512 -s coalesced
# Compute-intensive variant
./gaussianCI -p 0 -d 0 -n 512 -c 100-p <id>: OpenCL platform ID (default: 0)-d <id>: OpenCL device ID (default: 0)-n <size>: Matrix dimension (default: 512)-s <strategy>: Optimization strategy - "blocked" or "coalesced" (optimized version only)-c <count>: Computation loop count (compute-intensive version only)-h: Show help message
Matrix size: 512x512
Running sequential Gaussian elimination...
Sequential time: 125000 us
Sequential solution verified successfully!
Running optimized GPU solver...
Optimized GPU time: 8500 us
=== Results ===
Verification: PASSED
Speedup: 14.7x
CPU Performance: 0.89 GFLOPS
GPU Performance: 13.1 GFLOPS
GPU Memory Bandwidth: 45.2 GB/s
All implementations measure and give:
- Execution Time: Microseconds for computation only
- Speedup: Ratio of CPU time to GPU time
- GFLOPS: Computational performance (billion floating-point operations per second)
- Memory Bandwidth: GB/s of memory throughput
- Solution Accuracy: Maximum error compared to CPU reference
- Operational Intensity: FLOPS per byte (compute-intensive variant)