コード例 #1
0
        private bool StartsWithUnconditionalBarrier(Block b, Implementation Impl, Block SpecialExitBlock)
        {
            if (verifier.IsKernelProcedure(Impl.Proc))
            {
                if (b == Impl.Blocks[0])
                {
                    // There is a barrier at the very start of the kernel
                    return(true);
                }
                if (b == SpecialExitBlock)
                {
                    // There is a barrier at the very end of the kernel
                    return(true);
                }
            }

            if (b.Cmds.Count == 0)
            {
                return(false);
            }
            CallCmd c = b.Cmds[0] as CallCmd;

            if (c == null || !GPUVerifier.IsBarrier(c.Proc))
            {
                return(false);
            }

            var BarrierProcedure = c.Proc;

            if (!verifier.uniformityAnalyser.IsUniform(BarrierProcedure.Name))
            {
                // We may be able to do better in this case, but for now we conservatively say no
                return(false);
            }

            if (BarrierHasNonUniformArgument(BarrierProcedure))
            {
                // Also we may be able to do better in this case, but for now we conservatively say no
                return(false);
            }

            Debug.Assert(c.Ins.Count() == 2);
            if (strength == BarrierStrength.GROUP_SHARED || strength == BarrierStrength.ALL)
            {
                if (!c.Ins[0].Equals(verifier.IntRep.GetLiteral(1, 1)))
                {
                    return(false);
                }
            }
            else if (strength == BarrierStrength.GLOBAL || strength == BarrierStrength.ALL)
            {
                if (!c.Ins[1].Equals(verifier.IntRep.GetLiteral(1, 1)))
                {
                    return(false);
                }
            }
            else
            {
                // All cases should be covered by the above
                Debug.Assert(false);
            }
            return(true);
        }