1 #ifndef CAFFE_SYNCEDMEM_HPP_ 2 #define CAFFE_SYNCEDMEM_HPP_ 6 #include "caffe/common.hpp" 15 inline void CaffeMallocHost(
void** ptr,
size_t size,
bool* use_cuda) {
17 if (Caffe::mode() == Caffe::GPU) {
18 CUDA_CHECK(cudaMallocHost(ptr, size));
25 CHECK(*ptr) <<
"host allocation of size " << size <<
" failed";
28 inline void CaffeFreeHost(
void* ptr,
bool use_cuda) {
31 CUDA_CHECK(cudaFreeHost(ptr));
48 : cpu_ptr_(NULL), gpu_ptr_(NULL), size_(0), head_(UNINITIALIZED),
49 own_cpu_data_(
false), cpu_malloc_use_cuda_(
false), own_gpu_data_(
false),
52 : cpu_ptr_(NULL), gpu_ptr_(NULL), size_(size), head_(UNINITIALIZED),
53 own_cpu_data_(
false), cpu_malloc_use_cuda_(
false), own_gpu_data_(
false),
56 const void* cpu_data();
57 void set_cpu_data(
void* data);
58 const void* gpu_data();
59 void set_gpu_data(
void* data);
60 void* mutable_cpu_data();
61 void* mutable_gpu_data();
62 enum SyncedHead { UNINITIALIZED, HEAD_AT_CPU, HEAD_AT_GPU, SYNCED };
63 SyncedHead head() {
return head_; }
64 size_t size() {
return size_; }
67 void async_gpu_push(
const cudaStream_t& stream);
78 bool cpu_malloc_use_cuda_;
87 #endif // CAFFE_SYNCEDMEM_HPP_ A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14
Manages memory allocation and synchronization between the host (CPU) and device (GPU).
Definition: syncedmem.hpp:45