void BoxLib::Finalize (bool finalize_parallel) { BL_PROFILE_FINALIZE(); #ifdef BL_LAZY Lazy::Finalize(); #endif while (!The_Finalize_Function_Stack.empty()) { // // Call the registered function. // (*The_Finalize_Function_Stack.top())(); // // And then remove it from the stack. // The_Finalize_Function_Stack.pop(); } // The MemPool stuff is not using The_Finalize_Function_Stack so that // it can be used in Fortran BoxLib. int mp_min, mp_max, mp_tot; mempool_get_stats(mp_min, mp_max, mp_tot); // in MB if (ParallelDescriptor::NProcs() == 1) { if (mp_tot > 0) { std::cout << "MemPool: " #ifdef _OPENMP << "min used in a thread: " << mp_min << " MB, " << "max used in a thread: " << mp_max << " MB, " #endif << "tot used: " << mp_tot << " MB." << std::endl; } } else { int global_max = mp_tot; int global_min = mp_tot; ParallelDescriptor::ReduceIntMax(global_max); if (global_max > 0) { ParallelDescriptor::ReduceIntMin(global_min); if (ParallelDescriptor::IOProcessor()) { std::cout << "MemPool: " << "min used in a rank: " << global_min << " MB, " << "max used in a rank: " << global_max << " MB." << std::endl; } } } if (finalize_parallel) ParallelDescriptor::EndParallel(); }
void BoxLib::Finalize (bool finalize_parallel) { BL_PROFILE_FINALIZE(); while (!The_Finalize_Function_Stack.empty()) { // // Call the registered function. // (*The_Finalize_Function_Stack.top())(); // // And then remove it from the stack. // The_Finalize_Function_Stack.pop(); } if (finalize_parallel) ParallelDescriptor::EndParallel(); }
void BoxLib::Finalize (bool finalize_parallel) { BL_PROFILE_FINALIZE(); #ifdef BL_LAZY Lazy::Finalize(); #endif while (!The_Finalize_Function_Stack.empty()) { // // Call the registered function. // (*The_Finalize_Function_Stack.top())(); // // And then remove it from the stack. // The_Finalize_Function_Stack.pop(); } // The MemPool stuff is not using The_Finalize_Function_Stack so that // it can be used in Fortran BoxLib. #ifndef BL_AMRPROF if (BoxLib::verbose) { int mp_min, mp_max, mp_tot; mempool_get_stats(mp_min, mp_max, mp_tot); // in MB if (ParallelDescriptor::NProcs() == 1) { if (mp_tot > 0) { std::cout << "MemPool: " #ifdef _OPENMP << "min used in a thread: " << mp_min << " MB, " << "max used in a thread: " << mp_max << " MB, " #endif << "tot used: " << mp_tot << " MB." << std::endl; } } else { int global_max = mp_tot; int global_min = mp_tot; ParallelDescriptor::ReduceIntMax(global_max); if (global_max > 0) { ParallelDescriptor::ReduceIntMin(global_min); if (ParallelDescriptor::IOProcessor()) { std::cout << "MemPool: " << "min used in a rank: " << global_min << " MB, " << "max used in a rank: " << global_max << " MB." << std::endl; } } } } #endif #ifdef BL_MEM_PROFILING MemProfiler::report("Final"); #endif ParallelDescriptor::EndTeams(); ParallelDescriptor::EndSubCommunicator(); #ifdef BL_USE_UPCXX upcxx::finalize(); #endif if (finalize_parallel) { #if defined(BL_USE_FORTRAN_MPI) || defined(BL_USE_F_INTERFACES) #ifdef IN_TRANSIT int fcomm = MPI_Comm_c2f(ParallelDescriptor::Communicator()); bl_fortran_sidecar_mpi_comm_free(fcomm); #else bl_fortran_mpi_comm_free(); #endif #endif /* Don't shut down MPI if GASNet is still using MPI */ #ifndef GASNET_CONDUIT_MPI ParallelDescriptor::EndParallel(); #endif } }