OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PMemAllocator.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "ArenaAllocator.h"
20 
21 // An arena allocator that uses direct-access PMem for allocations. This implementation
22 // is simplified for now, but we could move it to a PMem allocator under folly if
23 // necessary in the future.
24 class PMemArena : public Arena {
25  public:
26  explicit PMemArena(size_t min_block_size = 1ULL << 32, size_t size_limit = 0);
27 
28  ~PMemArena() override;
29 
30  void* allocate(const size_t num_bytes) override;
31 
32  void* allocateAndZero(const size_t num_bytes) override;
33 
34  size_t bytesUsed() const override;
35 
36  MemoryType getMemoryType() const override { return MemoryType::PMEM; }
37 
38  private:
39  size_t size_limit_;
40  size_t size_;
41  std::vector<std::pair<void*, size_t>> allocations_;
42  struct memkind* pmem_kind_ = NULL;
43 };
PMemArena(size_t min_block_size=1ULL<< 32, size_t size_limit=0)
void * allocate(const size_t num_bytes) override
size_t size_limit_
Definition: PMemAllocator.h:39
~PMemArena() override
size_t bytesUsed() const override
std::vector< std::pair< void *, size_t > > allocations_
Definition: PMemAllocator.h:41
size_t size_
Definition: PMemAllocator.h:40
MemoryType getMemoryType() const override
Definition: PMemAllocator.h:36
struct memkind * pmem_kind_
Definition: PMemAllocator.h:42
void * allocateAndZero(const size_t num_bytes) override