https://github.com/yuvix25/piapproxcuda
A calculation of PI using integrals which runs on the GPU (CUDA).
https://github.com/yuvix25/piapproxcuda
Last synced: 3 months ago
JSON representation
A calculation of PI using integrals which runs on the GPU (CUDA).
- Host: GitHub
- URL: https://github.com/yuvix25/piapproxcuda
- Owner: Yuvix25
- Created: 2021-06-16T19:08:54.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-16T19:30:13.000Z (almost 4 years ago)
- Last Synced: 2025-01-19T10:09:52.750Z (4 months ago)
- Language: Cuda
- Size: 201 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PiApproxCUDA
A calculation of PI using integrals which runs on the GPU (CUDA).## Compatabilty:
NVIDIA GPUs with compute capabilty of 6.0 or higher.## Prebuilts:
For GPUs with compute capabilty 8.6 (arch=sm_86) you can use the prebuilts.## Build it yourself:
To build it yourself, use the following command: `nvcc pi_approx_gpu.cu -arch=sm_{your compute capability here} -o pi_approx_gpu`, for example, if your GPU has a 7.5 compute capability, run: `nvcc pi_approx_gpu.cu -arch=sm_75 -o pi_approx_gpu`.## Usage:
After compiling / using the prebuilts, just run the `.exe` file (`pi_approx_gpu.exe`) and enter the amount of iterations you want to perform (higher means higher accuracy, and if you entered `30`, it will run `2^30` iterations).## So, how does this work?
The code calculates the integral of `sqrt(1-x^2)` in the range `-1, 1` which gives you `pi/2`, by calculating the size of many rectangles bellow this function, and the "iterations" you enter are acctualy the number of recantgles to calculate.