Hill_Groove

OpenCL

Discussion created by Hill_Groove on Dec 5, 2009
Latest reply on Dec 6, 2009 by Hill_Groove
different calculation results

Hello. The results (res[0]) of the following code are different. Maybe there is a problem with memory somewhere. It is interesting, that if 7 t = t + 0.01  strings are written instead of 8 (as below), the program works fine.

#define N 20
__kernel void interaction(global float A[], global float res[], global float C[])
{
__private int a;
__private int b;
__private int i;
__private int j;
__private float t;
a = get_global_id(0);
b = get_global_id(1);
t = 0;
for (i=0;i<10;i++)
{
     t = t + 0.01;
     t = t + 0.01;
     t = t + 0.01;
     t = t + 0.01;
     t = t + 0.01;
     t = t + 0.01;
     t = t + 0.01;
     t = t + 0.01;
}
C[a*N+b] = t;
barrier(CLK_GLOBAL_MEM_FENCE);

if (a*b==1)
{
    res[0] = 0;
    for (i=0 ; i <N ;i++)
    {
        for (j=0;j<N;j++)
        {
            res[0] = res[0] + C[i*N+j];
        }
    }
}
}

Intel Core i7, XFX 4890, Win7

 

Outcomes