Beispiel #1
0
void netbuffer_final() {
    sysint i;

    if(l_nPools > 0) {
        /// .. finalize mempools
        for(i = 0; i < l_nPools; i++) {
            mempool_stats stats = mempool_get_stats(l_pool[i]);

            ShowInfo(read_message("Source.net_buffer_final"), l_poolElemSize[i], stats.peak_nodes_used, stats.num_realloc_events);

            mempool_destroy(l_pool[i]);
        }

        if(l_nEmergencyAllocations > 0) {
            ShowWarning(read_message("Source.net_buffer-final2"), l_nEmergencyAllocations);
            l_nEmergencyAllocations = 0;
        }

        aFree(l_poolElemSize);
        l_poolElemSize = NULL;
        aFree(l_pool);
        l_pool = NULL;
        l_nPools = 0;
    }


}//end: netbuffer_final()
Beispiel #2
0
void netbuffer_final(){
	sysint i;
	
	if(l_nPools > 0){
		/// .. finalize mempools
		for(i = 0; i < l_nPools; i++){
			mempool_stats stats = mempool_get_stats(l_pool[i]);
			
			ShowInfo("Netbuffer: Freeing Pool %u (Peak Usage: %u, Realloc Events: %u)\n", l_poolElemSize[i], stats.peak_nodes_used, stats.num_realloc_events);
						
			mempool_destroy(l_pool[i]);
		}	
	
		if(l_nEmergencyAllocations > 0){
			ShowWarning("Netbuffer: did %u Emergency Allocations, please tune your network.conf!\n", l_nEmergencyAllocations);
			l_nEmergencyAllocations = 0;
		}
	
		aFree(l_poolElemSize);  l_poolElemSize = NULL;
		aFree(l_pool);	l_pool = NULL;
		l_nPools = 0;
	}
	
	
}//end: netbuffer_final()
Beispiel #3
0
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();
}
Beispiel #4
0
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
    }
}