Skip to content
Snippets Groups Projects
Commit 773e09c8 authored by matbe320's avatar matbe320
Browse files

Lab5: Code cleanup

parent 4829349c
No related tags found
No related merge requests found
......@@ -39,18 +39,13 @@
#define maxKernelSizeX BLOCK_W
#define maxKernelSizeY BLOCK_H
// #define BLOCK_SIZE 16 // total number of threads per block = 256
// #define GRID_SIZE 8 // total number of blocks per grid = 256
#define LOCAL_MEM_SIZE (FILTER_W * FILTER_H)
__global__ void filter(unsigned char *image, unsigned char *out, const unsigned int imagesizex, const unsigned int imagesizey, const int kernelsizex, const int kernelsizey)
{
__shared__ unsigned char local_memory[FILTER_W * FILTER_H * 3];
// __shared__ unsigned char local_memory[(BLOCK_W + RADIUS) * 3 * (BLOCK_H + RADIUS)];
// map from blockIdx to pixel position
unsigned blockNumInGrid = blockIdx.x + gridDim.x * blockIdx.y;
unsigned threadNumInBlock = threadIdx.x + blockDim.x *threadIdx.y;
unsigned threadsPerBlock = blockDim.x * blockDim.y;
__shared__ unsigned char local_memory[LOCAL_MEM_SIZE * 3];
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
......@@ -64,7 +59,7 @@ __global__ void filter(unsigned char *image, unsigned char *out, const unsigned
int blockOffsetY = blockIdx.y * blockDim.y;
/* Changed while loop here also, might need to include some stuff with - RADIUS here also */
while((block_y * FILTER_W + block_x) < (FILTER_W *FILTER_H))
while((block_y * FILTER_W + block_x) < LOCAL_MEM_SIZE)
{
int global_y = max(blockOffsetY + block_y - RADIUS, 0);
int global_x = max(blockOffsetX + block_x - RADIUS, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment