OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CpuBufferMgr.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, 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 
18 
19 #include "CudaMgr/CudaMgr.h"
22 
23 namespace Buffer_Namespace {
24 
25 void CpuBufferMgr::addSlab(const size_t slab_size) {
27  slabs_.resize(slabs_.size() + 1);
28  try {
29  slabs_.back() = reinterpret_cast<int8_t*>(allocator_->allocate(slab_size));
30  } catch (std::bad_alloc&) {
31  slabs_.resize(slabs_.size() - 1);
32  throw FailedToCreateSlab(slab_size);
33  }
34  slab_segments_.resize(slab_segments_.size() + 1);
35  slab_segments_[slab_segments_.size() - 1].push_back(
36  BufferSeg(0, slab_size / page_size_));
37 }
38 
41  initializeMem();
42 }
43 
44 void CpuBufferMgr::allocateBuffer(BufferList::iterator seg_it,
45  const size_t page_size,
46  const size_t initial_size) {
47  new CpuBuffer(this,
48  seg_it,
49  device_id_,
50  cuda_mgr_,
51  page_size,
52  initial_size); // this line is admittedly a bit weird but
53  // the segment iterator passed into buffer
54  // takes the address of the new Buffer in its
55  // buffer member
56 }
57 
60 }
61 
62 } // namespace Buffer_Namespace
void addSlab(const size_t slab_size) override
constexpr size_t kArenaBlockOverhead
std::unique_ptr< DramArena > allocator_
Definition: CpuBufferMgr.h:71
void allocateBuffer(BufferList::iterator segment_iter, const size_t page_size, const size_t initial_size) override
std::vector< BufferList > slab_segments_
Definition: BufferMgr.h:180
CudaMgr_Namespace::CudaMgr * cuda_mgr_
Definition: CpuBufferMgr.h:68
#define CHECK(condition)
Definition: Logger.h:291
const size_t max_slab_size_
Definition: BufferMgr.h:175
std::vector< int8_t * > slabs_
Definition: BufferMgr.h:178