diff --git a/build.nasty.sh b/build.nasty.sh index 753ffb2a1..219e81e5b 100755 --- a/build.nasty.sh +++ b/build.nasty.sh @@ -61,11 +61,11 @@ fi # Configure with default release build settings: mkdir -p $BUILD_DIR rm -Rf $BUILD_DIR/* -(cd $BUILD_DIR && cmake -DCMAKE_BUILD_TYPE=Release \ +(cd $BUILD_DIR && cmake -DCMAKE_BUILD_TYPE=Debug \ -DENVIRONMENT_TYPE=default \ -DINSTALL_PREFIX=$HOME/opt/dash-0.3.0-nasty \ -DDART_IMPLEMENTATIONS=mpi \ - -DENABLE_THREADSUPPORT=ON \ + -DENABLE_THREADSUPPORT=OFF \ -DENABLE_DEV_COMPILER_WARNINGS=OFF \ -DENABLE_EXT_COMPILER_WARNINGS=OFF \ -DENABLE_LT_OPTIMIZATION=OFF \ @@ -91,6 +91,7 @@ rm -Rf $BUILD_DIR/* -DENABLE_HDF5=ON \ \ -DENABLE_NASTYMPI=ON \ + -DNASTYMPI_LIBRARY_PATH=/home/joseph/src/nasty-MPI/ \ \ -DBUILD_EXAMPLES=OFF \ -DBUILD_TESTS=ON \ diff --git a/dash/include/dash/matrix/LocalMatrixRef.h b/dash/include/dash/matrix/LocalMatrixRef.h index 11dab1a19..f21006a79 100644 --- a/dash/include/dash/matrix/LocalMatrixRef.h +++ b/dash/include/dash/matrix/LocalMatrixRef.h @@ -159,6 +159,16 @@ class LocalMatrixRef Matrix * mat ); + /** + * Constructor, creates a local view reference to a Matrix view at the + * specified global coordinates. + */ + template + LocalMatrixRef( + Matrix * mat, + std::array global_coords + ); + /** * View at local block at given local block coordinates. */ diff --git a/dash/include/dash/matrix/internal/LocalMatrixRef-inl.h b/dash/include/dash/matrix/internal/LocalMatrixRef-inl.h index e48d6f060..f2d591fd1 100644 --- a/dash/include/dash/matrix/internal/LocalMatrixRef-inl.h +++ b/dash/include/dash/matrix/internal/LocalMatrixRef-inl.h @@ -40,6 +40,21 @@ ::LocalMatrixRef( DASH_LOG_TRACE_VAR("LocalMatrixRef(mat) >", _refview._viewspec); } +template +template +LocalMatrixRef +::LocalMatrixRef( + Matrix * mat, + std::array global_coords) + : _refview(mat->_ref._refview) +{ + auto local_extents = mat->_pattern.local_extents(); + DASH_LOG_TRACE_VAR("LocalMatrixRef(mat, gcoords)", local_extents); + auto local_offsets = mat->_pattern.global(global_coords); + _refview._viewspec = ViewSpec_t(local_offsets, local_extents); + DASH_LOG_TRACE_VAR("LocalMatrixRef(mat, gcoords) >", _refview._viewspec); +} + #if 0 template LocalMatrixRef @@ -274,7 +289,7 @@ inline T * LocalMatrixRef ::lend() noexcept { - return end().local(); + return begin().local() + size(); } template @@ -282,7 +297,7 @@ constexpr const T * LocalMatrixRef ::lend() const noexcept { - return end().local(); + return begin().local() + size(); } template diff --git a/dash/include/dash/matrix/internal/MatrixRef-inl.h b/dash/include/dash/matrix/internal/MatrixRef-inl.h index 8641835ac..6db0575ae 100644 --- a/dash/include/dash/matrix/internal/MatrixRef-inl.h +++ b/dash/include/dash/matrix/internal/MatrixRef-inl.h @@ -251,7 +251,7 @@ typename MatrixRef::local_type MatrixRef ::sub_local() noexcept { - return local_type(this); + return local_type(this->_refview._mat, _refview._viewspec.offsets()); } template @@ -266,7 +266,7 @@ ::lbegin() noexcept // _mat->local.view(_refview) // // ... as order of projections (slice + local vs. local + slice) matters. - return sub_local().begin(); + return sub_local().lbegin(); } template @@ -281,7 +281,7 @@ ::lend() noexcept // _mat->local.view(_refview) // // ... as order of projections (slice + local vs. local + slice) matters. - return sub_local().end(); + return sub_local().lend(); } template diff --git a/dash/test/container/MatrixTest.cc b/dash/test/container/MatrixTest.cc index ab04385bd..70f5c9092 100644 --- a/dash/test/container/MatrixTest.cc +++ b/dash/test/container/MatrixTest.cc @@ -1616,3 +1616,29 @@ TEST_F(MatrixTest, MoveSemantics){ ASSERT_EQ_U(*(matrix_b.lbegin()), 1); } } + + +TEST_F(MatrixTest, MatrixRefLbegin){ + using matrix_t = dash::Matrix; + size_t nelem = dash::size() * 10; + size_t tilesize = 5; + matrix_t matrix(nelem, nelem, dash::TILE(tilesize), dash::TILE(tilesize)); + auto& pattern = matrix.pattern(); + dash::fill(matrix.begin(), matrix.end(), -1); + + auto lbs = pattern.local_blockspec(); + + // fill our blocks with our ID + for (size_t i = 0; i < lbs.size(); ++i) { + auto coords = lbs.coords(i); + auto block = matrix.block(coords); + for (auto bliter = block.lbegin(); bliter != block.lend(); ++bliter) { + *bliter = dash::myid(); + } + } + + // check that all our elements are correctly set + for (auto iter = matrix.lbegin(); iter != matrix.lend(); ++iter) { + ASSERT_EQ_U(*iter, dash::myid()); + } +}