Problem with else condition. may be thread indexing problem.

Hi,

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

[codebox]

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 )

{

if(seq1[idx/len1]==seq2[idx%len1])

  dev_matrix[idx]= 1;

else

 dev_matrix[idx]= 2;

}

[/codebox]

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

Thank you! .