         uint8_t thinning_cond_4 = (((P2 & P4 & P6) == 0) | (TR_P4 != 1));
         uint8_t thinning_cond_ok = thinning_cond_1 & thinning_cond_2 & thinning_cond_3 & thinning_cond_4;
 
-        d_dst[row * width + col] = BINARY_WHITE + ((1 - thinning_cond_ok) * d_src[row * width + col]);
+        d_dst[g_row * g_width + g_col] = BINARY_WHITE + ((1 - thinning_cond_ok) * d_src[g_row * g_width + g_col]);
     }
 }
 

#include "gpu3.cuh"
#include "../common/gpu_only_utils.cuh"
#include "../common/utils.hpp"

void and_reduction(uint8_t* d_data, int width, int height, dim3 grid_dim, dim3 block_dim) {
    int shared_mem_size = block_dim.x * block_dim.y * sizeof(uint8_t);

}

// Performs 1 iteration of the thinning algorithm.
__global__ void skeletonize_pass(uint8_t* d_src, uint8_t* d_dst, int g_width, int g_height) {
    // shared memory for tile
    extern __shared__ uint8_t s_data[];

    int g_row = blockIdx.y * blockDim.y + threadIdx.y;
    int g_col = blockIdx.x * blockDim.x + threadIdx.x;

    int s_row = threadIdx.y + PAD_TOP;
    int s_col = threadIdx.x + PAD_LEFT;
    int s_width = blockDim.x + PAD_LEFT + PAD_RIGHT;
    int s_height = blockDim.y + PAD_TOP + PAD_BOTTOM;

    if ((g_row < g_height) & (g_col < g_width)) {
        // load data into shared memory tile

        // "center" pixels
        s_data[s_row * s_width + s_col] = d_src[g_row * g_width + g_col];

        // top & bottom "padding" pixels
        if (s_row == PAD_TOP) {

        } else if (s_row == (s_height - 1)) {

        }

        // left & right "padding" pixels

        __syncthreads();

        // continue skeletonization
        uint8_t NZ = black_neighbors_around(d_src, g_row, g_col, g_width, g_height);
        uint8_t TR_P1 = wb_transitions_around(d_src, g_row, g_col, g_width, g_height);
        uint8_t TR_P2 = wb_transitions_around(d_src, g_row - 1, g_col, g_width, g_height);
        uint8_t TR_P4 = wb_transitions_around(d_src, g_row, g_col - 1, g_width, g_height);
        uint8_t P2 = P2_f(d_src, g_row, g_col, g_width, g_height);
        uint8_t P4 = P4_f(d_src, g_row, g_col, g_width, g_height);
        uint8_t P6 = P6_f(d_src, g_row, g_col, g_width, g_height);
        uint8_t P8 = P8_f(d_src, g_row, g_col, g_width, g_height);

        uint8_t thinning_cond_1 = ((2 <= NZ) & (NZ <= 6));
        uint8_t thinning_cond_2 = (TR_P1 == 1);
