cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

How do I parallelize the following sequential code?

I wanted to to make the following kernel code parallel,

  In the code below size of a is n, b and c is 8*n and of d is some value less than n(eg : 3*n/4)

 

j=0;

for(i=0;i<n;i++)

  {

     if (a[b]!=a[c])

        {

             d=b;

              j++;

       }

}

Since the number of elements of a and d aren't the same I am facing a problem to give i=get_global_id(0), since by doing this, in some elements of d there would be nothing placed if the 'if'' condition violates...! So how do I make parallel..?

If not this then, is it possible to delete the "no value" positions of d in the kernel if I store the positions where the values are placed in d in a different array..?

0 Likes
12 Replies