-
Notifications
You must be signed in to change notification settings - Fork 7
Make heap segment limits and sizes configurable #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b5b099b
Add heap_config to allow customizing segment limits and sizes
msimberg 8b27a3e
Add tests for heap_config
msimberg ceed1c8
Print invalid values in heap_config
msimberg a42ff84
Specify segment sizes same way as limits
msimberg ca54f36
Update copyright years
msimberg ffefcef
Put sstream include in right place
msimberg 752dfaf
Add missing spaces to log messages
msimberg 251320f
Update default heap_config and tests accordingly
msimberg 827c9f0
Update test_omp to use heap_config
msimberg 29e9f3b
Use EXPECT_EQ instead of EXPECT_TRUE in test_omp
msimberg 2078a51
Keep fewer segments in test_omp *.free tests so that buffers are real…
msimberg 6ddd2f0
Reduce duplication in the environment variable parsing
msimberg 32105b7
Move expected heap_config values to shared header for use in multiple…
msimberg f74ae0a
Move heap_config defaults (input parameters) into heap_config.hpp
msimberg 83b1711
Fix return type get_env
msimberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * ghex-org | ||
| * | ||
| * Copyright (c) 2014-2025, ETH Zurich | ||
| * All rights reserved. | ||
| * | ||
| * Please, refer to the LICENSE file in the root directory. | ||
| * SPDX-License-Identifier: BSD-3-Clause | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <cstddef> | ||
|
|
||
| namespace hwmalloc | ||
| { | ||
| namespace detail | ||
| { | ||
| inline constexpr std::size_t | ||
| log2_c(std::size_t n) noexcept | ||
| { | ||
| return ((n < 2) ? 1 : 1 + log2_c(n >> 1)); | ||
| } | ||
|
|
||
| inline constexpr std::size_t | ||
| round_to_pow_of_2(std::size_t n) noexcept | ||
| { | ||
| return 1u << log2_c(n - 1); | ||
| } | ||
| } // namespace detail | ||
|
|
||
| struct heap_config | ||
| { | ||
| static constexpr bool never_free_default = false; | ||
| static constexpr std::size_t num_reserve_segments_default = 16u; | ||
| static constexpr std::size_t tiny_limit_default = 128u; // 128B | ||
| static constexpr std::size_t small_limit_default = 4096u; // 4KiB | ||
| static constexpr std::size_t large_limit_default = 2097152u; // 2MiB | ||
| static constexpr std::size_t tiny_segment_size_default = 65536u; // 64KiB | ||
| static constexpr std::size_t small_segment_size_default = 65536u; // 64KiB | ||
| static constexpr std::size_t large_segment_size_default = 2097152u; // 2MiB | ||
|
|
||
| bool m_never_free; | ||
| std::size_t m_num_reserve_segments; | ||
| std::size_t m_tiny_limit; | ||
| std::size_t m_small_limit; | ||
| std::size_t m_large_limit; | ||
| std::size_t m_bucket_shift = detail::log2_c(m_tiny_limit) - 1; | ||
| std::size_t m_tiny_segment_size; | ||
| std::size_t m_small_segment_size; | ||
| std::size_t m_large_segment_size; | ||
| static constexpr std::size_t m_tiny_increment_shift = 3; | ||
| static constexpr std::size_t m_tiny_increment = (1u << m_tiny_increment_shift); | ||
| std::size_t m_num_tiny_heaps = m_tiny_limit / m_tiny_increment; | ||
| std::size_t m_num_small_heaps = detail::log2_c(m_small_limit) - detail::log2_c(m_tiny_limit); | ||
| std::size_t m_num_large_heaps = detail::log2_c(m_large_limit) - detail::log2_c(m_small_limit); | ||
|
|
||
| heap_config(bool never_free, std::size_t num_reserve_segments, std::size_t tiny_limit, | ||
| std::size_t small_limit, std::size_t large_limit, std::size_t tiny_segment_size, | ||
| std::size_t small_segment_size, std::size_t large_segment_size); | ||
| }; | ||
|
|
||
| heap_config const& get_default_heap_config(); | ||
| } // namespace hwmalloc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the final TODO unless there are other comments: the example below is based on the old defaults and should be updated before merging.