The Khronos Group - a non-profit industry consortium to develop, publish and promote open standard, royalty-free media authoring and acceleration standards for desktop and handheld devices, combined with conformance qualification programs for platform and device interoperability.

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Kernel for finding the minimum element in the array

I am writing an OpenCL code which parallelizes finding the minimum number in an array.
Here is my kernel function:
What i am doing is comparing all the elements with all the other elements and the element which is greater i am changing the corresponding value of M[i] to 1. At last we have only one element in M array with value 0, with that index we can look in the A array and have our minimum value

if(A[i]<A[j] && i!=j)
{M[j]=1;}
}
I am getting all the values M array as 0.
But the output should be that only one value of the M array should be 0. and that index would give me the min number index in array A.

Re: Kernel for finding the minimum element in the array

// Get the index of the current element
int i = get_global_id(0); //this will get you the index
int j;
int v=0;

//Checking the A[i] value with all the values of Set B
//k is the size of set B
for(j=0;j<k;j++)
{
if(A[i] == B[j])
{
v=1;
}
}
if(v == 0)C[i]=A[i];
}

This is the kernel function to compute A - B(A and B are two vectors) but the problem is
size_t global_item_size = s;
size_t local_item_size = s;
s is the size of A array and if i change the global_item_size and the local_item_size i don't get the answer