diff options
author | Kai Li <kaili_kloud@163.com> | 2014-07-10 01:57:16 +0800 |
---|---|---|
committer | Kai Li <kaili_kloud@163.com> | 2014-07-10 08:03:22 +0800 |
commit | ac0dd39252812aba1f67b9b0b0e18e62ea1742e6 (patch) | |
tree | d826783cb6e47e1ee8bb6655c378171fa78922d4 /src/caffe | |
parent | 00433d8082796bdaa2cafa067c158a5f31245985 (diff) | |
download | caffeonacl-ac0dd39252812aba1f67b9b0b0e18e62ea1742e6.tar.gz caffeonacl-ac0dd39252812aba1f67b9b0b0e18e62ea1742e6.tar.bz2 caffeonacl-ac0dd39252812aba1f67b9b0b0e18e62ea1742e6.zip |
Implement @Yangqing's solution to copy memory in the SyncedMemory
Diffstat (limited to 'src/caffe')
-rw-r--r-- | src/caffe/syncedmem.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/caffe/syncedmem.cpp b/src/caffe/syncedmem.cpp index 5d6d0585..3f9a3be9 100644 --- a/src/caffe/syncedmem.cpp +++ b/src/caffe/syncedmem.cpp @@ -33,8 +33,7 @@ inline void SyncedMemory::to_cpu() { CaffeMallocHost(&cpu_ptr_, size_); own_cpu_data_ = true; } - Caffe::set_mode(Caffe::GPU); - caffe_memcpy(size_, gpu_ptr_, cpu_ptr_); + CUDA_CHECK(cudaMemcpy(cpu_ptr_, gpu_ptr_, size_, cudaMemcpyDefault)); head_ = SYNCED; break; case HEAD_AT_CPU: @@ -54,8 +53,7 @@ inline void SyncedMemory::to_gpu() { if (gpu_ptr_ == NULL) { CUDA_CHECK(cudaMalloc(&gpu_ptr_, size_)); } - Caffe::set_mode(Caffe::GPU); - caffe_memcpy(size_, cpu_ptr_, gpu_ptr_); + CUDA_CHECK(cudaMemcpy(gpu_ptr_, cpu_ptr_, size_, cudaMemcpyDefault)); head_ = SYNCED; break; case HEAD_AT_GPU: |