Comparing two arrays

I have 2 arrays, i am declaring the global work size equal to the size of one array, and in each thread i am comparing every element of one array with all the other elements of the 2nd array - this i am doing using a for loop.
Is there a better method to compare both the arrays in which i don’t need to use the for loop??

You could launch your work as a 2D NDRange. Then, you could use get_global_id(0) to be the index of one array and get_global_id(1) to be the index in the other. This could successfully get rid of the loop, but it’s hard to say if it results in faster code. If the code is only doing one comparison, the overhead of lauching work on the compute units may eclipse the computation cost. But if you are doing more work than just the comparison, this path may result in simpler code.