# Inconsistant Values within Kernel

Hi,

I am doing some comparisons between two values within a kernel and writing a 1 to a matrix if they are equal and 0 if not. However, when I read a location from the matrix where it is supposed to produce 1, i find it a 0. If i read the value from the matrix immediatly after its written inside the loop, i get the correct value. But if i read it after the loop is done, the result is incorrect.

``````__global__ void

propagateGPU1(clause** clauses, vecp* dclauses, int* assign, short* dmatrix, size_t pitch, int* testv, short* stestv)

{

int i;

int j;

const unsigned int tid = threadIdx.x;

for(i = 0; i < dclauses->size; i++){

short* row = (short*)((char*)dmatrix + i * pitch);

for(j = 0; j < dclause_size(&clauses[i*64]); j++){

if(assign[tid] == (clauses[i*64].lits[j])){

row[tid] = 1;

//if(tid == 15 && i == 0 && j ==0)*stestv = dmatrix;   <--- when this is enabled, it produces a 1

}

else{

row[tid] = 0;

//if(tid == 15 && i == 0 && j ==0)**stestv = dmatrix;

}

}

}

if(tid == 15)**stestv = dmatrix; <---- this gives a 0

}
``````

I know for a fact that the result should be 1 based on the inputs which I have checked within the kernel are correct. both assign and clauses.lits are equal so the result should be 1. I am not doing anything between the loop and reading the value from the matrix but for some reason the result got changed.

pitch size is = 128 and the problem i am having is at i = 0 and j = 0