Some elements in Arrays not getting values

Hi

I have a really weird situation here. Currently in my algorithm, i require 8 sets of calculation that is dependent on values in an array, so for example (a watered down version of)

num = exp(arrayA[0]+arrayB[1])

den = exp(arrayA[0]) + exp(arrayB[1])

arrayC[0] = log(num/den)

...repeat similar...

num = exp(arrayB[0]+arrayC[1])

den = exp(arrayB[0]) + exp(arrayC[1])

arrayD[0] = log(num/den)

...repeat similar...

now i do everything in doubles, so not to lose precision. I have a GTX260 so I can do doubles.

After tracing through the code, i found out that some of the elements in the array contain bogus values (#UND, #IND, etc), i thought it could be some sort of race condition since everything gets executed at the same time, and the 2nd set of the calculations require results from the previous set, so I spilt the calculation into 2 different kernels. Both kernels are identical I basically end up doing something like this

__device__ kernel1 (etc)

{

num = exp(arrayA[0]+arrayB[1])

den = exp(arrayA[0]) + exp(arrayB[1])

arrayC[0] = log(num/den)

...repeat similar...

}

__device__ kernel2(etc)

{

num = exp(arrayB[0]+arrayC[1])

den = exp(arrayB[0]) + exp(arrayC[1])

arrayD[0] = log(num/den)

...repeat similar...

}

My problem is this: only the first kernel properly updates the arrays with the values. the 2nd kernel (with the problematic array before spiltting) STILL does not update the entire array but rather randomly and sparingly. I have no idea how to fix this issue. Is this something with syncthreads? I put __syncthreads after both kernels but it didnt work, still getting bogus values in the array. Is this somehow related to losing precision using doubles?

Does anyone have any clue as to what is happening?

Please help!

Update,

I messed around with number of threads and blocks and somehow all the elements are now free of bogus values.

I found the ‘optimal’ number of threads/blocks by trial and error, but is there any specific guideline as to what numbers to use?

Between the best practices guide that now ships with the toolkit and the occupancy spreadsheet which comes with the SDK, you should be able to find out everything you need to know.