Changes

Jump to: navigation, search

Avengers

11 bytes added, 15:39, 30 March 2019
Team Avengers
==== Identifying Parallelize-able Code ====
 
calculateDimensions() has 3 nested for loops. Each for loop is used to set the value of one of the triangle sides. The inner-most for loop compares the two shorter sides of the triangle by first squaring them and then adding the squared results together. A condition is used to check if the sum of the squared side values is equivalent to the squared value of the hypotenuse. The results are printed when the condition is true.
[[File:NestedLoops.PNG]]
 
The nested for loops represent the serial way of calculating the dimensions.
==== Offloading Process ====
 
To parallelize the code mentioned above, we did the following:
 
1. Use CUDA device properties to design the grid and blocks.
[[File:cudaDevProps.PNG]]
 
2. Adjust the number of threads to be used in the grid depending on the value passed in by the user (max hyptonuse value).
[[File:adjustNTPG.PNG]]
 
3. Allocated 2 arrays on device, initialized from 1 to the maximum hypotenuse (given by the user as an argument):
[[File:allocInit.PNG]]
 
4. Calculated the number of blocks required and iterated through the thrust vector, passing each individual element to the kernel launch along with the two previously allocated arrays.
[[File:NBandLaunch.PNG]]
 
5. The kernel contains the instructions for verifying whether the value passed in is part of a Pythagorean triple. If a Pythagorean triple is found, the values are printed out.
[[File:kernel.PNG]]
 
==== Time Logging ====
[[File:Timings.PNG]]
 
calculateSerial() contains the initial version of the application. It has 3 nested for loops and has a serialized approach to finding the Pythagorean triples. The time taken to find the triples is printed out after execution.
(Image)
 
=== Assignment 3 ===
46
edits

Navigation menu