-
Notifications
You must be signed in to change notification settings - Fork 41
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 shmem_{initialized, finalized} #470
Conversation
Suggestion from 8/16 WG: Add note clarifying that |
August spec meeting: Please add this note in the shmem_initialized section as API notes. |
These were the states I could think of in a K-map style:
From these states, this would be one of the only valid conditional guards: void app_startup() {
if (shmem_finalized()) {
// OpenSHMEM is done. Undefined behavior to call any OpenSHMEM routine.
return or abort();
}
if (!shmem_initialized()) {
// OpenSHMEM is not initialized. Okay to call OpenSHMEM initialization logic.
shmem_init() or shmem_init_thread();
this_app_initialized_openshmem = 1;
}
// OpenSHMEM is initialized.
}
void app_teardown() {
if (this_app_initialized_openshmem == 1) {
shmem_finalize();
}
} Or if your apps are not tearing down in reverse-startup order, you can choose to not (RE: must not?) put in parent {
app_startup();
// do work
app_teardown();
if (!shmem_finalized()) { // Note: Should not use `shmem_initialized()` due to aforementioned `<don't care>`.
shmem_finalize();
}
} I think this is a bit error-prone in my mind, but it works and it's what we've specified. 🐌 If subsequent calls to initialization routines were allowed in an active OpenSHMEM program, one behavior could be to "do nothing and increment value of void app_startup() {
if (shmem_finalized() == shmem_initialized()) {
return or abort();
}
shmem_init() or shmem_init_thread();
// OpenSHMEM is initialized.
}
void app_teardown() {
shmem_finalize();
}
in parent {
app_startup();
// do work
app_teardown();
assert(shmem_finalized() == shmem_initialized());
// All apps tore down correctly, or either one of them or you have a bug.
} The "do nothing" behavior could be a problem if subsequent calls of |
If we follow the MPI semantics, the guard for calling |
Added the following note:
|
@nspark The note is reasonable, but why not add reference counted init/finalize and require that init functions are thread safe? |
@jdinan IDK, that just seemed like a change of a larger scope. I'm happy to draft it, but I'd probably do it as a separate PR. |
|
||
\apidescription{ | ||
The \FUNC{shmem\_initialized} routine returns a value indicating | ||
whether the \openshmem library has been initialized (i.e, a call to |
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.
Do we want "has been" or "is currently"?
|
||
\apidescription{ | ||
The \FUNC{shmem\_finalized} routine returns a value indicating | ||
whether the \openshmem library has been finalized (i.e, a call to |
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.
Do we want "has been" or "is currently"? The problem with "has been" is that it tells you whether the API was ever called. If we assume that an OpenSHMEM library can't be reinitialized, then this is enough information to tell you the library state. If an OpenSHMEM library supports reinitialization then "has been" is not enough information to know the state of the library. You need to know "is currently".
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.
For reference, here is the NVSHMEM library state query function: https://docs.nvidia.com/hpc-sdk/nvshmem/api/docs/gen/api/setup.html#nvshmemx-init-status
Superseded by #512 |
This PR adds
shmem_initialized
andshmem_finalized
to query the state of the library.Closes #457