PRavi7
New Contributor
6 years agoConcurrent execution of two loops in OpenCL
Hi,
I'm implementing a kernel in OpenCL which has two loops - Loop_a and Loop_b. Loop_a and Loop_b operations are totally independent of each other and hence can be executed concurrently. The code has been optimized as follows
int loop_limit = max(loop_a_num_iterations, loop_b_num_iterations);
for(int i = 0; i < loop_limit; i++)
{
if(i < loop_a_num_iterations)
{
// loop_a operation
}
if(i < loop_b_num_iterations)
{
// loop_b operation
}
}Both these if statements are executed concurrently. loop_a operation has high latency than loop_b operation, but loop_a performs lesser number of iterations than loop_b. For the first loop_b_num_iterations, both loop_a operation and loop_b operation is executed at the same high latency as loop_a. Followed by this is remaining iterations for loop_b operation.
Is there a better way to overlap the execution of two loops?
Thanks in advance