OmniSciDB  8a228a1076
CpuBufferMgr.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, 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 
20 
22 
23 namespace CudaMgr_Namespace {
24 class CudaMgr;
25 }
26 
27 namespace Buffer_Namespace {
28 
29 class CpuBufferMgr : public BufferMgr {
30  public:
31  CpuBufferMgr(const int device_id,
32  const size_t max_buffer_pool_size,
34  const size_t min_slab_size,
35  const size_t max_slab_size,
36  const size_t page_size,
37  AbstractBufferMgr* parent_mgr = nullptr)
38  : BufferMgr(device_id,
39  max_buffer_pool_size,
40  min_slab_size,
41  max_slab_size,
42  page_size,
43  parent_mgr)
44  , cuda_mgr_(cuda_mgr)
45  , allocator_(std::make_unique<Arena>(/*min_block_size=*/max_slab_size +
47 
49  /* the destruction of the allocator automatically frees all memory */
50  }
51 
52  inline MgrType getMgrType() override { return CPU_MGR; }
53  inline std::string getStringMgrType() override { return ToString(CPU_MGR); }
54 
55  private:
56  void addSlab(const size_t slab_size) override;
57  void freeAllMem() override;
58  void allocateBuffer(BufferList::iterator segment_iter,
59  const size_t page_size,
60  const size_t initial_size) override;
61 
63  std::unique_ptr<Arena> allocator_;
64 };
65 
66 } // namespace Buffer_Namespace
constexpr size_t kArenaBlockOverhead
MgrType getMgrType() override
Definition: CpuBufferMgr.h:52
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: CpuBufferMgr.h:62
CpuBufferMgr(const int device_id, const size_t max_buffer_pool_size, CudaMgr_Namespace::CudaMgr *cuda_mgr, const size_t min_slab_size, const size_t max_slab_size, const size_t page_size, AbstractBufferMgr *parent_mgr=nullptr)
Definition: CpuBufferMgr.h:31
Note(s): Forbid Copying Idiom 4.1.
Definition: BufferMgr.h:97
std::unique_ptr< Arena > allocator_
Definition: CpuBufferMgr.h:63
std::string getStringMgrType() override
Definition: CpuBufferMgr.h:53