I have a situation where if a condition happens in any of the threadgroup threads, then a boolean should be set and a final task performed by a single thread.
Does this look like the correct way to accomplish that?
threadgroup uint myBool; // threadgroup bool crashes the compiler
// Initialize myBool
if(tid == 0)
{
myBool = false;
}
// Ensure all threads see value for myBool
threadgroup_barrier(mem_flags::mem_threadgroup);
// Do various caluclations
...
if(someFancyCondition)
{
myBool = true;
}
// Ensure correct final value for myBool
threadgroup_barrier(mem_flags::mem_threadgroup);
if(tid == 0 and myBool)
{
// do stuff
}