public MatrixOutput(CudaProvider cuda, int rows, int columns, int count, bool setToZero) { //_cuda = cuda; _rows = rows; _columns = columns; for (var i = 0; i < count; i++) { _data.Add(setToZero ? cuda.CreateZeroMatrix(rows, columns) : cuda.CreateMatrix(rows, columns) ); } _ptr = _data.Cast <GpuMatrix>().Select(m => m.Memory.DevicePointer).ToArray(); }
/// <summary> /// Initialize and verify that the provided is indeed available. /// If calling this method fails, consider to fall back to alternatives like the managed provider. /// </summary> public override void InitializeVerify() { CudaProvider.Load(minRevision: 1, hintPath: _hintPath); int linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor); // we only support exactly one major version, since major version changes imply a breaking change. if (linearAlgebra != 1) { throw new NotSupportedException(string.Format("Cuda Native Provider not compatible. Expecting linear algebra v1 but provider implements v{0}.", linearAlgebra)); } BLAS(SafeNativeMethods.createBLASHandle(ref _blasHandle)); Solver(SafeNativeMethods.createSolverHandle(ref _solverHandle)); }
public Block(DeviceMemory cache, int index, int size) { _cache = cache; Index = index; var sizeInBytes = size * CudaProvider.FLOAT_SIZE; var ptr = new CUdeviceptr(); var result = DriverAPINativeMethods.MemoryManagement.cuMemAlloc_v2(ref ptr, sizeInBytes); CudaProvider.CheckForError(result); DeviceVariable = new CudaDeviceVariable <float>(ptr, true, sizeInBytes); #if DEBUG if (Index == _badAlloc) { Debugger.Break(); } #endif }
/// <summary> /// Initialize and verify that the provided is indeed available. /// If calling this method fails, consider to fall back to alternatives like the managed provider. /// </summary> public override void InitializeVerify() { int revision = CudaProvider.Load(hintPath: _hintPath); if (revision < MinimumCompatibleRevision) { throw new NotSupportedException($"Cuda Native Provider revision r{revision} is too old. Consider upgrading to a newer version. Revision r{MinimumCompatibleRevision} and newer are supported."); } int linearAlgebra = SafeNativeMethods.query_capability((int)ProviderCapability.LinearAlgebraMajor); // we only support exactly one major version, since major version changes imply a breaking change. if (linearAlgebra != 1) { throw new NotSupportedException(string.Format("Cuda Native Provider not compatible. Expecting linear algebra v1 but provider implements v{0}.", linearAlgebra)); } BLAS(SafeNativeMethods.createBLASHandle(ref _blasHandle)); Solver(SafeNativeMethods.createSolverHandle(ref _solverHandle)); }
public TensorOutput(CudaProvider cuda, int rows, int columns, int depth, int count, bool setToZero) { _cuda = cuda; _rows = rows; _columns = columns; _depth = depth; _count = count; // allocate space for the output _data = setToZero ? cuda.CreateZeroMatrix(rows * columns * depth, count) : cuda.CreateMatrix(rows * columns * depth, count) ; // get the pointers for (var i = 0; i < count; i++) { var tensor = _data.Column(i).Split(depth).Cast <GpuVector>().Select(v => v.Memory).ToArray(); _ptr.Add(tensor); } }
public ConvolutionsData(CudaProvider cuda, List <(int X, int Y)> convolutions)
/// <summary> /// Frees memory buffers, caches and UnityEditor.Handles allocated in or to the provider. /// Does not unload the provider itself, it is still usable afterwards. /// </summary> public override void FreeResources() { CudaProvider.FreeResources(); }
/// <summary> /// Try to find out whether the provider is available, at least in principle. /// Verification may still fail if available, but it will certainly fail if unavailable. /// </summary> public override bool IsAvailable() { return(CudaProvider.IsAvailable(hintPath: _hintPath)); }
public override string ToString() { return(CudaProvider.Describe()); }
/// <summary> /// Try to find out whether the provider is available, at least in principle. /// Verification may still fail if available, but it will certainly fail if unavailable. /// </summary> public override bool IsAvailable() { return(CudaProvider.IsAvailable(minRevision: 1, hintPath: _hintPath)); }
/// <summary> /// Frees memory buffers, caches and handles allocated in or to the provider. /// Does not unload the provider itself, it is still usable afterwards. /// </summary> public void FreeResources() { CudaProvider.FreeResources(); }
/// <summary> /// Try to find out whether the provider is available, at least in principle. /// Verification may still fail if available, but it will certainly fail if unavailable. /// </summary> public override bool IsAvailable() { return(CudaProvider.IsAvailable(minRevision: 1)); }