``push_finalize_hook`` ====================== .. role::cpp(code) :language: cpp Defined in header ```` Usage ----- .. code-block:: cpp Kokkos::push_finalize_hook(func); Registers the callable object ``func`` to be called when the Kokkos execution environment is terminated. The functions registered via ``Kokkos::push_finalize_hook()`` will be called in reverse order when entering ``Kokkos::finalize()``, before releasing acquired resources and finalizing all backends. If a function exits via a thrown exception, ``std::terminate`` is called. Interface --------- .. cpp:Function:: void push_finalize_hook(std::function func); Register the function object ``func`` to be called when entering ``Kokkos::finalize()`` Example ------- .. code-block:: cpp #include #include void my_hook() { std::cout << "Cruel world!\n"; } int main(int argc, char* argv[]) { Kokkos::initialize(argc, argv); Kokkos::push_finalize_hook(my_hook); Kokkos::push_finalize_hook([]{ std::cout << "Goodbye\n"; }); std::cout << "Calling Kokkos::finalize() ...\n"; Kokkos::finalize(); } Output: .. code-block:: Calling Kokkos::finalize() ... Goodbye Cruel world! See also -------- * `Kokkos::finalize `_: terminates the Kokkos execution environment