1 #ifndef CAFFE_SYNCEDMEM_HPP_ 2 #define CAFFE_SYNCEDMEM_HPP_ 10 #include "caffe/common.hpp" 19 inline void CaffeMallocHost(
void** ptr,
size_t size,
bool* use_cuda) {
21 if (Caffe::mode() == Caffe::GPU) {
22 CUDA_CHECK(cudaMallocHost(ptr, size));
28 *ptr = mkl_malloc(size ? size:1, 64);
33 CHECK(*ptr) <<
"host allocation of size " << size <<
" failed";
36 inline void CaffeFreeHost(
void* ptr,
bool use_cuda) {
39 CUDA_CHECK(cudaFreeHost(ptr));
62 const void* cpu_data();
63 void set_cpu_data(
void* data);
64 const void* gpu_data();
65 void set_gpu_data(
void* data);
66 void* mutable_cpu_data();
67 void* mutable_gpu_data();
68 enum SyncedHead { UNINITIALIZED, HEAD_AT_CPU, HEAD_AT_GPU, SYNCED };
69 SyncedHead head() {
return head_; }
70 size_t size() {
return size_; }
73 void async_gpu_push(
const cudaStream_t& stream);
86 bool cpu_malloc_use_cuda_;
95 #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:57