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")); }
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);
public void SetMemorySpace(string name, MemorySpace space) { arrayLocations[name] = space; }
private static extern unsafe int _EyeRaw(PtrT pointer, uint nRows, MemorySpace memorySpace, MathDomain mathDomain);
private static extern unsafe int _ScaleRaw(PtrT z, uint size, MemorySpace memorySpace, MathDomain mathDomain, double alpha);
private static extern unsafe int _SubtractEqualRaw(PtrT z, PtrT x, uint size, MemorySpace memorySpace, MathDomain mathDomain);
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);
private static extern unsafe int _AddEqualRaw(PtrT z, PtrT x, uint size, MemorySpace memorySpace, MathDomain mathDomain, double alpha);
private static extern unsafe int _IsNonZeroRaw(PtrT z, PtrT x, uint size, MemorySpace memorySpace, MathDomain mathDomain);
private static extern unsafe int _InvertRaw(PtrT A, uint nRows, uint nCols, MemorySpace memorySpace, MathDomain mathDomain, MatrixOperation aOperation);
private static extern unsafe int _SparseAddRaw(PtrT z, PtrT x, PtrT y, uint nNonZeros, PtrT nonZeroIndices, MemorySpace memorySpace, MathDomain mathDomain, uint size, double alpha);
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);
private static extern unsafe int _ElementwiseProductRaw(PtrT z, PtrT x, PtrT y, uint size, MemorySpace memorySpace, MathDomain mathDomain, double alpha = 1.0);
public ValueMemory(dynamic value, MemorySpace memory) { Value = value; Memory = memory; }
internal ContiguousMemoryBuffer(bool isOwner = true, MemorySpace memorySpace = MemorySpace.Device, MathDomain mathDomain = MathDomain.Float) { this.isOwner = isOwner; this.memorySpace = memorySpace; this.mathDomain = mathDomain; }
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); }
private static extern unsafe int _InitializeRaw(PtrT pointer, uint size, MemorySpace memorySpace, MathDomain mathDomain, double value);
private static extern unsafe int _LinSpaceRaw(PtrT pointer, uint size, MemorySpace memorySpace, MathDomain mathDomain, double x0, double x1);
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);
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);
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); }
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); }
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);
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; }
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); }
public CPU(MemorySpace.Memory memory) { this._memory = memory; this._interruptController = new InterruptController(this._memory); // Initialize registers Reset(); ResetBreakpoints(); }
private static extern unsafe int _CumulativeRowSumRaw(PtrT A, uint nRows, uint nCols, MemorySpace memorySpace, MathDomain mathDomain);