Skip to content
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

Implemented custom byte_vector for local storage #245

Open
wants to merge 17 commits into
base: v0.7-dev
Choose a base branch
from

Conversation

ryan-dozier
Copy link
Contributor

@ryan-dozier ryan-dozier commented Aug 13, 2024

This work aims unify YGM send and recv buffers to the same data type. Previously we were using both std::vector<std::byte> and std::array<std::byte>. The goal is to create a sparse, dynamically resizable array. This is needed when many YGM communicators are spawned. This is to avoid fully allocating each of the overly large recv buffers until they are utilized (an issue we found with std::vector).

I tried to emulate most of the common std::vector API functions we were using, we should be able to add additional functionality on top of this approach when needed.

I did include a simple test file for CI and unit tests, it may not be fully exhaustive, so reviewing would be good.

@@ -18,6 +18,7 @@ class csv_field {

bool is_integer() const {
int64_t test;
std::cout << m_f << std::endl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a debugging statement was left in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, removed

}

if constexpr (!std::is_empty<Lambda>::value) {
// oarchive.saveBinary(&l, sizeof(Lambda));
size_t size_before = packed.size();
packed.resize(size_before + sizeof(Lambda));
std::memcpy(packed.data() + size_before, &l, sizeof(Lambda));
//packed.push_bytes(&l, sizeof(lambda));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this line replace the lines above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there was a typo here having lambda instead of Lambda that I forgot to return to and fix.

}

void reserve(size_t cap) {
size_t new_capacity = get_page_aligned_size(cap);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth implementing an exponentially growing size to get the number of calls to mremap to be logarithmic in the buffer size rather than linear.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be experimented with before implementing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants