Skip to content

Commit

Permalink
Add debug msg
Browse files Browse the repository at this point in the history
  • Loading branch information
Keita Iwabuchi committed Jan 24, 2025
1 parent a06f3c2 commit 9600beb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions include/metall/container/fallback_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,12 @@ class fallback_allocator_adaptor {
/// \param n The size to allocation
/// \return Returns a pointer
pointer allocate(const size_type n) const {
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
if (priv_stateful_allocator_available()) {
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
return m_stateful_allocator.allocate(n);
}
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
return priv_fallback_allocate(n);
}

Expand Down
7 changes: 5 additions & 2 deletions include/metall/kernel/manager_kernel_impl.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,17 @@ template <typename st, typename sst, typename cn, std::size_t cs>
void *manager_kernel<st, sst, cn, cs>::allocate(
const manager_kernel<st, sst, cn, cs>::size_type nbytes) {
priv_check_sanity();
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
if (m_segment_storage.read_only()) return nullptr;

std::cerr << __FILE__ << " " << __LINE__ << std::endl;
const auto offset = m_segment_memory_allocator.allocate(nbytes);
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
if (offset == segment_memory_allocator::k_null_offset) {
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
return nullptr;
}
assert(offset >= 0);

std::cerr << __FILE__ << " " << __LINE__ << std::endl;
return priv_to_address(offset);
}

Expand Down
5 changes: 4 additions & 1 deletion include/metall/kernel/segment_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class segment_allocator {
: priv_allocate_large_object(bin_no);
assert(offset >= 0 || offset == k_null_offset);

std::cerr << __FILE__ << " " << __LINE__ << " offset = " << offset
<< std::endl;
return offset;
}

Expand Down Expand Up @@ -196,7 +198,8 @@ class segment_allocator {

// Internal allocation size must be a multiple of alignment
assert(bin_no_mngr::to_object_size(bin_no_mngr::to_bin_no(nbytes)) %
alignment == 0);
alignment ==
0);

// As long as the above requirements are satisfied, just calling the normal
// allocate function is enough
Expand Down
9 changes: 7 additions & 2 deletions include/metall/stl_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,27 +156,32 @@ class stl_allocator {
// -------------------- //

pointer priv_allocate(const size_type n) const {
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
if (priv_max_size() < n) {
throw std::bad_array_new_length();
}

std::cerr << __FILE__ << " " << __LINE__ << std::endl;
if (!get_pointer_to_manager_kernel()) {
logger::out(logger::level::error, __FILE__, __LINE__,
"nullptr: cannot access to manager kernel");
throw std::bad_alloc();
}
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
auto* manager_kernel = *get_pointer_to_manager_kernel();
if (!manager_kernel) {
logger::out(logger::level::error, __FILE__, __LINE__,
"nullptr: cannot access to manager kernel");
throw std::bad_alloc();
}

std::cerr << __FILE__ << " " << __LINE__ << " Allocate (bytes) " << n * sizeof(T) << std::endl;
auto addr = pointer(
static_cast<value_type *>(manager_kernel->allocate(n * sizeof(T))));
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
if (!addr) {
std::cerr << __FILE__ << " " << __LINE__ << std::endl;
throw std::bad_alloc();
}
std::cerr << __FILE__ << " " << __LINE__ << std::endl;

return addr;
}
Expand Down

0 comments on commit 9600beb

Please sign in to comment.