a bunch of updates. to be checked on durian. does not build.
[jacinto-ai/caffe-jacinto.git] / src / caffeine / syncedmem.hpp
1 #ifndef CAFFEINE_SYNCEDMEM_HPP
2 #define CAFFEINE_SYNCEDMEM_HPP
4 namespace caffeine {
6 class SyncedMemory {
7  public:
8   SyncedMemory()
9       : cpu_ptr_(NULL), gpu_ptr_(NULL), size_(0), head_(UNINITIALIZED) {};
10   explicit SyncedMemory(size_t size)
11       : cpu_ptr_(NULL), gpu_ptr_(NULL), size_(size), head_(UNINITIALIZED) {};
12   ~SyncedMemory();
13   const void* cpu_data();
14   const void* gpu_data();
15   void* mutable_cpu_data();
16   void* mutable_gpu_data();
17   enum SyncedHead { UNINITIALIZED, HEAD_AT_CPU, HEAD_AT_GPU, SYNCED };
18   SyncedHead head() { return head_; }
19  private:
20   void to_cpu();
21   void to_gpu();
22   void* cpu_ptr_;
23   void* gpu_ptr_;
24   size_t size_;
25   SyncedHead head_;
26 };  // class SyncedMemory
28 }  // namespace caffeine
30 #endif  // CAFFEINE_SYNCEDMEM_HPP_