public VolumeStorage(VolumeStorage storage, Shape newShape) : base(newShape) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } if (storage._hostPointer == null) { throw new ArgumentException(); } this._isOwner = false; this._hostPointer = storage._hostPointer; this.Shape = newShape; this.Context = storage.Context; this._allocatedOnDevice = storage._allocatedOnDevice; storage.CopyToDevice(); this.Location = DataLocation.Device; this.DeviceBuffer = new CudaDeviceVariable <double>(storage.DeviceBuffer.DevicePointer); this.ConvolutionBackwardFilterStorage = storage.ConvolutionBackwardFilterStorage; this.ConvolutionBackwardStorage = storage.ConvolutionBackwardStorage; this.ConvolutionStorage = storage.ConvolutionStorage; this.ReductionStorage = storage.ReductionStorage; this.DropoutStorage = storage.DropoutStorage; this.DropoutStateStorage = storage.DropoutStateStorage; }
private static CudaHostMemoryRegion InitializeSharedMemory(long elementCount) { var sharedMemory = new CudaHostMemoryRegion(elementCount * sizeof(double)); // Zero out FillWithZeroes(sharedMemory.Start, sharedMemory.ByteCount); return(sharedMemory); }
public VolumeStorage(Shape shape, GpuContext context, long length = -1) : base(shape) { this.Context = context; // Take care of unkown dimension if (length != -1) { this.Shape.GuessUnkownDimension(length); } // Host this._hostPointer = InitializeSharedMemory(this.Shape.TotalLength); this._isOwner = true; }