@@ -27,14 +27,15 @@ using primitive_id = std::string;
27
27
using memory_ptr = std::shared_ptr<memory>;
28
28
29
29
struct memory_user {
30
- primitive_id _id ;
30
+ size_t _unique_id ;
31
31
uint32_t _network_id;
32
+ primitive_id _prim_id;
32
33
33
- memory_user (primitive_id id , uint32_t network_id)
34
- : _id(id ), _network_id(network_id) {}
34
+ memory_user (size_t unique_id , uint32_t network_id, primitive_id prim_id )
35
+ : _unique_id(unique_id ), _network_id(network_id), _prim_id(prim_id ) {}
35
36
36
37
friend std::ostream& operator <<(std::ostream& os, const memory_user& memory_user) {
37
- os << memory_user._id << " ( " << memory_user._network_id << " )" ;
38
+ os << memory_user._prim_id << " (unique_id: " << memory_user. _unique_id << " , net_id: " << memory_user._network_id << " )" ;
38
39
return os;
39
40
}
40
41
};
@@ -43,7 +44,7 @@ struct memory_user_comparer {
43
44
bool operator ()(const memory_user& l_mu, const memory_user& r_mu) const {
44
45
if (l_mu._network_id != r_mu._network_id )
45
46
return l_mu._network_id < r_mu._network_id ;
46
- return l_mu._id < r_mu._id ;
47
+ return l_mu._unique_id < r_mu._unique_id ;
47
48
}
48
49
};
49
50
@@ -91,7 +92,7 @@ class memory_pool {
91
92
memory_pool ();
92
93
93
94
memory_ptr alloc_memory (const layout& layout, allocation_type type, bool reset = true );
94
- static bool has_conflict (const memory_set&, const std::set<primitive_id >&, uint32_t network_id);
95
+ static bool has_conflict (const memory_set&, const std::set<size_t >&, uint32_t network_id);
95
96
96
97
std::multimap<uint64_t , memory_record> _non_padded_pool;
97
98
std::map<layout, std::list<memory_record>, padded_pool_comparer> _padded_pool;
@@ -103,29 +104,33 @@ class memory_pool {
103
104
~memory_pool ();
104
105
memory_ptr get_memory (const layout& layout,
105
106
const primitive_id& id,
107
+ size_t unique_id,
106
108
uint32_t network_id,
107
- const std::set<primitive_id >& restrictions,
109
+ const std::set<size_t >& restrictions,
108
110
allocation_type type,
109
111
bool reusable = true ,
110
112
bool reset = true ); // get from pool or create memory allocation
111
113
memory_ptr get_memory (const layout& layout, allocation_type type, bool reset = true );
112
114
memory_ptr get_from_non_padded_pool (const layout& layout,
113
- const primitive_id& id,
115
+ const primitive_id& prim_id,
116
+ size_t unique_id,
114
117
uint32_t network_id,
115
- const std::set<primitive_id >&,
118
+ const std::set<size_t >&,
116
119
allocation_type type,
117
120
bool reset = true );
118
121
memory_ptr get_from_padded_pool (const layout& layout,
119
- const primitive_id& id,
122
+ const primitive_id& prim_id,
123
+ size_t unique_id,
120
124
uint32_t network_id,
121
- const std::set<primitive_id >& restrictions,
125
+ const std::set<size_t >& restrictions,
122
126
allocation_type type);
123
127
memory_ptr get_from_across_networks_pool (const layout& layout,
124
128
const primitive_id& id,
129
+ size_t unique_id,
125
130
uint32_t network_id,
126
131
allocation_type type);
127
132
void clear_pool_for_network (uint32_t network_id);
128
- void release_memory (memory* memory, const primitive_id& id , uint32_t network_id);
133
+ void release_memory (memory* memory, const size_t & unique_id, primitive_id prim_id , uint32_t network_id);
129
134
130
135
size_t get_non_padded_pool_size () {
131
136
return _non_padded_pool.size ();
0 commit comments