Open main menu

CDOT Wiki β

Changes

BLAStoise

1,308 bytes added, 22:51, 4 April 2017
Progress
=== Assignment 2 ===
<h4>Parallelized Oil Painting Program</h4>
Despite our decision of choosing to parallelize the Sudoku solver in assignment 1, we came to the conclusion that parallelizing the oil painting program would be better suited for us. We were able to grasp the logic behind the oil painting program whereas we had a lot of trouble working out the logic behind solving Sudoku puzzles. In the serial program, the oil painting worked by going one pixel at a time in a double for loop going across the height and width of the iamge.
 
<pre>
for (int i=0; i < height; i++)
{
for (int j=0; j < width; j++)
{
result[i*width+j] = ProcessPixel(j,i);
}
}
</pre>
 
We were able to remove the need for this loop through the utilization of a kernel. In the main function, we created the following block and grid and called our oil painting kernel:
 
<pre>
const dim3 block(16, 16, 1);
const dim3 grid(ceil((float)width / block.x), ceil((float)height / block.y), 1);
oilPaint << <grid, block >> >(gpu_src, gpu_dst, width, height);
</pre>
 
 
In our kernel, through the use of the primitive types, we are able to determine the exact position of the pixel in the 2D array:
 
<pre>
//2D Index of current thread
const int i = blockIdx.x * blockDim.x + threadIdx.x;
const int j = blockIdx.y * blockDim.y + threadIdx.y;
</pre>
 
 
 
=== Assignment 3 ===
26
edits