diff --git a/include/ygm/container/detail/array_impl.hpp b/include/ygm/container/detail/array_impl.hpp index 5d2b5f69..0b3e52b5 100644 --- a/include/ygm/container/detail/array_impl.hpp +++ b/include/ygm/container/detail/array_impl.hpp @@ -41,6 +41,9 @@ class array_impl { : m_default_value(rhs.m_default_value), m_comm(rhs.m_comm), m_global_size(rhs.m_global_size), + m_small_block_size(rhs.m_small_block_size), + m_large_block_size(rhs.m_large_block_size), + m_local_start_index(rhs.m_local_start_index), m_local_vec(rhs.m_local_vec), pthis(this) {} @@ -52,7 +55,6 @@ class array_impl { m_global_size = size; m_small_block_size = size / m_comm.size(); m_large_block_size = m_small_block_size + ((size / m_comm.size()) > 0); - m_comm.cout0(m_small_block_size, " : ", m_large_block_size); m_local_vec.resize( m_small_block_size + (m_comm.rank() < (size % m_comm.size())), diff --git a/test/test_array.cpp b/test/test_array.cpp index e074c3b8..ffb2069e 100644 --- a/test/test_array.cpp +++ b/test/test_array.cpp @@ -192,5 +192,40 @@ int main(int argc, char **argv) { }); } + // Test copy constructor + { + int size = 64; + + ygm::container::array arr(world, size); + + if (world.rank0()) { + for (int i = 0; i < size; ++i) { + arr.async_set(i, 2 * i); + } + } + + world.barrier(); + + ygm::container::array arr_copy(arr); + + arr_copy.for_all([&arr](const auto &index, const auto &value) { + arr.async_visit( + index, + [](const auto &index, const auto &my_value, const auto &other_value) { + ASSERT_RELEASE(my_value == other_value); + }, + value); + }); + + arr.for_all([&arr_copy](const auto &index, const auto &value) { + arr_copy.async_visit( + index, + [](const auto &index, const auto &my_value, const auto &other_value) { + ASSERT_RELEASE(my_value == other_value); + }, + value); + }); + } + return 0; }