/// <summary cref="MemoryBuffer{T, TIndex}.CopyToView( /// AcceleratorStream, ArrayView{T}, LongIndex1)"/> protected internal unsafe override void CopyToView( AcceleratorStream stream, ArrayView <T> target, LongIndex1 sourceOffset) { var binding = Accelerator.BindScoped(); var clStream = (CLStream)stream; switch (target.AcceleratorType) { case AcceleratorType.CPU: CLException.ThrowIfFailed( CurrentAPI.ReadBuffer( clStream.CommandQueue, NativePtr, false, new IntPtr(sourceOffset * ElementSize), new IntPtr(target.LengthInBytes), new IntPtr(target.LoadEffectiveAddress()))); break; case AcceleratorType.OpenCL: CLException.ThrowIfFailed( CurrentAPI.CopyBuffer( clStream.CommandQueue, NativePtr, target.Source.NativePtr, new IntPtr(sourceOffset * ElementSize), new IntPtr(target.Index * ElementSize), new IntPtr(target.LengthInBytes))); break; default: throw new NotSupportedException( RuntimeErrorMessages.NotSupportedTargetAccelerator); } binding.Recover(); }