MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / CaffeMallocHost

Function CaffeMallocHost

rtpose_wrapper/include/caffe/syncedmem.hpp:15–26  ·  view source on GitHub ↗

If CUDA is available and in GPU mode, host memory will be allocated pinned, using cudaMallocHost. It avoids dynamic pinning for transfers (DMA). The improvement in performance seems negligible in the single GPU case, but might be more significant for parallel training. Most importantly, it improved stability for large models on many GPUs.

Source from the content-addressed store, hash-verified

13// but might be more significant for parallel training. Most importantly,
14// it improved stability for large models on many GPUs.
15inline void CaffeMallocHost(void** ptr, size_t size, bool* use_cuda) {
16#ifndef CPU_ONLY
17 if (Caffe::mode() == Caffe::GPU) {
18 CUDA_CHECK(cudaMallocHost(ptr, size));
19 *use_cuda = true;
20 return;
21 }
22#endif
23 *ptr = malloc(size);
24 *use_cuda = false;
25 CHECK(*ptr) << "host allocation of size " << size << " failed";
26}
27
28inline void CaffeFreeHost(void* ptr, bool use_cuda) {
29#ifndef CPU_ONLY

Callers 1

to_cpuMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected