-
Notifications
You must be signed in to change notification settings - Fork 407
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
Add Method to Resize View without Initialization #2048
Comments
See also #1877. |
I asked the same question on the Slack channel. It seems the answer for now is to use unmanaged view |
You don't have to use an unmanaged View. Just create a new View, uninitialized, and assign to the old one. That's what |
Can only resize managed views, so can't use unmanaged in this case. A static assert prevents this, see https://github.com/kokkos/kokkos/blob/master/core/src/Kokkos_CopyViews.hpp#L1839.
No, I don't think that is true, for example see https://github.com/kokkos/kokkos/blob/master/core/src/Kokkos_CopyViews.hpp#L470. |
@mhoemmen unless by "assign" you mean copy element by element... |
Maybe I need to explain what I need a little better. When I call |
@mhoemmen pretty sure you are thinking of |
@stanmoore1 I didn't mean resizing the unmanaged directly. Can you create an unmanaged view with the desired dimension by wrapping the pointer from the old view? |
I could create a new larger view that is uninitialized and copy element by element manually, but then I'm recreating the |
Just to be 100% clear, |
Actually, it is worse than I thought. Kokkos isn't just initializing the "extra" in the new view, it is initializing the entire new view, even though most of the values will just be copied over in the next operation. You can see that using this code. #include <Kokkos_Core.hpp>
#include <cstdio>
typedef Kokkos::View<int*> view_type;
int main (int argc, char* argv[]) {
Kokkos::initialize (argc, argv);
{
const int N = 10;
view_type a (Kokkos::view_alloc("A",Kokkos::WithoutInitializing), N);
Kokkos::resize(a,2*N);
}
Kokkos::finalize ();
} I used
|
my bad; thanks! |
I opened a duplicate earlier, (#2028), but I'll close that one in favor of this one because this one has user data showing why this is expensive. |
The CoPA/Cabana team also needs this feature. |
Is adding something like |
Yes, seems fine to me. |
Can a way to resize a view without any initialization please be added? The values are just going to be overwritten in the next parallel region.
The text was updated successfully, but these errors were encountered: