• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / docc / 26520678771

27 May 2026 03:22PM UTC coverage: 60.864% (-0.02%) from 60.886%
26520678771

Pull #719

github

web-flow
Merge 99c5e4f9d into 707dadcf8
Pull Request #719: Libnode ptr edges

961 of 1749 new or added lines in 52 files covered. (54.95%)

90 existing lines in 29 files now uncovered.

35222 of 57870 relevant lines covered (60.86%)

11043.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.33
/sdfg/src/data_flow/library_nodes/stdlib/memcpy.cpp
1
#include "sdfg/data_flow/library_nodes/stdlib/memcpy.h"
2

3
namespace sdfg {
4
namespace stdlib {
5

6
MemcpyNode::MemcpyNode(
7
    size_t element_id,
8
    const DebugInfo& debug_info,
9
    const graph::Vertex vertex,
10
    data_flow::DataFlowGraph& parent,
11
    const symbolic::Expression count
12
)
13
    : StdlibNode(
8✔
14
          element_id,
8✔
15
          debug_info,
8✔
16
          vertex,
8✔
17
          parent,
8✔
18
          LibraryNodeType_Memcpy,
8✔
19
          {},
8✔
20
          {"_dst", "_src"},
8✔
21
          true,
8✔
22
          data_flow::ImplementationType_NONE
8✔
23
      ),
8✔
24
      count_(count) {}
8✔
25

26
const symbolic::Expression MemcpyNode::count() const { return count_; }
4✔
27

28
void MemcpyNode::validate(const Function& function) const { LibraryNode::validate(function); }
6✔
29

30
symbolic::SymbolSet MemcpyNode::symbols() const {
2✔
31
    auto count_symbols = symbolic::atoms(this->count_);
2✔
32
    return count_symbols;
2✔
33
}
2✔
34

35
std::unique_ptr<data_flow::DataFlowNode> MemcpyNode::
36
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
37
    return std::make_unique<MemcpyNode>(element_id, debug_info_, vertex, parent, count_);
×
38
}
×
39

NEW
40
data_flow::PointerAccessType MemcpyNode::pointer_access_type(int input_idx) const {
×
NEW
41
    if (input_idx == 0) {
×
NEW
42
        return data_flow::PointerAccessMeta::create_full_write_only(count_, true);
×
NEW
43
    } else if (input_idx == 1) {
×
NEW
44
        return data_flow::PointerAccessMeta::create_read_only(count_, true);
×
NEW
45
    } else {
×
NEW
46
        return StdlibNode::pointer_access_type(input_idx);
×
NEW
47
    }
×
NEW
48
}
×
49

NEW
50
std::string MemcpyNode::toStr() const { return StdlibNode::toStr() + "(n: " + count_->__str__() + ")"; }
×
51

52
void MemcpyNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
53
    this->count_ = symbolic::subs(this->count_, old_expression, new_expression);
×
54
}
×
55

56
nlohmann::json MemcpyNodeSerializer::serialize(const data_flow::LibraryNode& library_node) {
×
57
    const MemcpyNode& node = static_cast<const MemcpyNode&>(library_node);
×
58

59
    nlohmann::json j;
×
60
    j["code"] = node.code().value();
×
61

62
    sdfg::serializer::JSONSerializer serializer;
×
63
    j["count"] = serializer.expression(node.count());
×
64

65
    return j;
×
66
}
×
67

68
data_flow::LibraryNode& MemcpyNodeSerializer::deserialize(
69
    const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
70
) {
×
71
    assert(j.contains("code"));
×
72
    assert(j.contains("debug_info"));
×
73
    assert(j.contains("count"));
×
74

75
    auto code = j["code"].get<std::string>();
×
76
    if (code != LibraryNodeType_Memcpy.value()) {
×
77
        throw InvalidSDFGException("Invalid library node code");
×
78
    }
×
79

80
    // Extract debug info using JSONSerializer
81
    sdfg::serializer::JSONSerializer serializer;
×
82
    DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
83

84
    // Extract properties
85
    auto count = symbolic::parse(j.at("count"));
×
86

87
    return builder.add_library_node<MemcpyNode>(parent, debug_info, count);
×
88
}
×
89

90
MemcpyNodeDispatcher::MemcpyNodeDispatcher(
91
    codegen::LanguageExtension& language_extension,
92
    const Function& function,
93
    const data_flow::DataFlowGraph& data_flow_graph,
94
    const MemcpyNode& node
95
)
96
    : codegen::LibraryNodeDispatcher(language_extension, function, data_flow_graph, node) {}
×
97

98
void MemcpyNodeDispatcher::dispatch_code_with_edges(
99
    codegen::CodegenOutput& out,
100
    std::vector<codegen::DispatchInput>& inputs,
101
    std::vector<codegen::DispatchOutput>& outputs
102
) {
×
103
    auto& node = static_cast<const MemcpyNode&>(node_);
×
104

NEW
105
    out.stream << language_extension_.external_prefix() << "memcpy(" << inputs.at(0).expr << ", " << inputs.at(1).expr
×
NEW
106
               << ", " << language_extension_.expression(node.count()) << ")" << ";";
×
NEW
107
    out.stream << std::endl;
×
NEW
108
}
×
109

110
MemcpyNode& add_memcpy_node(
111
    builder::StructuredSDFGBuilder& builder,
112
    Block& block,
113
    const std::string& src_ptr,
114
    const std::string& dst_ptr,
115
    const symbolic::Expression& count,
116
    const types::IType& ptr_type,
117
    DebugInfo debug_info
118
) {
8✔
119
    auto& src_ptr_access = builder.add_access(block, src_ptr);
8✔
120
    auto& dst_ptr_access = builder.add_access(block, dst_ptr);
8✔
121
    auto& libnode = builder.add_library_node<stdlib::MemcpyNode>(block, debug_info, count);
8✔
122
    builder.add_computational_memlet(block, src_ptr_access, libnode, "_src", {}, ptr_type);
8✔
123
    builder.add_computational_memlet(block, dst_ptr_access, libnode, "_dst", {}, ptr_type);
8✔
124

125
    return static_cast<MemcpyNode&>(libnode);
8✔
126
}
8✔
127

128
std::tuple<Block&, MemcpyNode&> add_memcpy_block(
129
    builder::StructuredSDFGBuilder& builder,
130
    Sequence& parent,
131
    const std::string& src_ptr,
132
    const std::string& dst_ptr,
133
    const symbolic::Expression& count,
134
    const types::IType& ptr_type,
135
    DebugInfo debug_info
136
) {
8✔
137
    auto& block = builder.add_block(parent);
8✔
138

139
    auto& libnode = add_memcpy_node(builder, block, src_ptr, dst_ptr, count, ptr_type, debug_info);
8✔
140

141
    return {block, libnode};
8✔
142
}
8✔
143

144
} // namespace stdlib
145
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc