diff --git a/CMakeLists.txt b/CMakeLists.txt index e4b45b541a4f6d14a18cd315c0ce4f6eb7a4cea0..07927d4c1c6f1419b7a08520fc1a275762b05e22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,5 +27,5 @@ set(SOURCES ) add_executable(test ${SOURCES}) -target_include_directories(test PUBLIC ${memory_processing_SOURCE_DIR}/include ./Lib/) -target_link_libraries(test memproc memory-holder) \ No newline at end of file +target_include_directories(test PUBLIC ./Lib/) +target_link_libraries(test memory-holder) \ No newline at end of file diff --git a/Lib/memory-holder.cpp b/Lib/memory-holder.cpp index ef12ee1d2ac30bcab8c0c34a01b220f4bb231b69..cd8bc174b972431f3643fb7dda9c85c92e007127 100644 --- a/Lib/memory-holder.cpp +++ b/Lib/memory-holder.cpp @@ -52,7 +52,9 @@ bool size_comparator(const buffer<mem>& obj, const size_t required_size) } template bool size_comparator(const buffer<MemType::CPU>& obj, const size_t required_size); +#ifdef INCLUDE_CUDA template bool size_comparator(const buffer<MemType::GPU>& obj, const size_t required_size); +#endif template< MemType mem > void* buffer<mem>::get_ptr() const @@ -78,6 +80,7 @@ buffer<mem>& buffer<mem>::operator=(buffer<mem>& other) if (this == &other) return *this; + // memproc::realloc<mem>((void*&)ptr, allocated_size, other.get_size()); std::swap(ptr, other.ptr); std::swap(allocated_size, other.allocated_size); // exchange resources between *this and other std::swap(scalar_size, other.scalar_size); @@ -99,17 +102,23 @@ void buffer<mem>::set_id(const int idx) } template class buffer<MemType::CPU>; +#ifdef INCLUDE_CUDA template class buffer<MemType::GPU>; +#endif memory_pipline::memory_pipline() { +#ifdef INCLUDE_CUDA gpu_buff = std::vector<buffer<MemType::GPU> > (); +#endif cpu_buff = std::vector<buffer<MemType::CPU> > (); } memory_pipline::~memory_pipline() { +#ifdef INCLUDE_CUDA gpu_buff.clear(); +#endif cpu_buff.clear(); } @@ -119,14 +128,13 @@ std::vector<buffer<mem> >& memory_pipline::get_memtyped_vector() return cpu_buff; } +#ifdef INCLUDE_CUDA template<> std::vector<buffer<MemType::GPU> >& memory_pipline::get_memtyped_vector() { return gpu_buff; } - -// template std::vector<buffer<MemType::CPU> >& memory_pipline::get_memtyped_vector(); -// template std::vector<buffer<MemType::GPU> >& memory_pipline::get_memtyped_vector(); +#endif template< MemType mem > int memory_pipline::get_buffer(const size_t required_size, void * ptr) @@ -149,7 +157,9 @@ int memory_pipline::get_buffer(const size_t required_size, void * ptr) } template int memory_pipline::get_buffer<MemType::CPU>(const size_t required_size, void * ptr); +#ifdef INCLUDE_CUDA template int memory_pipline::get_buffer<MemType::GPU>(const size_t required_size, void * ptr); +#endif template< MemType mem > void memory_pipline::set_available(const int id) @@ -158,7 +168,9 @@ void memory_pipline::set_available(const int id) } template void memory_pipline::set_available<MemType::CPU>(const int id); +#ifdef INCLUDE_CUDA template void memory_pipline::set_available<MemType::GPU>(const int id); +#endif memory_faucet::memory_faucet(){} @@ -184,8 +196,8 @@ memBuf<mem>::memBuf(const size_t required_size) template< MemType mem > memBuf<mem>::~memBuf() { - memory_pipline* mem_pipe = memory_faucet::get_faucet(); - mem_pipe->set_available<mem>(id); + // memory_pipline* mem_pipe = memory_faucet::get_faucet(); + // mem_pipe->set_available<mem>(id); } template< MemType mem > @@ -201,4 +213,6 @@ int memBuf<mem>::get_size() } template class memBuf<MemType::CPU>; -template class memBuf<MemType::GPU>; \ No newline at end of file +#ifdef INCLUDE_CUDA +template class memBuf<MemType::GPU>; +#endif diff --git a/Lib/memory-holder.h b/Lib/memory-holder.h index 0e1dd457c8e9b0b5e41aef59410c39aeaa2c60a1..860576c34b1283d871bdcd962ccfd55288ba4edc 100644 --- a/Lib/memory-holder.h +++ b/Lib/memory-holder.h @@ -38,7 +38,9 @@ public: class memory_pipline { private: +#ifdef INCLUDE_CUDA std::vector<buffer<MemType::GPU> > gpu_buff; +#endif std::vector<buffer<MemType::CPU> > cpu_buff; public: memory_pipline();