From 82ef2976e65d24503e8d0a5d9cabdb2fb128438b Mon Sep 17 00:00:00 2001 From: Tomasetti Romin Date: Tue, 3 Sep 2024 18:44:08 -0400 Subject: [PATCH] core(view): warn about the implications of without initializing (#569) * core(view): warn about view of views in a warning box * core(view): implications of WithoutInitializing --- docs/source/ProgrammingGuide/View.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/source/ProgrammingGuide/View.rst b/docs/source/ProgrammingGuide/View.rst index a196b59c4..ae6fa9661 100644 --- a/docs/source/ProgrammingGuide/View.rst +++ b/docs/source/ProgrammingGuide/View.rst @@ -97,7 +97,9 @@ Finally, note that virtual functions are technically allowed, but calling them i 6.2.3 Can I make a View of Views? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -NOVICES: THE ANSWER FOR YOU IS "NO." PLEASE SKIP THIS SECTION. +.. warning:: + + NOVICES: THE ANSWER FOR YOU IS "NO." PLEASE SKIP THIS SECTION. A "View of Views" is a special case of View, where the type of each entry is itself a View. It is possible to make this, but before you try, please see below. @@ -458,6 +460,14 @@ in a way that reflects how first-touch affinity to threads is desired. Typically it is sufficient to use the parallel iteration index as the index of the location in the view to write to. +.. warning:: + + :cppkokkos:`WithoutInitialization` implies that the destructor of each element of the :cppkokkos:`View` **will not be called**. + For instance, if the :cppkokkos:`View`'s value type is not trivially destructible, + you **should not use** :cppkokkos:`WithoutInitialization` unless you are taking care of calling the destructor manually before the :cppkokkos:`View` deallocates its memory. + + The mental model is that whenever placement new is used to call the constructor, the destructor also isn't called before the memory is deallocated but it needs to be called manually. + 6.4.3 Deep copy and HostMirror ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~