1
edit
Changes
no edit summary
=== Assignment 1 ===
I found ray tracer that matched the criteria I was looking for at http://scratchapixel.com/assets/Uploads/Lesson001/Source%20Code/raytracer.cpp
}
====Michael====
I have picked the Monte Carlo simulation for this assignment. Source code was from [http://www.dartmouth.edu/~rc/classes/soft_dev/C_simple_ex.html here] and was modified to take and argument as the number of iterations and factored out the function which is going to be used for parallelzation.
Runtime for this program O(N) and the results are as follows:
{| class="wikitable"
! N Iterations !! Time (seconds)
|-
| 1,000,000 || 0.02
|-
| 5,000,000 || 0.24
|-
| 10,000,000 || 0.42
|-
| 50,000,000 || 2.22
|-
| 100,000,000 || 4.75
|-
| 500,000,000 || 19.97
|-
| 1,000,000,000 || 44.5
|-
| 5,000,000,000 || 94.08
|}
Due to the simplicity of the program, all of the time spent was on the calc function below, as iterations increased, the time it takes increases at a linear rate.
Function to parallelize:
void calc(int iterations, int* count){
double x, y, z;
for (int i=0;i<iterations;i++){
x = (double)rand()/RAND_MAX;
y = (double)rand()/RAND_MAX;
z = x*x+y*y;
if (z<=1){
(*count)++;
}
}
}
=== Assignment 2 ===
=== Assignment 3 ===