One of my kernels compares each value of a double 1D array verifying that is greater than a scalar. This kernel fills a boolean array of the comparison results.
The resulting boolean vector should provide every element comparison result in TRUE or FALSE terms.
But I found that the device is storing other types of TRUE values that makes my code crash. I can find TRUE (63), TRUE (66), TRUE (240), etc. What is this?
Please download the images of the same array in two different times when the scalar is equal to zero.
The 1D array contains 100 elements and only the first element is equal to 1 and the rest is equal to zero. The expected results is of course: {TRUE, FALSE, FALSE, FALSE, ... FALSE}
I found another question with an answer that suggests the use 32-bit integers ("Ideally you should aim to use a 32 bit type") but I don't understand how to do that:
This is my kernel:
__global__ void _vecCmpGreat(bool *output, double *input1, double input2) {
unsigned int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < samples)
output[i] = input1[i] > input2;
}
The part of my code that computes the comparison results is the following. It should push back into std::vector result when the transition "FALSE" to "TRUE" is found the the boolean array.
unsigned int j;
for (unsigned int i = 0; i < samples - 1; i++) {
j = samples - i - 1;
if (r[samples - 1]) {
result.push_back(samples - i - 1);
break;
}
else {
if (r[j] == false && r[j - 1] == true) {
result.push_back(j);
break;
}
}
Any suggestions will be appreciated.