Barrier?

Hi,

I have the following questions regarding to usage of barrier. It would be very appreciated if anyone could answer it.

[1]

If (condition)
{

barrier();

}
else
{

}

Question: “condition” for all work items in the same workgroup should be all true or all false in order to reach the exactly same barrier in IF-TRUE block, and this should be guaranteed from progragm logic by a programmer. Is it correct?

[2]

void func()
{

if (condition2)
barrier();

}

If (condition1)
{

func();

}
else
{

}

Question: similar to above case, if one of work item in a workgroup reaches “barrier” inside a function, all work items in the same workgroup should reach the same “barrier”, too. Thus, “condition1” and “condition2” should be all true for all work items in the same workgroup in this case. Is it correct?

[3]

if (get_local_id(0) % 2 == 0)
{

barrier();

}
else
{

barrier();

}

Question: assume workgroup size is greater than 2, this case should be illegal because condition of “get_local_id(0) % 2 == 0” cannot be all true or all false for all work items in the same workgroup due to barrier() inside. Is it correct?

Thanks a lot!