I am new to OpenCL/OneAPI. How can I change this nested loop to use oneAPI GPU:
try {
for (int i = 0; i < count; i++) {
for (int j = 0; j < count; j++) {
if (a_array[i] * a_array[j] == max) {
p_found = a_array[i];
q_found = a_array[j];
throw "found";
}
}
}
}
catch (...) {
std::cout << "q = " << q_found << " and p = " << p_found << std::endl;
}
Here is how an OpenCL kernel for the task would look like:
Note that due to parallelization, there is a small complication: If there is exactly one hit, everything is fine. However if there is more than one hit, the result will be eiter one of the multiple hits, and it will be totally random which one it is.