Skip to content

Commit

Permalink
Remove debug codes
Browse files Browse the repository at this point in the history
  • Loading branch information
do-jason committed Dec 1, 2023
1 parent c2edd63 commit 6ebf335
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 81 deletions.
62 changes: 1 addition & 61 deletions src/acc/sycl/sycl_memory_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,6 @@ syclMemoryBlock::~syclMemoryBlock()
if (_mem)
{
sycl::free(_mem, *_Q);
#ifdef DEBUG_SYCL_MEMORY_POOL
if (_alloc_list.size() != 0)
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! ERROR/destructor !!] There is _alloc_list(" << _alloc_bytes << " bytes/ " << _alloc_list.size() << ") remained\n" << std::flush;
if (_free_list.size() == 0)
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/destructor !!] There is no _free_list\n" << std::flush;
if (_free_list.size() > 1)
{
size_t size = 0;
for (const auto& f : _free_list)
{
size += f.second - f.first;
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/_free_list !!] " << f.first << " ~ " << f.second << " \n" << std::flush;
}
if (size != _free_bytes)
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/destructor !!] There is mismatch in _free_list size: " << _free_bytes << " vs " << size << "\n" << std::flush;
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/destructor !!] There is not-merged _free_list(" << _free_bytes << " bytes/ " << _free_list.size() << ")\n" << std::flush;
}
if (_rfree_list.size() == 0)
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/destructor !!] There is no _rfree_list\n" << std::flush;
if (_rfree_list.size() > 1)
{
size_t size = 0;
for (const auto& r : _rfree_list)
{
size += r.first - r.second;
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/_rfree_list !!] " << r.second << " ~ " << r.first << " \n" << std::flush;
}
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/destructor !!] There is not-merged _rfree_list(" << size << " bytes/ " << _rfree_list.size() << ")\n" << std::flush;
}
#endif
#ifdef DIAG_SYCL_MEMORY_POOL
printStats();
#endif
Expand All @@ -80,36 +50,6 @@ void syclMemoryBlock::clean()
if (_mem)
{
std::lock_guard<std::mutex> locker(_container_lock[_blockID].mutex);
#ifdef DEBUG_SYCL_MEMORY_POOL
if (_alloc_list.size() != 0)
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! ERROR/clean !!] There is _alloc_list(" << _alloc_bytes << " bytes/ " << _alloc_list.size() << ") remained\n" << std::flush;
if (_free_list.size() == 0)
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/clean !!] There is no _free_list\n" << std::flush;
if (_free_list.size() > 1)
{
size_t size = 0;
for (const auto& f : _free_list)
{
size += f.second - f.first;
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/_free_list !!] " << f.first << " ~ " << f.second << " \n" << std::flush;
}
if (size != _free_bytes)
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/clean !!] There is mismatch in _free_list size: " << _free_bytes << " vs " << size << "\n" << std::flush;
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/clean !!] There is not-merged _free_list(" << _free_bytes << " bytes/ " << _free_list.size() << ")\n" << std::flush;
}
if (_rfree_list.size() == 0)
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/clean !!] There is no _rfree_list\n" << std::flush;
if (_rfree_list.size() > 1)
{
size_t size = 0;
for (const auto& r : _rfree_list)
{
size += r.first - r.second;
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/_rfree_list !!] " << r.second << " ~ " << r.first << " \n" << std::flush;
}
std::cerr << (_mem_type == alloc_kind::device ? "DEVICE" : "HOST") << " [!! BUG/clean !!] There is not-merged _rfree_list(" << size << " bytes/ " << _rfree_list.size() << ")\n" << std::flush;
}
#endif
#ifdef DIAG_SYCL_MEMORY_POOL
printStats();
#endif
Expand Down Expand Up @@ -294,7 +234,7 @@ void syclMemoryPool::shrink(const size_t num)
while (it != _memory_block_list.end())
{
if (it->empty())
it = _memory_block_list.erase(it);
it = _memory_block_list.erase(it);
else if (count >= num && it->isUnused())
it = _memory_block_list.erase(it);
else
Expand Down
20 changes: 0 additions & 20 deletions src/acc/sycl/sycl_memory_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
#include <utility>
#include <list>
#include <map>
#include <unordered_map>
#include <sycl/sycl.hpp>

using memoryStorage = std::byte*;
using memoryAllocMap = std::map<memoryStorage,memoryStorage>;
using memoryFreeMap = std::map<memoryStorage,memoryStorage>;
//using memoryFreeMap = std::unordered_map<memoryStorage,memoryStorage>;
using memoryFreeSizeMap = std::multimap<size_t,std::pair<memoryStorage,memoryStorage>>;
using alloc_kind = sycl::usm::alloc;

Expand Down Expand Up @@ -97,21 +95,3 @@ class syclMemoryPool
std::list<syclMemoryBlock> _memory_block_list;
inline static std::mutex _mem_lock;
};

// TO-DO
template <typename T>
class syclMemoryPoolAllocator // std::allocator
{
using size_type = size_t;
using difference_type = ptrdiff_t;
using pointer = T*;
using const_pointer = const T*;
using reference = T&;
using const_reference = const T&;
using value_type = T;
};

template <typename T>
class syclMemoryPoolPolyAllocator // std::pmr::polymorphic_allocator
{
};

0 comments on commit 6ebf335

Please sign in to comment.