-
Notifications
You must be signed in to change notification settings - Fork 48
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
UniqueToken.md: API documentation for UniqueToken.md #179
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a lot of whitespace in the c++ code that looks akward given the style we use in the rest of the documentation.
Document the extra constructor for UniqueTokenScope==Global as:
|
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the implementation I want to suggest some changes. But someone should verify.
int id = token . acquire (); | ||
RandomGen gen = pool (id ); | ||
// Computation Body | ||
token . release (id ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int id = token . acquire (); | |
RandomGen gen = pool (id ); | |
// Computation Body | |
token . release (id ); | |
auto id = token.acquire (); | |
RandomGen gen = pool (id ); | |
// Computation Body | |
token.release (id ); |
Shouldn't it be |
713ac08
to
d5f1d97
Compare
@JBludau - I used most of your suggestions. See what you think about the updates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
In a parallel region, before the main computation, a pool of ``UniqueToken`` (integer) ID is generated, and each ID is released following iteration. | ||
|
||
.. warning:: | ||
``UniqueToken <ExecutionSpace> token`` *can* be called inside a parallel region, *but* must be released at the end of *each* iteration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be saying "work item" instead of "iteration"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either formulation is fine : " ... each iterate" or " ... each work item"
* ``UniqueTokenScope``: defaults to ``Instance``, and every instance is independent of another. In contrast, ``Global`` uses one set of unique IDs for all instances. | ||
|
||
.. note:: | ||
In a parallel region, before the main computation, a pool of ``UniqueToken`` (integer) ID is generated, and each ID is released following iteration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each ID is released following iteration.
I don't quite understand what this means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess she meant to say that the token is released at the end of the iteration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reworked for clarity.
UniqueToken(size_type max_size, ExecutionSpace execution_space = ExecutionSpace()) | ||
// Scope is instance | ||
|
||
.. code-block:: cpp | ||
|
||
UniqueToken(size_type max_size, ExecutionSpace execution_space = ExecutionSpace()) requires(TokenScope == Global); | ||
// Scope is global |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not following what is the difference between the two.
Should that be interpreted as, regardless of whether TokenScope is instance or global, the constructor takes an integer argument and optionally an execution space trailing argument that defaults to the default exec space instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think are right, the constructor that takes a max_size
will instantiate UniqueToken<ExecutionSpace,UniqueTokenScope::Instance>
.
The one with only the ExecutionSpace
as argument does not restrict the scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes -- the main distinction is scope (instance or global).
.. code-block:: cpp | ||
|
||
UniqueToken(size_type max_size, ExecutionSpace execution_space=ExecutionSpace()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. code-block:: cpp | |
UniqueToken(size_type max_size, ExecutionSpace execution_space=ExecutionSpace()) | |
presumably a copy pasta error
|
||
.. code-block:: cpp | ||
|
||
size_type size() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we forget to define size_type
?
.. code-block:: cpp | ||
|
||
size_type size() | ||
// Returns the size of the token pool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a dedicated syntax for return
// Returns the size of the token pool | |
:returns: the size of the token pool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:return:
doesn't work (as a Sphinx directive) with .. code-block:: cpp
or .. cpp:function::
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, code-block:: cpp
(vs. cpp:function::
) is being used (i.e., cpp:function
requires a conventional function signature (vs. method on a class).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch by @dalg24, the ctor description is not correct
.. code-block:: cpp | ||
|
||
UniqueToken(size_type max_size, ExecutionSpace execution_space = ExecutionSpace()) | ||
// Scope is instance | ||
|
||
.. code-block:: cpp | ||
|
||
UniqueToken(size_type max_size, ExecutionSpace execution_space = ExecutionSpace()) requires(TokenScope == Global); | ||
// Scope is global |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. code-block:: cpp | |
UniqueToken(size_type max_size, ExecutionSpace execution_space = ExecutionSpace()) | |
// Scope is instance | |
.. code-block:: cpp | |
UniqueToken(size_type max_size, ExecutionSpace execution_space = ExecutionSpace()) requires(TokenScope == Global); | |
// Scope is global | |
.. code-block:: cpp | |
UniqueToken(size_type max_size, ExecutionSpace execution_space = ExecutionSpace{}) | |
// Scope is instance | |
UniqueToken(ExecutionSpace execution_space = ExecutionSpace{}) | |
// Scope can be instance or global |
* ``UniqueTokenScope``: defaults to ``Instance``, and every instance is independent of another. In contrast, ``Global`` uses one set of unique IDs for all instances. | ||
|
||
.. note:: | ||
In a parallel region, before the main computation, a pool of ``UniqueToken`` (integer) ID is generated. A generated ID is released following iteration (see ``void release(size_t idx)`` below). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if we need the note when we have the warning below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we kept the warning and ditched the note. The warning was very explicit about what users have to adhere to. The note makes it sound optional in my opinion
This PR is the first draft of API documentation for
UniqueToken
capability and is linked to the #5140 "catch all" Documentation issue.