 
     exit(0);
 }
+
+// OLD FILTER WITHOUT TEXTURES
+
+    /*__global__*/
+/*void filter(unsigned char *grayScale, unsigned char *filtered)*/
+/*{*/
+    /*int tid = (blockIdx.x * gridDim.y * blockDim.x * blockDim.y) + (blockIdx.y * blockDim.x * blockDim.y) + (threadIdx.x * blockDim.y) + threadIdx.y;*/
+
+    /*int i = tid % WIDTH;*/
+    /*int j = tid / WIDTH;*/
+
+    /*if (i <= 0 || i >= WIDTH - 1 || j <= 0 || j >= HEIGHT - 1)*/
+    /*{*/
+        /*return;*/
+    /*}*/
+
+    /*setPixel(filtered, i, j, tex2D(imageTex, i, j), N);*/
+
+    /*[>int gradX = tex2D(imageTex, i, j);<]*/
+    /*[>int gradY = tex2D(imageTex, i, j);<]*/
+
+    /*[>int gradX = getPixel(grayScale, i-1, j+1, N) - getPixel(grayScale, i-1, j-1, N) + 2*getPixel(grayScale, i, j+1, N) - 2*getPixel(grayScale, i, j-1, N) + getPixel(grayScale, i+1, j+1, N) - getPixel(grayScale, i+1, j-1, N);<]*/
+
+    /*[>int gradY = getPixel(grayScale, i-1, j-1, N) + 2*getPixel(grayScale, i-1, j, N) + getPixel(grayScale, i-1, j+1, N) - getPixel(grayScale, i+1, j-1, N) - 2*getPixel(grayScale, i+1, j, N) - getPixel(grayScale, i+1, j+1, N);<]*/
+
+    /*[>int magnitude = gradX*gradX + gradY*gradY;<]*/
+
+    /*[>if (magnitude  > 10000)<]*/
+    /*[>{<]*/
+        /*[>setPixel(filtered, i, j, 255, N);<]*/
+    /*[>}<]*/
+    /*[>else<]*/
+    /*[>{<]*/
+        /*[>setPixel(filtered, i, j, 0, N);<]*/
+    /*[>}<]*/
+/*}*/

    CHECK(cudaMalloc(&devGrayScale, WIDTH * HEIGHT * sizeof(unsigned char)));
    CHECK(cudaMalloc(&devFiltered, WIDTH * HEIGHT * sizeof(unsigned char)));

    // Copy Cuda Memory
    CHECK(cudaMemcpy(devGrayScale, grayScale.img, WIDTH * HEIGHT * sizeof(unsigned char), cudaMemcpyHostToDevice));
    // Set to 0 just in case
    CHECK(cudaMemset(devFiltered, 0, WIDTH * HEIGHT * sizeof(unsigned char)));

    // Run the kernel
    dim3 dimBlock(WIDTH, HEIGHT);
    dim3 dimGrid(1);
    filter<<<dimBlock, dimGrid>>>(devGrayScale, devFiltered);

    // Return the Cuda Memory


#define WIDTH 640
#define HEIGHT 480
#define WARP_SIZE 32

texture<unsigned char, 2> imageTex;

/**
 * TODO List
 *
 * - Resize image to test for speed
 * - Introduce a stride
 * - Think how this can work for images of any size
 * - Think about bank collisions
 * - Refactor the code
