7 #ifndef OMEGA_H_KOKKOS_POOL_HPP
8 #define OMEGA_H_KOKKOS_POOL_HPP
16 #include "Kokkos_Core.hpp"
17 #include "Omega_h_kokkos.hpp"
21 constexpr
size_t DEFAULT_BYTES_PER_CHUNK = 1000;
24 constexpr
size_t DEFAULT_NUMBER_OF_CHUNKS = 700'000;
27 constexpr
size_t DEFAULT_GROWTH_CONSTANT = 2;
29 using IndexPair = std::pair<size_t, size_t>;
33 using is_transparent =
36 auto operator()(IndexPair lhs, IndexPair rhs)
const -> bool;
37 auto operator()(IndexPair lhs,
size_t rhs)
const -> bool;
38 auto operator()(
size_t lhs, IndexPair rhs)
const -> bool;
41 using MultiSetBySizeT = std::multiset<IndexPair, CompareFreeIndices>;
42 using SetByIndexT = std::set<IndexPair>;
53 auto allocate(
size_t n) ->
void*;
54 void deallocate(
void* data);
56 auto getNumAllocations()
const -> unsigned;
57 auto getNumFreeChunks()
const -> unsigned;
58 auto getNumAllocatedChunks()
const -> unsigned;
59 auto getNumChunks()
const -> unsigned;
60 auto getNumFreeFragments()
const -> unsigned;
62 static auto getRequiredChunks(
size_t n,
size_t bytesPerChunk) -> size_t;
67 auto insertIntoSets(IndexPair indices)
68 -> std::pair<MultiSetBySizeT::iterator, SetByIndexT::iterator>;
69 void removeFromSets(IndexPair indices);
71 const size_t numberOfChunks;
72 const size_t chunkSize;
75 MultiSetBySizeT freeSetBySize;
76 SetByIndexT freeSetByIndex;
77 std::map<void*, IndexPair> allocations;
89 auto allocate(
size_t n) ->
void*;
90 void deallocate(
void* data);
92 template <
typename DataType>
93 auto allocateView(
size_t n) -> View<DataType*> {
94 return View<DataType*>(
95 reinterpret_cast<DataType*
>(allocate(n *
sizeof(DataType))), n);
98 template <
typename DataType>
99 void deallocateView(View<DataType*> view) {
100 deallocate(
reinterpret_cast<void*
>(view.data()));
103 auto getNumAllocations()
const -> unsigned;
104 auto getNumFreeChunks()
const -> unsigned;
105 auto getNumAllocatedChunks()
const -> unsigned;
106 auto getNumChunks()
const -> unsigned;
107 auto getNumFreeFragments()
const -> unsigned;
108 auto getChunkSize()
const -> size_t;
111 static auto destroyGlobalPool() -> void;
114 using PoolListT = std::list<StaticKokkosPool>;
118 std::map<void*, PoolListT::iterator> allocations;
Definition: Omega_h_pool_kokkos.hpp:31
A memory pool for allocating and deallocating chunks of memory.
Definition: Omega_h_pool_kokkos.hpp:85
A memory pool for allocating and deallocating chunks of memory.
Definition: Omega_h_pool_kokkos.hpp:49
Definition: amr_mpi_test.cpp:6