diff --git a/dash/include/dash/Array.h b/dash/include/dash/Array.h index c67a8d1c5..2c8fbbe2e 100644 --- a/dash/include/dash/Array.h +++ b/dash/include/dash/Array.h @@ -1144,7 +1144,7 @@ class Array m_begin = iterator(m_globmem, m_pattern); m_end = iterator(m_begin) + m_size; // Local iterators: - m_lbegin = m_globmem->lbegin(m_myid); + m_lbegin = m_globmem->lbegin(); // More efficient than using m_globmem->lend as this a second mapping // of the local memory segment: m_lend = m_lbegin + m_lsize; @@ -1204,7 +1204,7 @@ class Array m_begin = iterator(m_globmem, pattern); m_end = iterator(m_begin) + m_size; // Local iterators: - m_lbegin = m_globmem->lbegin(m_myid); + m_lbegin = m_globmem->lbegin(); // More efficient than using m_globmem->lend as this a second mapping // of the local memory segment: m_lend = m_lbegin + pattern.local_size(); diff --git a/dash/include/dash/GlobMem.h b/dash/include/dash/GlobMem.h index 3297bcc39..448aa8fbc 100644 --- a/dash/include/dash/GlobMem.h +++ b/dash/include/dash/GlobMem.h @@ -125,8 +125,9 @@ class GlobMem _begptr = _allocator.allocate(_nlelem); DASH_ASSERT_MSG(!DART_GPTR_ISNULL(_begptr), "allocation failed"); - _lbegin = lbegin(team.myid()); - _lend = lend(team.myid()); + // Use id's of team all + _lbegin = lbegin(dash::myid()); + _lend = lend(dash::myid()); DASH_LOG_TRACE("GlobMem(nlocal,team) >"); } @@ -158,8 +159,8 @@ class GlobMem _begptr = _allocator.allocate(_nlelem); DASH_ASSERT_MSG(!DART_GPTR_ISNULL(_begptr), "allocation failed"); - _lbegin = lbegin(team.myid()); - _lend = lend(team.myid()); + _lbegin = lbegin(dash::myid()); + _lend = lend(dash::myid()); // Initialize allocated local elements with specified values: auto copy_end = std::copy(local_elements.begin(), local_elements.end(), @@ -175,7 +176,7 @@ class GlobMem // TODO: Should depend on allocator trait // dash::allocator_traits::is_collective() DASH_LOG_DEBUG("GlobMem(lvals,team)", "barrier"); - barrier(); + team.barrier(); } DASH_LOG_DEBUG("GlobMem(lvals,team) >", @@ -244,15 +245,16 @@ class GlobMem /** * Native pointer of the initial address of the local memory of * a unit. + * \param global_unit_id id of unit in \c dash::Team::All() */ const ElementType * lbegin( - dart_unit_t unit_id) const + dart_unit_t global_unit_id) const { void *addr; - DASH_LOG_TRACE_VAR("GlobMem.lbegin const()", unit_id); + DASH_LOG_TRACE_VAR("GlobMem.lbegin const()", global_unit_id); dart_gptr_t gptr = _begptr; DASH_ASSERT_RETURNS( - dart_gptr_setunit(&gptr, unit_id), + dart_gptr_setunit(&gptr, global_unit_id), DART_OK); DASH_ASSERT_RETURNS( dart_gptr_getaddr(gptr, &addr), @@ -264,17 +266,18 @@ class GlobMem /** * Native pointer of the initial address of the local memory of * a unit. + * \param global_unit_id id of unit in \c dash::Team::All() */ ElementType * lbegin( - dart_unit_t unit_id) + dart_unit_t global_unit_id) { void *addr; - DASH_LOG_TRACE_VAR("GlobMem.lbegin()", unit_id); + DASH_LOG_TRACE_VAR("GlobMem.lbegin()", global_unit_id); dart_gptr_t gptr = _begptr; DASH_LOG_TRACE_VAR("GlobMem.lbegin", GlobPtr((dart_gptr_t)gptr)); DASH_ASSERT_RETURNS( - dart_gptr_setunit(&gptr, unit_id), + dart_gptr_setunit(&gptr, global_unit_id), DART_OK); DASH_ASSERT_RETURNS( dart_gptr_getaddr(gptr, &addr), diff --git a/dash/test/ArrayTest.cc b/dash/test/ArrayTest.cc index 68ce84ba6..d2eedc248 100644 --- a/dash/test/ArrayTest.cc +++ b/dash/test/ArrayTest.cc @@ -168,4 +168,24 @@ TEST_F(ArrayTest, ConstructorNelemInitializerList) } } +TEST_F(ArrayTest, TeamSplit) +{ + auto & team_all = dash::Team::All(); + auto ext_x = team_all.size(); + + if(team_all.size() < 2){ + SKIP_TEST(); + } + if(!team_all.is_leaf()){ + LOG_MESSAGE("team is already splitted. Skip test"); + SKIP_TEST(); + } + + auto & myteam = team_all.split(2); + auto array_a = dash::Array(ext_x, myteam); + array_a.barrier(); + // Check if array is allocated + ASSERT_NE_U(array_a.lbegin(), nullptr); + team_all.barrier(); +} diff --git a/dash/test/GlobMemTest.cc b/dash/test/GlobMemTest.cc index 1b92bb802..a7e0ff061 100644 --- a/dash/test/GlobMemTest.cc +++ b/dash/test/GlobMemTest.cc @@ -28,6 +28,11 @@ TEST_F(GlobMemTest, LocalBegin) { auto target_local_elements = { 1, 2, 3, 4 }; + if(!dash::Team::All().is_leaf()){ + LOG_MESSAGE("team is already splitted. Skip test"); + SKIP_TEST(); + } + auto & sub_team = dash::size() < 4 ? dash::Team::All() : dash::Team::All().split(2); @@ -37,5 +42,5 @@ TEST_F(GlobMemTest, LocalBegin) for (int l = 0; l < target_local_elements.size(); l++) { EXPECT_EQ_U(*(target_local_elements.begin() + l), target.lbegin()[l]); } + EXPECT_NE_U(target.lbegin(), nullptr); } - diff --git a/dash/test/TeamTest.cc b/dash/test/TeamTest.cc index 0d14d7839..fb8ffe55e 100644 --- a/dash/test/TeamTest.cc +++ b/dash/test/TeamTest.cc @@ -34,6 +34,11 @@ TEST_F(TeamTest, SplitTeamSync) if(team_all.size() < 2){ SKIP_TEST(); } + if(!team_all.is_leaf()){ + LOG_MESSAGE("team is already splitted. Skip test"); + SKIP_TEST(); + } + LOG_MESSAGE("team_all contains %d units", team_all.size()); auto & team_core = team_all.split(2);