int alloc_part() { const uint s0 = atomicAdd(fcnt[1], 1u); for (uint k = 0u; k < 64u; ++k) { const uint s = (s0 + k) % uint(FPART_MAX); const uint word = 4u + uint(FP_MAX) * 24u + s * 12u + 4u; const uint previous = atomicAdd(fxwords[word], 0u); if (uintBitsToFloat(previous) <= 0.0 && atomicCompSwap(fxwords[word], previous, floatBitsToUint(3.0e38)) == previous) return int(s); } return -1; } void release_part(uint slot) { // Publish a free slot only after its previous owner has finished all writes. memoryBarrierBuffer(); atomicExchange(fxwords[4u + uint(FP_MAX) * 24u + slot * 12u + 4u], 0u); }