@ Override public void relocate ( AllocationStatus currentStatus , AllocationStatus targetStatus , AllocationPoint point , AllocationShape shape , CudaContext context ) { //log.info("RELOCATE CALLED: [" +currentStatus+ "] -> ["+targetStatus+"]"); if ( currentStatus == AllocationStatus . DEVICE && targetStatus == AllocationStatus . HOST ) { // DEVICE -> HOST DataBuffer targetBuffer = point . getBuffer ( ) ; if ( targetBuffer == null ) throw new IllegalStateException ( "Target buffer is NULL!" ) ; Pointer devicePointer = new CudaPointer ( point . getPointers ( ) . getDevicePointer ( ) . address ( ) ) ; } else if ( currentStatus == AllocationStatus . HOST && targetStatus == AllocationStatus . DEVICE ) { // HOST -> DEVICE // TODO: this probably should be removed if ( point . isConstant ( ) ) { //log.info("Skipping relocation for constant"); return ; } if ( point . getPointers ( ) . getDevicePointer ( ) == null ) { throw new IllegalStateException ( "devicePointer is NULL!" ) ; } val profD = PerformanceTracker . getInstance ( ) . helperStartTransaction ( ) ; if ( nativeOps . memcpyAsync ( point . getPointers ( ) . getDevicePointer ( ) , point . getPointers ( ) . getHostPointer ( ) , AllocationUtils . getRequiredMemory ( shape ) , CudaConstants . cudaMemcpyHostToDevice , context . getSpecialStream ( ) ) == 0 ) throw new IllegalStateException ( "MemcpyAsync relocate H2D failed: [" + point . getHostPointer ( ) . address ( ) + "] -> [" + point . getDevicePointer ( ) . address ( ) + "]" ) ; flowController . commitTransfer ( context . getSpecialStream ( ) ) ; PerformanceTracker . getInstance ( ) . helperRegisterTransaction ( point . getDeviceId ( ) , profD , point . getNumberOfBytes ( ) , MemcpyDirection . HOST_TO_DEVICE ) ; //context.syncOldStream(); } else throw new UnsupportedOperationException ( "Can't relocate data in requested direction: [" + currentStatus + "] -> [" + targetStatus + "]" ) ; }
Copies specific chunk of memory from one storage to another