Skip to content

Commit

Permalink
Merge branch 'feature/segment_storage' into feature/custom_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
KIwabuchi committed Dec 8, 2023
2 parents 45c3f92 + abf6d86 commit af466ca
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 336 deletions.
10 changes: 7 additions & 3 deletions include/metall/basic_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ class basic_manager {
}

/// \brief Creates a new data store (an existing data store will be
/// overwritten). \param base_path Path to create a data store. \param
/// capacity Maximum total allocation size.
/// overwritten).
/// \param base_path Path to create a data store.
/// \param capacity Total allocation size. Metall uses this value as a hint.
// The actual limit could be smaller or larger than this value, depending on
// the internal implementation. However, a close minimum capacity should be
// available.
basic_manager(create_only_t, const path_type &base_path,
const size_type capacity) noexcept {
try {
Expand Down Expand Up @@ -1291,7 +1295,7 @@ class basic_manager {
}
try {
return allocator_type<T>(reinterpret_cast<manager_kernel_type *const *>(
&(m_kernel->get_segment_header()->manager_kernel_address)));
&(m_kernel->get_segment_header().manager_kernel_address)));
} catch (...) {
logger::out(logger::level::error, __FILE__, __LINE__,
"An exception has been thrown");
Expand Down
2 changes: 1 addition & 1 deletion include/metall/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#endif

// --------------------
// Macros for the default segment storage manager
// Macros for the default segment storage
// --------------------

/// \def METALL_SEGMENT_BLOCK_SIZE
Expand Down
25 changes: 4 additions & 21 deletions include/metall/kernel/manager_kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,6 @@ class manager_kernel {
static_assert(k_default_vm_reserve_size <= k_max_segment_size,
"k_default_vm_reserve_size must be <= k_max_segment_size");

#ifndef METALL_SEGMENT_BLOCK_SIZE
#error "METALL_SEGMENT_BLOCK_SIZE is not defined."
#endif
static constexpr size_type k_initial_segment_size = METALL_SEGMENT_BLOCK_SIZE;
static_assert(k_initial_segment_size <= k_default_vm_reserve_size,
"k_initial_segment_size must be <= k_default_vm_reserve_size");
static_assert(k_chunk_size <= k_initial_segment_size,
"Chunk size must be <= k_initial_segment_size");

using segment_header_type = segment_header;
static constexpr size_type k_segment_header_size =
mdtl::round_up(sizeof(segment_header_type), k_chunk_size);
Expand Down Expand Up @@ -344,9 +335,9 @@ class manager_kernel {
T *generic_construct(char_ptr_holder_type name, size_type num, bool try2find,
bool do_throw, mdtl::in_place_interface &table);

/// \brief Get the address of the segment header.
/// \return Returns the address of the segment header.
const segment_header_type *get_segment_header() const;
/// \brief Return a reference to the segment header.
/// \return A reference to the segment header.
const segment_header_type &get_segment_header() const;

/// \brief Get the address of the application segment segment.
/// \return Returns the address of the application segment segment.
Expand Down Expand Up @@ -481,7 +472,7 @@ class manager_kernel {
// Private methods
// -------------------- //

void priv_sanity_check() const;
void priv_check_sanity() const;
bool priv_validate_runtime_configuration() const;
difference_type priv_to_offset(const void *ptr) const;
void *priv_to_address(difference_type offset) const;
Expand Down Expand Up @@ -521,11 +512,6 @@ class manager_kernel {
void priv_destruct_and_free_memory(difference_type offset, size_type length);

// ---------- For segment ---------- //
bool priv_reserve_vm_region(size_type nbytes);
bool priv_release_vm_region();
bool priv_allocate_segment_header(void *addr);
bool priv_deallocate_segment_header();

bool priv_open(const path_type &base_path, bool read_only,
size_type vm_reserve_size_request = 0);
bool priv_create(const path_type &base_path, size_type vm_reserve_size);
Expand Down Expand Up @@ -571,9 +557,6 @@ class manager_kernel {
// -------------------- //
bool m_good{false};
path_type m_base_path{};
size_type m_vm_region_size{0};
void *m_vm_region{nullptr};
segment_header_type *m_segment_header{nullptr};
attributed_object_directory_type m_named_object_directory{};
attributed_object_directory_type m_unique_object_directory{};
attributed_object_directory_type m_anonymous_object_directory{};
Expand Down
Loading

0 comments on commit af466ca

Please sign in to comment.