| 29 | extern "C" { |
| 30 | |
| 31 | void 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 | |
| 68 | void amrex_mempool_finalize () |
| 69 | { |
no test coverage detected