20 get_yakl_instance().yakl_final_mtx.lock();
26 for (
int i=0; i < get_yakl_instance().finalize_callbacks.size(); i++) {
27 get_yakl_instance().finalize_callbacks[i]();
30 #if defined(YAKL_ARCH_HIP)
35 get_yakl_instance().pool.finalize();
37 get_yakl_instance().yakl_is_initialized =
false;
40 #if defined(YAKL_PROFILE)
44 get_yakl_instance().timer_init_func = [] () {
45 yakl_throw(
"ERROR: attempting to call the yakl::timer_init(); before calling yakl::init()");
47 get_yakl_instance().timer_finalize_func = [] () {
48 yakl_throw(
"ERROR: attempting to call the yakl::timer_finalize(); before calling yakl::init()");
50 get_yakl_instance().timer_start_func = [] (
char const *label) {
51 yakl_throw(
"ERROR: attempting to call the yakl::timer_start(); before calling yakl::init()");
53 get_yakl_instance().timer_stop_func = [] (
char const * label) {
54 yakl_throw(
"ERROR: attempting to call the yakl::timer_stop(); before calling yakl::init()");
56 get_yakl_instance().alloc_device_func = [] (
size_t bytes ,
char const *label ) ->
void* {
57 yakl_throw(
"ERROR: attempting memory alloc before calling yakl::init()");
60 get_yakl_instance().free_device_func = [] (
void *ptr ,
char const *label ) {
61 yakl_throw(
"ERROR: attempting memory free before calling yakl::init()");
64 get_yakl_instance().device_allocators_are_default =
false;
65 get_yakl_instance().pool_enabled =
false;
69 std::cerr <<
"WARNING: Calling yakl::finalize() when YAKL is not initialized. ";
70 std::cerr <<
"This might mean you've called yakl::finalize() more than once.\n";
74 get_yakl_instance().yakl_is_initialized =
false;
77 get_yakl_instance().yakl_final_mtx.unlock();
88 inline void register_finalize_callback( std::function<
void ()> callback ) { get_yakl_instance().finalize_callbacks.push_back(callback); }