dash icon indicating copy to clipboard operation
dash copied to clipboard

MatrixRef::lbegin() fails to compile

Open devreal opened this issue 7 years ago • 4 comments

Consider the following code snippet:

dash::NArray<int, 2> matrix(dash::size(), N);
int *my_row = matrix[dash::myid()].lbegin();

which gives the following compiler error:

/home/joseph/opt/dash-0.3.0//include/dash/matrix/internal/MatrixRef-inl.h: In instantiation of ‘T* dash::MatrixRef<T, NumDimensions, CUR, PatternT>::lbegin() [with ElementT = int; int NumDimensions = 2; int NumViewDim = 1; PatternT = dash::BlockPattern<2, (dash::MemArrange)1u, long int>]’:
isx.cc:277:63:   required from here
/home/joseph/opt/dash-0.3.0//include/dash/matrix/internal/MatrixRef-inl.h:269:28: error: cannot convert ‘dash::LocalMatrixRef<int, 2, 2, dash::BlockPattern<2, (dash::MemArrange)1u, long int> >::iterator {aka dash::GlobViewIter<int, dash::BlockPattern<2, (dash::MemArrange)1u, long int>, dash::GlobStaticMem<int, dash::allocator::SymmetricAllocator<int> >, dash::GlobPtr<int, dash::GlobStaticMem<int, dash::allocator::SymmetricAllocator<int> > >, dash::GlobRef<int> >}’ to ‘int*’ in return
   return sub_local().begin();

As a workaround, I can probably use matrix.lbegin() for now.

devreal avatar Jul 06 '17 11:07 devreal

I'm surprised this one is left unanswered so long.

I tried to look into this yesterday and wanted to report my findings. In short this TODO has to be done: MatrixRef.h#L47-L49

To check this use case in a unit test it is possible to extend the existing case MatrixTest.MatrixLBegin:

   EXPECT_EQ_U(myid, static_cast<int>(*(matrix.lbegin())));
+  EXPECT_EQ_U(myid, static_cast<int>(*(matrix[myid].lbegin())));
   EXPECT_EQ_U(myid, static_cast<int>(*(matrix.local.block(0).begin())));
   EXPECT_EQ_U(myid, static_cast<int>(*(matrix.local.begin())));

First of all the type of lbegin() in MatrixRef can't be right. Instead local_type::iterator should be used. See MatrixRef.h#L199. If ElementT * is really sufficient that should be changed in LocalMatrixRef. See LocalMatrixRef.h#L93.

Next the typedef of local_type does not respect the current dimension in the MatrixRef. See the typedefs of local_type, local_reference_type, ... in MatrixRef.h#L105-L117. Shouldn't be this LocalMatrixRef<ElementT, NumDimensions, NumViewDim, PatternT> instead?

Last but not least the function sub_local() of MatrixRef is currently not supported. It tries to call this currently deactivated constructor of LocalMatrixRef: LocalMatrixRef-inl.h#L43-L64 That constructor contains this lines:

  DASH_THROW(
    dash::exception::NotImplemented,
    "Matrix view projection order matrix.sub().local() "
    "is not supported, yet. Use matrix.local().sub().");

As I'm not entirely sure how Matrix, MatrixRef, MatrixRefView, and so on works, I stopped there before breaking something completely.

@fuchsto Perhaps this is something for your view expressions.

ddiefenthaler avatar Aug 12 '17 10:08 ddiefenthaler

I spoke to soon, there is PR #428 which is handling at this issue. Perhaps my report is helpful anyways...

ddiefenthaler avatar Aug 12 '17 11:08 ddiefenthaler

@ddiefenthaler maybe something you can fix based on the already existing pull request and your breakdown? It would be nice to have it in the 0.3.0 release.

rkowalewski avatar Sep 21 '18 12:09 rkowalewski

Ping. Just ran into this again :(

devreal avatar Jan 03 '19 21:01 devreal