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

Fix to concat0 #553

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/madness/world/worldgop.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,6 @@ namespace madness {
};
using sptr_t = std::unique_ptr<T[], free_dtor>;

sptr_t buf0;
auto aligned_buf_alloc = [&]() -> T* {
// posix_memalign requires alignment to be an integer multiple of sizeof(void*)!! so ensure that
const std::size_t alignment =
Expand All @@ -813,9 +812,11 @@ namespace madness {
}
return static_cast<T *>(ptr);
#else
return static_cast<T*>(std::aligned_alloc(alignment, buf_size));
return static_cast<T *>(std::aligned_alloc(alignment, buf_size));
#endif
};

sptr_t buf0;
if (child0 != -1)
buf0 = sptr_t(aligned_buf_alloc(),
free_dtor{});
Expand Down Expand Up @@ -951,6 +952,8 @@ namespace madness {
template <typename T>
std::vector<T> concat0(const std::vector<T>& v, size_t bufsz=1024*1024) {
MADNESS_ASSERT(bufsz <= std::numeric_limits<int>::max());
// bufsz must be multiple of alignment!!! so ensure that
bufsz = ((bufsz + sizeof(void*) - 1) / sizeof(void*)) * sizeof(void*);

ProcessID parent, child0, child1;
world_.mpi.binary_tree_info(0, parent, child0, child1);
Expand All @@ -964,20 +967,16 @@ namespace madness {
};
using sptr_t = std::unique_ptr<std::byte[], free_dtor>;

sptr_t buf0;
if (child0 != -1)
buf0 = sptr_t(static_cast<std::byte *>(std::aligned_alloc(
std::alignment_of_v<T>, bufsz)),
free_dtor{});
sptr_t buf1;
if (child1 != -1)
buf1 = sptr_t(static_cast<std::byte *>(std::aligned_alloc(
std::alignment_of_v<T>, bufsz)),
free_dtor{});
auto buf0 = sptr_t(static_cast<std::byte *>(
std::aligned_alloc(sizeof(void *), bufsz)),
free_dtor{});
auto buf1 = sptr_t(static_cast<std::byte *>(
std::aligned_alloc(sizeof(void *), bufsz)),
free_dtor{});

// transfer data in chunks at most this large
const int batch_size = static_cast<int>(
std::min(static_cast<size_t>(max_reducebcast_msg_size()),bufsz));
std::min(static_cast<size_t>(max_reducebcast_msg_size()), bufsz));

// precompute max # of tags any node ... will need, and allocate them on every node to avoid tag counter divergence
const int max_nbatch = bufsz / batch_size;
Expand Down
Loading