Petr Palata Petr Palata -3 years ago 144
iOS Question

How to synchronize between threadgroups in Metal

I want to synchronize writes to a

between threadgroups in Metal kernel. I've tried to use the
type and
function. This should work, but my problem is that I don't know how to interpret the values on the CPU side. I would prefer a locking mechanism that I could use to synchronize writes to the same buffer from different threadgroups. Is there such mechanism or some other workaround that is not bound to atomic types?

Answer Source

I'm facing similar problems in 16-bit float conversion.

You could try to interpret values on the CPU side by extracting raw bits from the buffer, comparing with the internal format of the atomic_uint, and then try to use the information obtained to recast as the datatype you need. A low-level approach for sure, but works when nothing else will.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download