Problem with else condition. may be thread indexing problem.


In this kernel, the else condition is satisfied but the control does not go in the else statement,


global void calculateMatrix(char* seq1, char* seq2, int *dev_matrix,int len2,int len1)


int bx = blockIdx.x;

int by = blockIdx.y;

int threadx = blockDim.x*bx + threadIdx.x;

int thready = blockDim.x*by + threadIdx.y;

int idx = threadx + thready * len1;

int blockNum = bx + by;

if(idx>len1 && idx%len1!=0 )



  dev_matrix[idx]= 1;


 dev_matrix[idx]= 2;



Can any one please suggest what can be wrong with it?

Thank you! .