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

Method alloc

Src/Base/AMReX_PArena.cpp:53–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void*
54PArena::alloc (std::size_t nbytes)
55{
56#if defined(AMREX_USE_GPU)
57
58#if defined(AMREX_GPU_STREAM_ALLOC_SUPPORT)
59 if (Gpu::Device::memoryPoolsSupported()) {
60 void* p;
61 AMREX_HIP_OR_CUDA(
62 AMREX_HIP_SAFE_CALL(hipMallocAsync(&p, nbytes, m_pool, Gpu::gpuStream()));,
63 AMREX_CUDA_SAFE_CALL(cudaMallocAsync(&p, nbytes, m_pool, Gpu::gpuStream()));
64 )
65 m_profiler.profile_alloc(p, nbytes);
66 return p;
67 } else
68#endif
69 {
70 return The_Arena()->alloc(nbytes);
71 }
72
73#elif defined(AMREX_USE_OMP)
74
75 if (omp_in_parallel()) {
76 return amrex_mempool_alloc(nbytes);
77 } else {
78 return The_Arena()->alloc(nbytes);
79 }
80
81#else
82
83 return The_Arena()->alloc(nbytes);
84
85#endif
86}
87
88void
89PArena::free (void* p)

Callers

nothing calls this directly

Calls 4

gpuStreamFunction · 0.85
The_ArenaFunction · 0.85
amrex_mempool_allocFunction · 0.85
profile_allocMethod · 0.80

Tested by

no test coverage detected