CUDA-accelerated 2D Monte Carlo integration with automatic mixed-precision optimization.
- GPU Acceleration with CUDA batch processing
- Mixed Precision: Automatic float/double/long double selection
- Multiple Strategies: Term-wise and region-wise decomposition
- CPU Comparison: OpenMP parallel implementation
- Expression Parser: Supports
+,-,*,/,^,sin,cos,log,ln,exp,sqrt
- CUDA Toolkit (10.0+)
- NVIDIA GPU (compute capability 3.5+)
- G++ with C++17 support
- OpenMP
make./mciInput Example:
Expression: x*y + sin(x) + cos(y) x-range [a b]: 0 3.14159 y-range [c d]: 0 3.14159 Total samples: 10000000 The framework automatically selects optimal precision for each term/region based on:
- Function variance
- Gradient magnitude
- Numerical stability
- Error tolerance (default: 1e-5)
Precision Selection:
- Float: Fast, suitable for smooth functions (~4x faster than double)
- Double: Default for moderate complexity
- Long Double: High precision (CPU only)
The program runs multiple integration strategies:
- GPU Float Precision
- GPU Double Precision
- GPU Mixed Precision (term-wise)
- GPU Mixed Precision (region-wise)
- CPU comparisons
Each outputs timing breakdown and integration results.
For function f(x,y) over [a,b] × [c,d]:
Integral ≈ (b-a)(d-c) × (1/N) × Σf(xi, yi) Change tolerance:
input.tolerance = 1e-5; // in main()Adjust OpenMP threads:
omp_set_num_threads(6); // default is 6- Ferhat Onur Özgan
- Berke Kabasakal