@@ -74,8 +74,7 @@ const std::pair<unsigned int, unsigned int>& Variable::get_subscriber_transactio
7474void Variable::add_transaction_metadata (unsigned int transaction_id, sg4::ActorPtr publisher,
7575 const std::string& location)
7676{
77- auto start_and_count = std::make_pair (local_start_[publisher], local_count_[publisher]);
78- metadata_->transaction_infos_ [transaction_id][start_and_count] = std::make_pair (location, publisher);
77+ metadata_->add_transaction (transaction_id, local_start_[publisher], local_count_[publisher], location, publisher);
7978}
8079
8180std::vector<std::pair<std::string, sg_size_t >> Variable::get_sizes_to_get_per_block (unsigned int transaction_id,
@@ -84,7 +83,7 @@ std::vector<std::pair<std::string, sg_size_t>> Variable::get_sizes_to_get_per_bl
8483{
8584 std::vector<std::pair<std::string, sg_size_t >> get_sizes_per_block;
8685 // TODO add sanity checks
87- auto blocks = metadata_->transaction_infos_ [ transaction_id] ;
86+ auto blocks = metadata_->get_blocks_for_transaction ( transaction_id) ;
8887 XBT_DEBUG (" %zu block(s) to check for transaction %u" , blocks.size (), transaction_id);
8988 for (const auto & [block_info, location] : blocks) {
9089 size_t size_to_get = element_size_;
@@ -98,18 +97,15 @@ std::vector<std::pair<std::string, sg_size_t>> Variable::get_sizes_to_get_per_bl
9897 block_count[i]);
9998 size_t size_in_dim = 0 ;
10099 bool element_found = false ;
101- if (start[i] <= block_start[i]) {
102- if ((block_start[i] - start[i]) <= count[i]) {
100+ if (start[i] <= block_start[i] && (block_start[i] - start[i]) <= count[i]) {
103101 size_in_dim = std::min (block_count[i], count[i] - (block_start[i] - start[i]));
104102 element_found = true ;
105- }
106- } else {
107- if ((start[i] - block_start[i]) <= block_count[i]) {
103+ }
104+ if (start[i] > block_start[i] && (start[i] - block_start[i]) <= block_count[i]) {
108105 size_in_dim = std::min (count[i], block_count[i] - (start[i] - block_start[i]));
109106 element_found = true ;
110- }
111107 }
112-
108+
113109 if (element_found && size_in_dim > 0 ) {
114110 something_to_get[i] = true ;
115111 XBT_DEBUG (" Mutiply size to read by %zu elements" , size_in_dim);
@@ -119,7 +115,7 @@ std::vector<std::pair<std::string, sg_size_t>> Variable::get_sizes_to_get_per_bl
119115
120116 if (std::all_of (something_to_get.begin (), something_to_get.end (), [](bool v) { return v; })) {
121117 XBT_DEBUG (" Total size to read from %s: %zu)" , where.c_str (), size_to_get);
122- get_sizes_per_block.emplace_back (std::make_pair ( where, size_to_get) );
118+ get_sizes_per_block.emplace_back (where, size_to_get);
123119 }
124120 }
125121 return get_sizes_per_block;
0 commit comments