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

daisytuner / sdfglib / 20564758202

29 Dec 2025 12:13AM UTC coverage: 40.366% (+1.4%) from 38.976%
20564758202

push

github

web-flow
Merge pull request #409 from daisytuner/lib-nodes-refactor

restructures library nodes

14298 of 45900 branches covered (31.15%)

Branch coverage included in aggregate %.

259 of 388 new or added lines in 19 files covered. (66.75%)

28 existing lines in 2 files now uncovered.

12247 of 19861 relevant lines covered (61.66%)

89.04 hits per line

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

14.71
/src/data_flow/library_nodes/math/cmath/cmath_node.cpp
1
#include "sdfg/data_flow/library_nodes/math/cmath/cmath_node.h"
2
#include "sdfg/symbolic/symbolic.h"
3

4
namespace sdfg {
5
namespace math {
6
namespace cmath {
7

8
CMathNode::CMathNode(
46✔
9
    size_t element_id,
10
    const DebugInfo& debug_info,
11
    const graph::Vertex vertex,
12
    data_flow::DataFlowGraph& parent,
13
    const std::string& name,
14
    size_t arity
15
)
16
    : MathNode(
46!
17
          element_id, debug_info, vertex, parent, LibraryNodeType_CMath, {"_out"}, {}, data_flow::ImplementationType_NONE
46!
18
      ),
19
      name_(name) {
46!
20
    for (size_t i = 0; i < arity; i++) {
112✔
21
        this->inputs_.push_back("_in" + std::to_string(i + 1));
66!
22
    }
66✔
23
}
46✔
24

NEW
25
const std::string& CMathNode::name() const { return this->name_; }
×
26

27
symbolic::SymbolSet CMathNode::symbols() const { return {}; }
2✔
28

NEW
29
void CMathNode::replace(const symbolic::Expression old_expression, const symbolic::Expression new_expression) {
×
NEW
30
    return;
×
31
}
32

33

34
void CMathNode::validate(const Function& function) const {}
1✔
35

36
std::unique_ptr<data_flow::DataFlowNode> CMathNode::
37
    clone(size_t element_id, const graph::Vertex vertex, data_flow::DataFlowGraph& parent) const {
×
NEW
38
    return std::unique_ptr<
×
NEW
39
        CMathNode>(new CMathNode(element_id, this->debug_info(), vertex, parent, this->name_, this->inputs_.size()));
×
40
}
×
41

42
symbolic::Expression CMathNode::flop() const { return symbolic::one(); }
1✔
43

NEW
44
nlohmann::json CMathNodeSerializer::serialize(const data_flow::LibraryNode& library_node) {
×
NEW
45
    const CMathNode& node = static_cast<const CMathNode&>(library_node);
×
46
    nlohmann::json j;
×
47

48
    serializer::JSONSerializer serializer;
×
49
    j["code"] = node.code().value();
×
50
    j["name"] = node.name();
×
51
    j["arity"] = node.inputs().size();
×
52

53
    return j;
×
54
}
×
55

NEW
56
data_flow::LibraryNode& CMathNodeSerializer::deserialize(
×
57
    const nlohmann::json& j, builder::StructuredSDFGBuilder& builder, structured_control_flow::Block& parent
58
) {
59
    // Assertions for required fields
60
    assert(j.contains("element_id"));
×
61
    assert(j.contains("code"));
×
62
    assert(j.contains("debug_info"));
×
63

64
    auto code = j["code"].get<std::string>();
×
NEW
65
    if (code != LibraryNodeType_CMath.value()) {
×
66
        throw std::runtime_error("Invalid library node code");
×
67
    }
68

69
    // Extract debug info using JSONSerializer
70
    sdfg::serializer::JSONSerializer serializer;
×
71
    DebugInfo debug_info = serializer.json_to_debug_info(j["debug_info"]);
×
72

73
    auto name = j["name"].get<std::string>();
×
74
    auto arity = j["arity"].get<size_t>();
×
75

NEW
76
    return builder.add_library_node<CMathNode>(parent, debug_info, name, arity);
×
77
}
×
78

NEW
79
CMathNodeDispatcher::CMathNodeDispatcher(
×
80
    codegen::LanguageExtension& language_extension,
81
    const Function& function,
82
    const data_flow::DataFlowGraph& data_flow_graph,
83
    const CMathNode& node
84
)
85
    : codegen::LibraryNodeDispatcher(language_extension, function, data_flow_graph, node) {}
×
86

NEW
87
void CMathNodeDispatcher::dispatch_code(
×
88
    codegen::PrettyPrinter& stream,
89
    codegen::PrettyPrinter& globals_stream,
90
    codegen::CodeSnippetFactory& library_snippet_factory
91
) {
92
    stream << "{" << std::endl;
×
93
    stream.setIndent(stream.indent() + 4);
×
94

NEW
95
    auto& node = static_cast<const CMathNode&>(this->node_);
×
96

97
    stream << node.outputs().at(0) << " = ";
×
98
    stream << node.name() << "(";
×
99
    for (size_t i = 0; i < node.inputs().size(); i++) {
×
100
        stream << node.inputs().at(i);
×
101
        if (i < node.inputs().size() - 1) {
×
102
            stream << ", ";
×
103
        }
×
104
    }
×
105
    stream << ");" << std::endl;
×
106

107
    stream.setIndent(stream.indent() - 4);
×
108
    stream << "}" << std::endl;
×
109
}
×
110

111
} // namespace cmath
112
} // namespace math
113
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc