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

Add ability to set hook on Kokkos::finalize #714

Closed
mhoemmen opened this issue Mar 30, 2017 · 3 comments
Closed

Add ability to set hook on Kokkos::finalize #714

mhoemmen opened this issue Mar 30, 2017 · 3 comments
Assignees
Labels
Feature Request Create new capability; will potentially require voting
Milestone

Comments

@mhoemmen
Copy link
Contributor

mhoemmen commented Mar 30, 2017

Compare to MPI's ability to set a hook to be called at MPI_Finalize. The point is to have a way to free global state -- e.g., cuBLAS' handle -- before (say) Kokkos::Cuda::finalize gets called. Hooks would imitate semantics of POSIX atexit. All hooks would need to be called before any execution spaces, etc. get finalized.

This would be handy, but it's not urgent. See discussion, e.g., here: trilinos/Trilinos#1194 . This is also related to #632.

@mhoemmen mhoemmen added the Feature Request Create new capability; will potentially require voting label Mar 30, 2017
@hcedwar hcedwar added this to the Backlog milestone Apr 5, 2017
@mhoemmen
Copy link
Contributor Author

mhoemmen commented Jan 2, 2018

Please add to Feb 2018 milestone (by @crtrott 's request, for Tpetra deliverable); thanks!

@mhoemmen
Copy link
Contributor Author

mhoemmen commented Jan 2, 2018

I can do / help with this.

@mhoemmen
Copy link
Contributor Author

mhoemmen commented Jan 4, 2018

@crtrott I'm almost done; just writing another test. Once I'm done, I'll submit a Kokkos pull request.

crtrott added a commit that referenced this issue Jan 5, 2018
Fix #714 (add Kokkos::push_finalize_hook function & tests)
@crtrott crtrott modified the milestones: Backlog, 2018 February Jan 5, 2018
mhoemmen pushed a commit to trilinos/Trilinos that referenced this issue Jan 5, 2018
Fix kokkos/kokkos#714 by adding a new
function: Kokkos::push_finalize_hook.  It lets users set function(s)
to be called in Kokkos::finalize, BEFORE Kokkos finalizes anything.  I
also added unit tests that ensure the following:

  1. Kokkos::finalize actually calls the finalize hooks.
  2. Kokkos::finalize calls the functions in reverse (LIFO) order.
     That is, it calls them backwards from the order in which they
     were added, just as std::atexit does.
  3. If a finalize hook throws an uncaught exception, then
     Kokkos::finalize calls std::terminate, just as std::atexit does.

This commit patches Trilinos, using the same changes made in Kokkos
pull request kokkos/kokkos#1319 .  That pull
request was merged into Kokkos:develop, so it will overwrite this
Trilinos commit at the next Kokkos promotion into Trilinos.
mhoemmen added a commit to trilinos/Trilinos that referenced this issue Jan 5, 2018
Fix kokkos/kokkos#714 by adding a new
function: Kokkos::push_finalize_hook.  It lets users set function(s)
to be called in Kokkos::finalize, BEFORE Kokkos finalizes anything.  I
also added unit tests that ensure the following:

  1. Kokkos::finalize actually calls the finalize hooks.
  2. Kokkos::finalize calls the functions in reverse (LIFO) order.
     That is, it calls them backwards from the order in which they
     were added, just as std::atexit does.
  3. If a finalize hook throws an uncaught exception, then
     Kokkos::finalize calls std::terminate, just as std::atexit does.

This commit patches Trilinos, using the same changes made in Kokkos
pull request kokkos/kokkos#1319 .  That pull
request was merged into Kokkos:develop, so it will overwrite this
Trilinos commit at the next Kokkos promotion into Trilinos.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Create new capability; will potentially require voting
Projects
None yet
Development

No branches or pull requests

4 participants