I’m studying OpenCL and I’m trying to do this exercise but I don’t know how to write the corresponding kernel code in order to avoid the branch-divergence problem.
I write something like that but I don’t know if I’ll problem or branch divergence
__kernel void oddcopy(const __global const int *a, __global int*b) {
int gid = get_global_id(0);
if(gid%2==0){
b[gid] = a[gid];
}
}
I hope my question is clear because I’m not very well at English, sorry.
Thanks in advance for the help, if there are problems let me know!