Open main menu

CDOT Wiki β

Changes

GPU610/DPS915 CUDA PI

367 bytes added, 00:27, 4 November 2013
no edit summary
==== '''Code Snippet''' ====
Serial Pi Calculation Algorithm
// loops through user amount of rounds of sets of points
for(i = 0; i < points; i++)
==== '''Introduction''' ====
In Phase 2, I've parallelized the serial program to run on a custom kernel on a CUDA-enabled device.
 
==== '''Source File(s)''' ====
Link: https://drive.google.com/file/d/0B8GUuIUqdEJEbDBRNkhWYnpGSnM
 
==== '''Code Snippet''' ====
Serial Pi Calculation Algorithm
 
// loops through user amount of rounds of sets of points
for(i = 0; i < points; i++)
{
x = randNum();
y = randNum();
 
// check if point resides within the circle
if (((x*x) + (y*y)) <= 1.0)
{
score++;
}
}
// calculate pi
pi = 4.0 * (float)score/(float)points;
==== '''Compilation and Running''' ====
[[File:Pi_serial_vs_cuda_results.jpg|border]]
==== '''Source File(s)''' ====
Link: https://drive.google.com/file/d/0B8GUuIUqdEJEbDBRNkhWYnpGSnM
==== '''Conclusion''' ====