1
edit
Changes
TudyBert
,→Assignment 3
Here's the final, optimized enlarge method:
<span style='color:#7f0055; font-weight:bold; '>int</span> jdx = blockIdx.x * blockDim.x + threadIdx.x;
<span style='color:#7f0055; font-weight:bold; '>int</span> idx = blockIdx.y * blockDim.y + threadIdx.y;
<span style='color:#7f0055; font-weight:bold; '>int</span> k = idx + jdx * blockDim.x * gridDim.x;
<span style='color:#7f0055; font-weight:bold; '>int</span> enlargeRow, enlargeCol;
__shared__ <span style='color:#7f0055; font-weight:bold; '>int</span> pixel;
pixel = work[k];
enlargeRow = idx * factor;
enlargeCol = jdx * factor;
__syncthreads();
<span style='color:#7f0055; font-weight:bold; '>for</span>(<span style='color:#7f0055; font-weight:bold; '>int</span> c = enlargeRow; c < (enlargeRow + factor); c++)
{
<span style='color:#7f0055; font-weight:bold; '>for</span>(<span style='color:#7f0055; font-weight:bold; '>int</span> d = enlargeCol; d < (enlargeCol + factor); d++)
{
result[c + d * blockDim.x * gridDim.x * factor] = pixel;
__syncthreads();
}
}
I was going to paste the code snippet here but I'm getting frustrated with the formatting. Why is it so difficult to nicely format code on a Wiki? [http://pastebin.com/ZZV9KRJN Here] it is.