A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://kokkos.github.io/kokkos-core-wiki/API/core/initialize_finalize/push_finalize_hook.html below:

push_finalize_hook - Kokkos documentation

Toggle table of contents sidebar

push_finalize_hook

Defined in header <Kokkos_Core.hpp>

Usage
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
void push_finalize_hook(std::function<void()> func);

Register the function object func to be called when entering Kokkos::finalize()

Example
#include <Kokkos_Core.hpp>
#include <iostream>

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:

Calling Kokkos::finalize() ...
Goodbye
Cruel world!
See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4