 int main(int argc, char *argv[])
 {
     Uint32 flags = 0;
-    int i, w, h, size, done;
+    int w, h, size, done;
     clock_t clk;
 
     SDL_Window   *window = NULL;
     SDL_Renderer *renderer = NULL;
-    SDL_Texture  *texture = NULL;
+    SDL_Texture  *img_texture = NULL;
     SDL_Surface  *img_surface = NULL;
     SDL_Event     event;
 
     const char *img_name = NULL;
 
-    uint32_t *dev_buf = NULL, *host_buf = NULL;
+    uint32_t *dev_buf = NULL;
     dim3 thrd_per_block(32,32), block_per_grid;
 
     if(argc != 2)

        fprintf(stderr, "Failed to load %s.\n", img_name);
        return -3;
    }

    clk = clock();

    size = img_surface->w * img_surface->h * sizeof(uint32_t);
    cudaMalloc((void**)&dev_buf, size);
    host_buf = (uint32_t*)malloc(size);

    cudaMemcpy(dev_buf, img_surface->pixels, size, cudaMemcpyHostToDevice);

    block_per_grid.x = img_surface->w / thrd_per_block.x;
    block_per_grid.y = img_surface->h / thrd_per_block.y;
    monochrome<<<block_per_grid, thrd_per_block, 0>>>(dev_buf, img_surface->w, img_surface->h);
    cudaDeviceSynchronize();

    cudaMemcpy(img_surface->pixels, dev_buf, size, cudaMemcpyDeviceToHost);


    printf("*** Time: %f\n", (float)(clock() - clk) / CLOCKS_PER_SEC);

    img_texture = SDL_CreateTextureFromSurface(renderer, img_surface);
    if (!img_texture)
    {
        fprintf(stderr, "Couldn't create texture from surface!\n");
        return -1;
    }

    SDL_SetWindowTitle(window, img_name);
    SDL_SetWindowSize(window, w, h);
