Beispiel #1
0
        public static void Atoms(EmitterContext context)
        {
            OpCodeAtom op = (OpCodeAtom)context.CurrOp;

            ReductionType type = op.RawOpCode.Extract(28, 2) switch
            {
                0 => ReductionType.U32,
                1 => ReductionType.S32,
                2 => ReductionType.U64,
                _ => ReductionType.S64
            };

            Operand offset = context.ShiftRightU32(GetSrcA(context), Const(2));

            int sOffset = (op.RawOpCode.Extract(30, 22) << 10) >> 10;

            offset = context.IAdd(offset, Const(sOffset));

            Operand value = GetSrcB(context);

            Operand res = EmitAtomicOp(
                context,
                Instruction.MrShared,
                op.AtomicOp,
                type,
                offset,
                Const(0),
                value);

            context.Copy(GetDest(context), res);
        }
Beispiel #2
0
 public Map(int rows, int columns)
 {
     this.Rows              = rows;
     this.Columns           = columns;
     this.Cells             = new MapCellList();
     this.Patterns          = new MapPatternList();
     this.IncludeDimensions = true;
     this.Reduction         = ReductionType.None;
 }
Beispiel #3
0
 void OnGUI()
 {
     GUILayout.Label("Object Reduction (Permanent)", EditorStyles.boldLabel);
     RedType    = (ReductionType)EditorGUILayout.EnumPopup("Reduce Method", RedType);
     SelType    = (SelectionType)EditorGUILayout.EnumPopup("Operate On", SelType);
     percentage = EditorGUILayout.IntSlider("Reduce Percentage", percentage, 1, 100);
     if (GUILayout.Button("Reduce"))
     {
         Reduce();
     }
 }
Beispiel #4
0
        public static List <FMeasureFromWidthOrCount> FindFMeasureFromNeighborsCount(
            Parameters parameters,
            int minNeiborsCount,
            int maxNeighborsCount,
            int step,
            ReductionType reductionType)
        {
            var dependency            = new List <FMeasureFromWidthOrCount>();
            var currentNeighborsCount = minNeiborsCount;

            while (currentNeighborsCount <= maxNeighborsCount)
            {
                parameters.NeighborsCount = currentNeighborsCount;
                switch (reductionType)
                {
                case ReductionType.Naive:
                    dependency.Add(new FMeasureFromWidthOrCount
                    {
                        Value          = CalculateFMeasureNaive(parameters),
                        NeighborsCount = currentNeighborsCount
                    });
                    break;

                case ReductionType.OneHot:
                    dependency.Add(new FMeasureFromWidthOrCount
                    {
                        Value          = CalculateFMeasureOneHot(parameters),
                        NeighborsCount = currentNeighborsCount
                    });
                    break;

                default:
                    break;
                }
                currentNeighborsCount += step;
            }
            return(dependency);
        }
Beispiel #5
0
        public static List <FMeasureFromWidthOrCount> FindFMeasureFromWindowWidth(
            Parameters parameters,
            double minWindowWidth,
            double maxWindowWidth,
            double step,
            ReductionType reductionType)
        {
            var dependency         = new List <FMeasureFromWidthOrCount>();
            var currentWindowWidth = minWindowWidth;

            while (currentWindowWidth <= maxWindowWidth)
            {
                parameters.WindowWidth = currentWindowWidth;
                switch (reductionType)
                {
                case ReductionType.Naive:
                    dependency.Add(new FMeasureFromWidthOrCount
                    {
                        Value       = CalculateFMeasureNaive(parameters),
                        WindowWidth = currentWindowWidth
                    });
                    break;

                case ReductionType.OneHot:
                    dependency.Add(new FMeasureFromWidthOrCount
                    {
                        Value       = CalculateFMeasureOneHot(parameters),
                        WindowWidth = currentWindowWidth
                    });
                    break;

                default:
                    break;
                }
                currentWindowWidth += step;
            }
            return(dependency);
        }
Beispiel #6
0
        public static void Atom(EmitterContext context)
        {
            OpCodeAtom op = (OpCodeAtom)context.CurrOp;

            ReductionType type = (ReductionType)op.RawOpCode.Extract(49, 2);

            int sOffset = (op.RawOpCode.Extract(28, 20) << 12) >> 12;

            (Operand addrLow, Operand addrHigh) = Get40BitsAddress(context, op.Ra, op.Extended, sOffset);

            Operand value = GetSrcB(context);

            Operand res = EmitAtomicOp(
                context,
                Instruction.MrGlobal,
                op.AtomicOp,
                type,
                addrLow,
                addrHigh,
                value);

            context.Copy(GetDest(context), res);
        }
Beispiel #7
0
        private static Operand EmitAtomicOp(
            EmitterContext context,
            Instruction mr,
            AtomicOp op,
            ReductionType type,
            Operand addrLow,
            Operand addrHigh,
            Operand value)
        {
            Operand res = Const(0);

            switch (op)
            {
            case AtomicOp.Add:
                if (type == ReductionType.S32 || type == ReductionType.U32)
                {
                    res = context.AtomicAdd(mr, addrLow, addrHigh, value);
                }
                else
                {
                    context.Config.GpuAccessor.Log($"Invalid reduction type: {type}.");
                }
                break;

            case AtomicOp.BitwiseAnd:
                if (type == ReductionType.S32 || type == ReductionType.U32)
                {
                    res = context.AtomicAnd(mr, addrLow, addrHigh, value);
                }
                else
                {
                    context.Config.GpuAccessor.Log($"Invalid reduction type: {type}.");
                }
                break;

            case AtomicOp.BitwiseExclusiveOr:
                if (type == ReductionType.S32 || type == ReductionType.U32)
                {
                    res = context.AtomicXor(mr, addrLow, addrHigh, value);
                }
                else
                {
                    context.Config.GpuAccessor.Log($"Invalid reduction type: {type}.");
                }
                break;

            case AtomicOp.BitwiseOr:
                if (type == ReductionType.S32 || type == ReductionType.U32)
                {
                    res = context.AtomicOr(mr, addrLow, addrHigh, value);
                }
                else
                {
                    context.Config.GpuAccessor.Log($"Invalid reduction type: {type}.");
                }
                break;

            case AtomicOp.Maximum:
                if (type == ReductionType.S32)
                {
                    res = context.AtomicMaxS32(mr, addrLow, addrHigh, value);
                }
                else if (type == ReductionType.U32)
                {
                    res = context.AtomicMaxU32(mr, addrLow, addrHigh, value);
                }
                else
                {
                    context.Config.GpuAccessor.Log($"Invalid reduction type: {type}.");
                }
                break;

            case AtomicOp.Minimum:
                if (type == ReductionType.S32)
                {
                    res = context.AtomicMinS32(mr, addrLow, addrHigh, value);
                }
                else if (type == ReductionType.U32)
                {
                    res = context.AtomicMinU32(mr, addrLow, addrHigh, value);
                }
                else
                {
                    context.Config.GpuAccessor.Log($"Invalid reduction type: {type}.");
                }
                break;
            }

            return(res);
        }
Beispiel #8
0
 public Map()
 {
     this.Cells     = new MapCellList();
     this.Reduction = ReductionType.None;
     this.Patterns  = new MapPatternList();
 }