#pragma clang diagnostic ignored "-Wmissing-prototypes" #include #include using namespace metal; template inline bool spvSubgroupAllEqual(T value) { return simd_all(all(value == simd_broadcast_first(value))); } template<> inline bool spvSubgroupAllEqual(bool value) { return simd_all(value) || !simd_any(value); } template inline bool spvSubgroupAllEqual(vec value) { return simd_all(all(value == (vec)simd_broadcast_first((vec)value))); } struct inputData { float inputDataArray[1]; }; constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); kernel void main0(device inputData& _12 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { float thisLaneData = _12.inputDataArray[gl_LocalInvocationID.x]; bool laneActive = thisLaneData > 0.0; bool allInvocations = simd_all(laneActive); bool anyInvocations = simd_any(laneActive); bool allInvocationsEqual = spvSubgroupAllEqual(laneActive); }