-
Notifications
You must be signed in to change notification settings - Fork 406
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
data()==NULL after realloc with LayoutStride #351
Comments
resize with a layout stride view should only accept layout object, not integer dimensions |
|
Resize and realloc were implemented to support the LayoutLeft and LayoutRight. Those functions were not previously intended to support LayoutStride. The fact that LayoutStride can be passed in at all is a bug. A new overload of resize and realloc that accepts a LayoutStride object is needed. Thus this issue is both a bug report and, I assume, a feature request. |
Yes, thats correct, although the bug fix is all I'd need to consider it resolved, i.e. this usage ought to cause a compile or runtime error at the |
This makes the resize and realloc functions which only take integers work solely with LayoutLeft and LayoutRight. Added overloads which take a view and a layout instance, which also works for LayoutStride. Had to make Layout constructors explicit (i.e. prevent implicit calls of Layout constructors). Also added missing default declarations of constructors in LayoutStride. Added tests for new resize and realloc and made the tests actually check whether resize preserves old data.
OK here is how this works with LayoutStride: #else
Kokkos::realloc(view, NNodes1);
#endif do #else
Kokkos::realloc(view, make_layout(NNodes1));
#endif The other version will now also compile time fail if the layout is not LayoutRight or LayoutLeft. Unit tests are put in place. |
thanks very much ! |
When running this example code:
With
USE_STRIDE
and withoutGOOD_REALLOC
, the assertionview.data() != nullptr
fails. The history here is my View used to have compile-time layout andrealloc
worked fine given only one dimension. After switching toLayoutStride
I got segfaults due to this.Either this shouldn't happen and there is a bug somewhere, or it is expected in which case I would prefer that some part of Kokkos threw a compile or runtime error on this example, so that its easier to track down the problem.
The text was updated successfully, but these errors were encountered: