diff options
author | Ronghang Hu <huronghang@hotmail.com> | 2015-09-16 13:39:23 -0700 |
---|---|---|
committer | Ronghang Hu <huronghang@hotmail.com> | 2015-09-25 15:52:46 -0700 |
commit | bd5f15427cc2f008f80378a5948ce379d93ebde6 (patch) | |
tree | 419b87840e2824258e1d5df598dcac211ae4935f /src/caffe | |
parent | 71e05876f644a08af4cb1c955d01c5a272539e96 (diff) | |
download | caffeonacl-bd5f15427cc2f008f80378a5948ce379d93ebde6.tar.gz caffeonacl-bd5f15427cc2f008f80378a5948ce379d93ebde6.tar.bz2 caffeonacl-bd5f15427cc2f008f80378a5948ce379d93ebde6.zip |
Add flag on how host memory is allocated
Add a bool flag to record whether a host memory is allocated using malloc or
cudaMallocHost, and free correspondingly using this flag, instead of depending on Caffe::mode(), which is mutable during runtime.
Diffstat (limited to 'src/caffe')
-rw-r--r-- | src/caffe/syncedmem.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/caffe/syncedmem.cpp b/src/caffe/syncedmem.cpp index a667a867..632bf1f1 100644 --- a/src/caffe/syncedmem.cpp +++ b/src/caffe/syncedmem.cpp @@ -8,7 +8,7 @@ namespace caffe { SyncedMemory::~SyncedMemory() { if (cpu_ptr_ && own_cpu_data_) { - CaffeFreeHost(cpu_ptr_); + CaffeFreeHost(cpu_ptr_, cpu_malloc_use_cuda_); } #ifndef CPU_ONLY @@ -27,7 +27,7 @@ SyncedMemory::~SyncedMemory() { inline void SyncedMemory::to_cpu() { switch (head_) { case UNINITIALIZED: - CaffeMallocHost(&cpu_ptr_, size_); + CaffeMallocHost(&cpu_ptr_, size_, &cpu_malloc_use_cuda_); caffe_memset(size_, 0, cpu_ptr_); head_ = HEAD_AT_CPU; own_cpu_data_ = true; @@ -35,7 +35,7 @@ inline void SyncedMemory::to_cpu() { case HEAD_AT_GPU: #ifndef CPU_ONLY if (cpu_ptr_ == NULL) { - CaffeMallocHost(&cpu_ptr_, size_); + CaffeMallocHost(&cpu_ptr_, size_, &cpu_malloc_use_cuda_); own_cpu_data_ = true; } caffe_gpu_memcpy(size_, gpu_ptr_, cpu_ptr_); @@ -86,7 +86,7 @@ const void* SyncedMemory::cpu_data() { void SyncedMemory::set_cpu_data(void* data) { CHECK(data); if (own_cpu_data_) { - CaffeFreeHost(cpu_ptr_); + CaffeFreeHost(cpu_ptr_, cpu_malloc_use_cuda_); } cpu_ptr_ = data; head_ = HEAD_AT_CPU; |