Atlas Runtime
pregion_mgr_util.hpp
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2016 Hewlett Packard Enterprise Development LP
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version. This program is
8  * distributed in the hope that it will be useful, but WITHOUT ANY
9  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11  * for more details. You should have received a copy of the GNU Lesser
12  * General Public License along with this program. If not, see
13  * <http://www.gnu.org/licenses/>.
14  */
15 
16 
17 #ifndef PREGION_MGR_UTIL_HPP
18 #define PREGION_MGR_UTIL_HPP
19 
20 #include <map>
21 #include <utility>
22 
23 #include "pregion_configs.hpp"
24 
25 namespace Atlas {
26 
28 public:
29  typedef std::pair<intptr_t,intptr_t> IntPtrPair;
30  class CmpIntPtr {
31  public:
32  bool operator()(
33  const IntPtrPair & c1, const IntPtrPair & c2) const {
34  return (c1.first < c2.first) &&
35  (c1.second < c2.second);
36  }
37  };
38  typedef std::map<IntPtrPair,uint32_t,CmpIntPtr> MapInterval;
39 
40  PRegionExtentMap() = default;
42  MapInterval::const_iterator ci_end = from.Extents_.end();
43  for (MapInterval::const_iterator ci =
44  from.Extents_.begin(); ci != ci_end; ++ ci)
45  insertExtent(ci->first.first, ci->first.second, ci->second);
46  }
47 
48  void insertExtent(intptr_t first, intptr_t last, uint32_t id)
49  { Extents_[std::make_pair(first,last)] = id; }
50 
51  void deleteExtent(intptr_t first, intptr_t last, uint32_t id) {
52  MapInterval::iterator ci = Extents_.find(
53  std::make_pair(first,last));
54  if (ci != Extents_.end()) Extents_.erase(ci);
55  }
56 
57  uint32_t findExtent(intptr_t first, intptr_t last) const {
58  MapInterval::const_iterator ci = Extents_.find(
59  std::make_pair(first,last));
60  if (ci != Extents_.end()) return ci->second;
61  return kInvalidPRegion_;
62  }
63 private:
64  MapInterval Extents_;
65 };
66 
67 } // namespace Atlas
68 
69 #endif
70 
71 
std::map< IntPtrPair, uint32_t, CmpIntPtr > MapInterval
Definition: pregion_mgr_util.hpp:38
Definition: pregion_mgr_util.hpp:27
Definition: pregion_mgr_util.hpp:30
void deleteExtent(intptr_t first, intptr_t last, uint32_t id)
Definition: pregion_mgr_util.hpp:51
const uint32_t kInvalidPRegion_
Definition: pregion_configs.hpp:33
bool operator()(const IntPtrPair &c1, const IntPtrPair &c2) const
Definition: pregion_mgr_util.hpp:32
uint32_t findExtent(intptr_t first, intptr_t last) const
Definition: pregion_mgr_util.hpp:57
PRegionExtentMap(const PRegionExtentMap &from)
Definition: pregion_mgr_util.hpp:41
void insertExtent(intptr_t first, intptr_t last, uint32_t id)
Definition: pregion_mgr_util.hpp:48
Definition: atlas_alloc_cpp.hpp:21
std::pair< intptr_t, intptr_t > IntPtrPair
Definition: pregion_mgr_util.hpp:29