@ Override public void memcpy ( DataBuffer dstBuffer , DataBuffer srcBuffer ) { CudaContext context = ( CudaContext ) AtomicAllocator . getInstance ( ) . getDeviceContext ( ) . getContext ( ) ; if ( dstBuffer instanceof CompressedDataBuffer && ! ( srcBuffer instanceof CompressedDataBuffer ) ) { // destination is compressed, source isn't AllocationPoint srcPoint = AtomicAllocator . getInstance ( ) . getAllocationPoint ( srcBuffer ) ; long size = srcBuffer . getElementSize ( ) * srcBuffer . length ( ) ; if ( ! srcPoint . isActualOnHostSide ( ) ) { // copying device -> host AtomicAllocator . getInstance ( ) . synchronizeHostData ( srcBuffer ) ; // Pointer src = AtomicAllocator.getInstance().getPointer(srcBuffer, context); // NativeOpsHolder.getInstance().getDeviceNativeOps().memcpyAsync(dstBuffer.addressPointer(), src, size, 2, context.getSpecialStream()); // context.syncSpecialStream(); } // else { // copying host -> host Pointer src = AtomicAllocator . getInstance ( ) . getHostPointer ( srcBuffer ) ; Pointer . memcpy ( dstBuffer . addressPointer ( ) , src , size ) ; // } } else if ( ! ( dstBuffer instanceof CompressedDataBuffer ) && srcBuffer instanceof CompressedDataBuffer ) { // destination is NOT compressed, source is compressed AllocationPoint dstPoint = AtomicAllocator . getInstance ( ) . getAllocationPoint ( dstBuffer ) ; long size = srcBuffer . getElementSize ( ) * srcBuffer . length ( ) ; Pointer . memcpy ( dstBuffer . addressPointer ( ) , srcBuffer . addressPointer ( ) , size ) ; dstPoint . tickHostWrite ( ) ; } else if ( dstBuffer instanceof CompressedDataBuffer && srcBuffer instanceof CompressedDataBuffer ) { // both buffers are compressed, just fire memcpy Pointer . memcpy ( dstBuffer . addressPointer ( ) , srcBuffer . addressPointer ( ) , srcBuffer . length ( ) * srcBuffer . getElementSize ( ) ) ; } else { // both buffers are NOT compressed AtomicAllocator . getInstance ( ) . memcpy ( dstBuffer , srcBuffer ) ; } }
This method provides basic memcpy functionality with respect to target environment