title: OpenCL 1D Array Big Number Multiply
body: <p>I am working on multiplying two integer array for big numbers. I basically multiplied about 20 digits numbers but for more numbers it acts unstable. I have some code on CPU and kernel for test and kernel give me different numbers after each work. The problem may be barrier or something like mutex but im not into this that much. How can i solve this unstability? Here is the code</p>
  
  <pre><code>kernel void multiply(global int* A,
                   const int M,
                   global int* B,
                   const int N,
                   global int* C){
  const int globalRow = get_global_id(0); // Row ID of C (0..M)
  int globalCol,i;
  
  // Compute a single element (loop over K)
  for (globalCol=0; globalCol&lt;N; globalCol++) {
      int val=A[globalRow]*B[globalCol];
  
      printf("Row is %d , Col is %d \n",globalRow,globalCol);
      //C[globalCol + globalRow +1]+=val/10;
      C[globalCol + globalRow]+=val%10;
  
      C[globalCol+1+globalRow]+=val/10;
  
  }
  
  int flag=1;
  while (flag) {
      flag=0;
      for (i=M+N-1   ; i&gt;=0 ; i--) {
          if (C[i]&gt;9) {
              C[i+1]+=C[i]/10;
              C[i]=C[i]%10;
              flag=1;
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>the flag thing on code is shifting.It sounds like accessing elements problem but i don't know how to solve.</p>