Example #1
0
        public Disassembler(CPU cpu, MemorySpace.Memory memory)
        {
            _cpu = cpu;
              _memory = memory;

              Reset();
        }
        public void SaveVariableToMemorySpace()
        {
            MemorySpaceNodeListCache cache = new MemorySpaceNodeListCache();

            AST root = new AST();
            MemorySpace memorySpace = new MemorySpace("globals", root, new Scope(Scope.ScopeType.MAIN_SCOPE, "blah"), cache);
            object val = 5.9f;
            memorySpace.setValue("x", val);
            Assert.AreEqual(typeof(float), memorySpace.getValue("x").GetType());
            Assert.AreEqual(5.9f, (float)memorySpace.getValue("x"));
        }
Example #3
0
        public void SaveVariableToMemorySpace()
        {
            MemorySpaceNodeListCache cache = new MemorySpaceNodeListCache();

            AST root = new AST();
            MemorySpace memorySpace = new MemorySpace("globals", root, new Scope(Scope.ScopeType.MAIN_SCOPE, "blah"), cache);
            ReturnValue val = new ReturnValue(5.9f);
            memorySpace.setValue("x", val);
            Assert.AreEqual(ReturnValueType.NUMBER, memorySpace.getValue("x").getReturnValueType());
            Assert.AreEqual(5.9f, memorySpace.getValue("x").NumberValue);
        }
        private void Assign(Ast ast, dynamic value, MemorySpace space = null)
        {
            if (value is ValueMemory)
            {
                var tup = value as ValueMemory;

                tup.Memory.Assign(ast.Token.TokenValue, tup.Value);

                return;
            }

            if (space != null)
            {
                space.Assign(ast.Token.TokenValue, value);
                return;
            }

            MemorySpaces.Current.Assign(ast.Token.TokenValue, value);
        }
 public ValueMemory(dynamic value, MemorySpace memory)
 {
     this.Value  = value;
     this.Memory = memory;
 }
 private static extern unsafe int _AllocHostRaw(ref PtrT pointer, uint size, MemorySpace memorySpace, MathDomain mathDomain);
Example #7
0
 public void SetMemorySpace(string name, MemorySpace space)
 {
     arrayLocations[name] = space;
 }
Example #8
0
 private static extern unsafe int _EyeRaw(PtrT pointer, uint nRows, MemorySpace memorySpace, MathDomain mathDomain);
Example #9
0
 private static extern unsafe int _ScaleRaw(PtrT z, uint size, MemorySpace memorySpace, MathDomain mathDomain, double alpha);
Example #10
0
 private static extern unsafe int _SubtractEqualRaw(PtrT z, PtrT x, uint size, MemorySpace memorySpace, MathDomain mathDomain);
Example #11
0
 private static extern unsafe int _AddEqualMatrixRaw(PtrT A, PtrT B, uint nRows, uint nCols, MemorySpace memorySpace, MathDomain mathDomain, MatrixOperation aOperation, MatrixOperation bOperation, double alpha, double beta);
Example #12
0
 private static extern unsafe int _AddEqualRaw(PtrT z, PtrT x, uint size, MemorySpace memorySpace, MathDomain mathDomain, double alpha);
Example #13
0
 private static extern unsafe int _IsNonZeroRaw(PtrT z, PtrT x, uint size, MemorySpace memorySpace, MathDomain mathDomain);
Example #14
0
 private static extern unsafe int _InvertRaw(PtrT A, uint nRows, uint nCols, MemorySpace memorySpace, MathDomain mathDomain, MatrixOperation aOperation);
Example #15
0
 private static extern unsafe int _SparseAddRaw(PtrT z, PtrT x, PtrT y, uint nNonZeros, PtrT nonZeroIndices, MemorySpace memorySpace, MathDomain mathDomain, uint size, double alpha);
Example #16
0
 private static extern unsafe int _SparseDotRaw(PtrT y, PtrT A, PtrT x, uint nNonZeros, PtrT nonZeroColumnIndices, PtrT nNonZeroRows, uint nRows, uint nCols, MemorySpace memorySpace, MathDomain mathDomain, MatrixOperation aOperation, double alpha);
Example #17
0
 private static extern unsafe int _ElementwiseProductRaw(PtrT z, PtrT x, PtrT y, uint size, MemorySpace memorySpace, MathDomain mathDomain, double alpha = 1.0);
Example #18
0
 public ValueMemory(dynamic value, MemorySpace memory)
 {
     Value = value;
     Memory = memory;
 }
Example #19
0
 internal ContiguousMemoryBuffer(bool isOwner = true, MemorySpace memorySpace = MemorySpace.Device, MathDomain mathDomain = MathDomain.Float)
 {
     this.isOwner     = isOwner;
     this.memorySpace = memorySpace;
     this.mathDomain  = mathDomain;
 }
Example #20
0
 public Tensor(int nRows, int nCols, int nCubes, double value, MemorySpace memorySpace = MemorySpace.Device, MathDomain mathDomain = MathDomain.Float)
     : this(nRows, nCols, nCubes, memorySpace, mathDomain)
 {
     Set(value);
 }
Example #21
0
 private static extern unsafe int _InitializeRaw(PtrT pointer, uint size, MemorySpace memorySpace, MathDomain mathDomain, double value);
Example #22
0
 private static extern unsafe int _LinSpaceRaw(PtrT pointer, uint size, MemorySpace memorySpace, MathDomain mathDomain, double x0, double x1);
Example #23
0
 private static extern unsafe int _RandNormalRaw(PtrT pointer, uint size, MemorySpace memorySpace, MathDomain mathDomain, int seed);
 private static extern unsafe int _AutoCopyRaw(PtrT destPointer, PtrT sourcePointer, uint size, MemorySpace memorySpace, MathDomain mathDomain);
Example #25
0
        protected void MakeStackOp(StackOp op, int size, MemorySpace space, int offset, Expr indexExpr, ArrayList bytecodeList)
        {
            // Not for MemorySpace.MEM ops.

            if (indexExpr != null)
            {
                indexExpr.MakeByteCode(true, bytecodeList);
            }

            int opcode;
            if (offset < 32
                && size == 4
                && (space == MemorySpace.VAR || space == MemorySpace.LOCAL)
                && indexExpr == null)
            {	// Use the short form if possible
                if ((offset & 3) != 0)
                    throw new ParseException("Non-long offset", Token);

                opcode = space == MemorySpace.VAR ? 0x40 : 0x60;	// VAR / LOCAL
                opcode |= (byte)op;

                bytecodeList.Add((byte)(opcode + offset));
            }
            else	// we have to use the long form
            {
                opcode = 0x80 | ((size >> 1) << 5) | ((int)space << 2) | (int)op;
                if (indexExpr != null)
                {
                    opcode |= 0x10;
                }

                if (offset < 128)
                {
                    bytecodeList.Add((byte)opcode);
                    bytecodeList.Add((byte)offset);
                }
                else
                {
                    bytecodeList.Add((byte)opcode);
                    bytecodeList.Add((byte)(offset >> 8 | 0x80));
                    bytecodeList.Add((byte)offset);
                }
            }
        }
 private static extern unsafe int _FreeRaw(PtrT pointer, uint size, MemorySpace memorySpace, MathDomain mathDomain);
Example #27
0
 public ValueMemory(dynamic value, MemorySpace memory)
 {
     Value  = value;
     Memory = memory;
 }
Example #28
0
 public SparseVector(int denseSize, int nNonZeroIndices, MemorySpace memorySpace, MathDomain mathDomain)
     : this(denseSize, new Vector(nNonZeroIndices, memorySpace, MathDomain.Int), mathDomain)
 {
 }
        public static ColumnWiseMatrix LinSpace(int nRows, int nCols, double x0, double x1, MemorySpace memorySpace = MemorySpace.Device, MathDomain mathDomain = MathDomain.Float)
        {
            var mat = new ColumnWiseMatrix(nRows, nCols, memorySpace, mathDomain);

            mat.LinSpace(x0, x1);

            return(mat);
        }
        private object NewDo(NewAst ast)
        {
            var className = Resolve(ast);

            var classType = (className as ClassSymbol).Src as ClassAst;

            var space = new MemorySpace();

            var oldSpace = MemorySpaces.Current;

            MemorySpaces.Current = space;

            foreach (var symbol in classType.Body.ScopedStatements)
            {
                Exec(symbol);
            }

            if (classType.Constructor != null)
            {
                var funcInvoke = new FuncInvoke(classType.Constructor.Token, ast.Args);

                funcInvoke.CurrentScope = classType.Body.CurrentScope;

                Exec(funcInvoke);
            }

            MemorySpaces.Current = oldSpace;

            return space;
        }
        public static ColumnWiseMatrix RandomGaussian(int nRows, int nCols, int seed, MemorySpace memorySpace = MemorySpace.Device, MathDomain mathDomain = MathDomain.Float)
        {
            var mat = new ColumnWiseMatrix(nRows, nCols, memorySpace, mathDomain);

            mat.RandomGaussian(seed);

            return(mat);
        }
Example #32
0
 private static extern unsafe int _SparseSubtractRaw(PtrT z, PtrT x, PtrT y, uint nNonZeros, PtrT nonZeroIndices, MemorySpace memorySpace, MathDomain mathDomain, uint size);
 public ColumnWiseMatrix(int nRows, int nCols, double value, MemorySpace memorySpace = MemorySpace.Device, MathDomain mathDomain = MathDomain.Float)
     : this(nRows, nCols, memorySpace, mathDomain)
 {
     Set(value);
 }
Example #34
0
 private static extern unsafe int _SparseMultiplyRaw(PtrT A, PtrT B, PtrT C, uint nNonZeros, PtrT nonZeroColumnIndices, PtrT nNonZeroRows, uint nRowsB, uint nRowsC, uint nColsC, MemorySpace memorySpace, MathDomain mathDomain, uint leadingDimensionB, uint leadingDimensionC, MatrixOperation bOperation, double alpha);
Example #35
0
        public static Tensor LinSpace(int nRows, int nCols, int nCubes, double x0, double x1, MemorySpace memorySpace = MemorySpace.Device, MathDomain mathDomain = MathDomain.Float)
        {
            var tensor = new Tensor(nRows, nCols, nCubes, memorySpace, mathDomain);

            tensor.LinSpace(x0, x1);

            return(tensor);
        }
 /// <summary>
 /// Class constructor.
 /// </summary>
 /// <param name="memory">The memory referenced by the CPU core.</param>
 internal InterruptController(MemorySpace.Memory memory)
 {
     this.memory = memory;
 }
Example #37
0
        public static Tensor RandomGaussian(int nRows, int nCols, int nCubes, int seed, MemorySpace memorySpace = MemorySpace.Device, MathDomain mathDomain = MathDomain.Float)
        {
            var tensor = new Tensor(nRows, nCols, nCubes, memorySpace, mathDomain);

            tensor.RandomGaussian(seed);

            return(tensor);
        }
Example #38
0
        public CPU(MemorySpace.Memory memory)
        {
            this._memory = memory;
            this._interruptController = new InterruptController(this._memory);

            // Initialize registers
            Reset();
            ResetBreakpoints();
        }
Example #39
0
 private static extern unsafe int _CumulativeRowSumRaw(PtrT A, uint nRows, uint nCols, MemorySpace memorySpace, MathDomain mathDomain);