Skip to content
Snippets Groups Projects
Commit d545d668 authored by 数学の武士's avatar 数学の武士
Browse files

.

parent 34b020b3
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment