MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / amrex_mempool_init

Function amrex_mempool_init

Src/Base/AMReX_MemPool.cpp:31–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29extern "C" {
30
31void amrex_mempool_init ()
32{
33 if (!initialized)
34 {
35 BL_PROFILE("amrex_mempool_init()");
36
37 initialized = true;
38
39 int nthreads = OpenMP::get_max_threads();
40
41 the_memory_pool.resize(nthreads);
42 for (int i=0; i<nthreads; ++i) {
43 the_memory_pool[i] = std::make_unique<CArena>(0, ArenaInfo().SetCpuMemory());
44 }
45
46#ifdef AMREX_USE_OMP
47#pragma omp parallel num_threads(nthreads)
48#endif
49 {
50 size_t N = 1024*1024*sizeof(double);
51 void *p = amrex_mempool_alloc(N);
52 memset(p, 0, N);
53 amrex_mempool_free(p);
54 }
55
56#ifdef AMREX_MEM_PROFILING
57 MemProfiler::add("MemPool", std::function<MemProfiler::MemInfo()>
58 ([] () -> MemProfiler::MemInfo {
59 int MB_min, MB_max, MB_tot;
60 amrex_mempool_get_stats(MB_min, MB_max, MB_tot);
61 Long b = MB_tot * (1024L*1024L);
62 return {b, b};
63 }));
64#endif
65 }
66}
67
68void amrex_mempool_finalize ()
69{

Callers 1

InitializeMethod · 0.85

Calls 6

get_max_threadsFunction · 0.85
ArenaInfoClass · 0.85
amrex_mempool_allocFunction · 0.85
amrex_mempool_freeFunction · 0.85
amrex_mempool_get_statsFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected