Reading wrong data on OpenCL

listed in answer

Reading wrong data on OpenCL
0 votes, 0.00 avg. rating (0% score)

ANSWER:

You are messing up with buffer dimensions.

1) Your buffers contains 768 elements each (see initialization of w_portion_size and w_pos_portion_size)

2) Workgroup size on my machine is 896 (see initialization of wg_count)

3) You print out 790 values.

Apart from this, one conceptual error is here:

if(global_id == 0) 
     counter[5] = 0; // set index of pos in weights to zero

//atomic increments on counter[5]

You can’t assume that the first virtual processor will execute this line before the others. You should completely remove this line, since you initialize coutner[5] on the host side. (Even if incorrect, I do not believe that this is the cause of your problem).

After fixing these problems your code seems to run fine (intel implementation).

by sbabbi from http://stackoverflow.com/questions/10666934