Dear all,

I am a belgian MSc student in computer science. My final MSc thesis is about machine learning algorithms and their implementation on GPGPU using CUDA.

I 'm working on a **global** function for the implementation of “decision trees” on the GPU.

I have a problem with the following code :

```
__device__ float getEntropyOnDevice(unsigned int* matrix, unsigned int numberOfY)
{
float entropy = 0, Na, N = *(matrix+numberOfY);
for(int i=0; i<numberOfY-1; i++)
{
Na = *(matrix+i);
if(Na != 0) entropy -= (Na/N * log2f(Na/N));
}
return entropy;
}
__global__ void scoreOnDevice( DeviceRecord* attToCompute, uint numberOfY, uint* total_matrix_left, uint* total_matrix_right, float entropy_estimate, uint nbScoreToCompute, Test* d_scores)
{
uint id = blockIdx.x * blockDim.x + threadIdx.x;
float Na,Nb,N,entropy_split;
entropy_split = Na = Nb = N = 1;
if(id < nbScoreToCompute)
{
Na = d_scores[id].total_left = *(total_matrix_left + (id*(numberOfY + 1)) + numberOfY);
Nb = d_scores[id].total_right = *(total_matrix_right + (id*(numberOfY + 1)) + numberOfY);
N = Na + Nb;
entropy_split = -(Na/N * log2f(Na/N)) - (Nb/N * log2f(Nb/N));
float entropy_left = getEntropyOnDevice(total_matrix_left + id * (numberOfY + 1), numberOfY);
float entropy_right = getEntropyOnDevice(total_matrix_right + id * (numberOfY + 1), numberOfY);
if(entropy_estimate == 0 || entropy_split == 0)d_scores[id].score = 0;
else
{
float information_gain = entropy_estimate - ((Na/N) * entropy_left) - ((Nb/N) * entropy_right);
//printf("\n %f ",2 * information_gain / (entropy_split + entropy_estimate)); // -deviceemu
// PROBLEM HERE, if I let "information_gain", the line is not executed... :
// d_scores[id].score = 2 / (entropy_split + entropy_estimate); // ----> WORKS but don't do what I want
d_scores[id].score = 2 * information_gain / (entropy_split + entropy_estimate); // WORKS ONLY on -deviceemu
}
d_scores[id].test = attToCompute[id].test;
}
}
```

When I compile the code with -deviceemu, the result given is exactly what I wrote but when I do a standard compilation, if I let the line “d_scores[id].score = 2 * information_gain / (entropy_split + entropy_estimate);”, the result goes totally wrong ( d_scores[id].test and d_scores[id].score contain random values )!

When this bug will be fixed, I will be able to post my results about “decision trees” on GPU… I’m sure that some of you will find my problem obvious but please, I really need your help.

Thank you in advance,

D1mmu.