opencl - Knapsack algorithm: strange behavior with pown() on the gpu -


the version on cpu ocl produces right results, gpu ocl in places gives different results in places after influence correctness of result. have debugged on intel ocl sdk right results. haven't spotted race condition or concurrent access memory. problem has appeared after have introduced in kernel (one line of code) pown function.

void kernel knapsack(global int *input_f, global int *output_f, global uint *m_d,  int cmax, int weightk, int pk, int maxelem, int i){  int c = get_global_id(0)+cmax;  if(get_global_id(0)<maxelem){     if(input_f[c] < input_f[c - weightk] + pk){         output_f[c] = input_f[c - weightk] + pk;         m_d[c-1] = pown(2.0,i); *//previous version: m_d[c-1] = 1;*     }      else{     output_f[c] = input_f[c];      }     } } 

the purpose of pown compress m_d buffer holds outcomes.

for example  1 0 1 0    2^0+2^2, 2^1, 2^0, 2^1   0 1 0 1 => 1 0 0 0 

on gpu this:

    2^0+2^2, 2^1, 2^0+2^2, 2^1  in      3rd column access pown 1 more again, when i'm not supposed to.  

this gives me "slight" different result. here can find full code

this work based on article:


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -