MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / CopyToCPUHelper

Function CopyToCPUHelper

paddle/phi/core/mixed_vector.cc:33–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32template <typename T>
33void CopyToCPUHelper(std::vector<T> *cpu_,
34 Allocator::AllocationPtr *gpu_,
35 size_t *gpu_memory_size_) {
36#if defined(PADDLE_WITH_CUSTOM_DEVICE)
37 // COPY Custom Device Data To CPU
38 auto *dev_ctx = static_cast<CustomContext *>(
39 DeviceContextPool::Instance().Get((*gpu_)->place()));
40 auto stream = dev_ctx->stream();
41 void *src = (*gpu_)->ptr();
42 void *dst = cpu_->data();
43 memory_utils::Copy(CPUPlace(),
44 dst,
45 OptionalCustomPlace(*gpu_).get(),
46 src,
47 *gpu_memory_size_,
48 stream);
49 dev_ctx->Wait();
50#elif defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
51 // COPY GPU Data To CPU
52 auto *dev_ctx = static_cast<GPUContext *>(
53 DeviceContextPool::Instance().Get((*gpu_)->place()));
54 auto stream = dev_ctx->stream();
55 void *src = (*gpu_)->ptr();
56 void *dst = cpu_->data();
57 memory_utils::Copy(CPUPlace(),
58 dst,
59 OptionalCUDAPlace(*gpu_).get(),
60 src,
61 *gpu_memory_size_,
62 stream);
63 dev_ctx->Wait();
64#endif
65}
66
67template <typename T>
68void CopyCPUDataToCUDAHelper(std::vector<T> *cpu_,

Callers

nothing calls this directly

Calls 12

InstanceFunction · 0.85
OptionalCustomPlaceFunction · 0.85
OptionalCUDAPlaceFunction · 0.85
CopyFunction · 0.70
CPUPlaceClass · 0.50
GetMethod · 0.45
placeMethod · 0.45
streamMethod · 0.45
ptrMethod · 0.45
dataMethod · 0.45
getMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected