kernel void entry() { int id = (int)get_global_id(0); bool end = false; int cnt = 0; bool end2 = false; while (1) { if (end2) break; if (cnt==0) { // First loop end = id==0; // end is only true for first work item } else { // Second loop end = true; // end is always true now } cnt++; // end2 will be false at first loop, and true at second loop // end2 will be of the same value for whole sub_group/work_group #if 1 end2 = sub_group_all(end?1:0)!=0; #else end2 = work_group_all(end?1:0)!=0; #endif #if 0 if (id<=1) { printf("global_id = %d, end = %d, end2 = %d\n", id, end?1:0, end2?1:0); } #endif } }