Repository navigation
Expand file tree
/
Copy pathMetadata.cpp
More file actions
55 lines (45 loc) · 2.25 KB
/
Copy pathMetadata.cpp
File metadata and controls
55 lines (45 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Copyright (c) 2024-2026. The SWAT Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include <fstream>
#include "dtlmod/Variable.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(dtlmod_metadata, dtlmod, "DTL logging about Metadata");
namespace dtlmod {
/// \cond EXCLUDE_FROM_DOCUMENTATION
void Metadata::add_transaction(unsigned int id,
const std::pair<std::vector<size_t>, std::vector<size_t>>& start_and_count,
const std::string& location, sg4::ActorPtr publisher)
{
transaction_infos_[id][start_and_count] = std::make_pair(location, publisher);
}
void Metadata::export_to_file(std::ofstream& ostream) const
{
XBT_DEBUG("Variable %s:", variable_->get_cname());
ostream << variable_->get_element_size() << "\t" << variable_->get_cname() << "\t" << transaction_infos_.size();
ostream << "*{";
auto shape = variable_->get_shape();
const auto last_index = shape.size() - 1;
for (unsigned int i = 0; i < last_index; i++)
ostream << shape[i] << ",";
ostream << shape[last_index] << "}" << std::endl;
for (const auto& [id, transaction] : transaction_infos_) {
XBT_DEBUG(" Transaction %u:", id);
ostream << " Transaction " << id << ":" << std::endl;
for (const auto& [block_info, location] : transaction) {
const auto& [block_start, block_count] = block_info;
const auto& [where, actor] = location;
ostream << " " << where.c_str() << ": [";
XBT_DEBUG(" Actor %s wrote:", actor->get_cname());
unsigned long last = block_start.size() - 1;
for (unsigned long i = 0; i < last; i++) {
ostream << block_start[i] << ":" << block_start[i] + block_count[i] << ", ";
XBT_DEBUG(" Dimension %lu : [%zu..%zu]", i + 1, block_start[i], block_start[i] + block_count[i]);
}
ostream << block_start[last] << ":" << block_start[last] + block_count[last] << "]" << std::endl;
XBT_DEBUG(" Dimension %lu : [%zu..%zu]", last + 1, block_start[last], block_start[last] + block_count[last]);
XBT_DEBUG(" in: %s", where.c_str());
}
}
}
/// \endcond
} // namespace dtlmod