Skip to content
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

core(view): warn about the implications of without initializing #569

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/source/ProgrammingGuide/View.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
dalg24 marked this conversation as resolved.
Show resolved Hide resolved

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.

Expand Down Expand Up @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: maybe spell out what to do in the case of both trivially and non-trivially destructible data types, maybe even including a couple of simple code-snippet examples. Perhaps also mention a couple of typical use cases where someone would want to use a View WithoutInitialization.

The sentence on line 469 is not clear, and is a little redundant with the immediately preceding statements. It may not be necessary if the previous verbiage were sharpened up, with spelled out use cases and an couple of simple examples.


6.4.3 Deep copy and HostMirror
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
Loading