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

daisytuner / sdfglib / 19162352523

07 Nov 2025 08:16AM UTC coverage: 61.556% (-0.4%) from 61.911%
19162352523

push

github

web-flow
rewrite of arg captures to work on a scope level (#319)

* rewrite of arg captures to work on a scope level

* adding first unit tests for arg capturing

* Fix scoped arg captures

* Fix debug output

* Only write capture fila name to index

* Switch to element-id based capture storage

* Reenable debug prints

* Fix serialization deserialization of arg capture index

* Use fake node ids in rtl test

* Add debug output for capture file creation

* Boost coverage

---------

Co-authored-by: Nora Hagmeyer <nora.hagmeyer@daisytuner.com>

171 of 320 new or added lines in 18 files covered. (53.44%)

17 existing lines in 5 files now uncovered.

10265 of 16676 relevant lines covered (61.56%)

100.85 hits per line

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

77.78
/src/function.cpp
1
#include "sdfg/function.h"
2
#include <cstddef>
3

4
#include "sdfg/symbolic/symbolic.h"
5

6
using json = nlohmann::json;
7

8
namespace sdfg {
9

10
const std::unique_ptr<types::Scalar> Function::NVPTX_SYMBOL_TYPE =
11
    std::make_unique<types::Scalar>(types::PrimitiveType::UInt32);
2✔
12
const std::unique_ptr<types::Pointer> Function::CONST_POINTER_TYPE =
2✔
13
    std::make_unique<types::Pointer>(types::Scalar(types::PrimitiveType::Void));
2✔
14

15
Function::Function(const std::string& name, FunctionType type, const types::IType& return_type)
974✔
16
    : element_counter_(0), name_(name), type_(type), return_type_(return_type.clone()) {
487✔
17
    if (this->type_ == FunctionType_NV_GLOBAL) {
487✔
18
        this->assumptions_[symbolic::threadIdx_x()] =
4✔
19
            symbolic::Assumption::create(symbolic::threadIdx_x(), *NVPTX_SYMBOL_TYPE);
4✔
20
        this->assumptions_[symbolic::threadIdx_y()] =
4✔
21
            symbolic::Assumption::create(symbolic::threadIdx_y(), *NVPTX_SYMBOL_TYPE);
4✔
22
        this->assumptions_[symbolic::threadIdx_z()] =
4✔
23
            symbolic::Assumption::create(symbolic::threadIdx_z(), *NVPTX_SYMBOL_TYPE);
4✔
24
        this->assumptions_[symbolic::blockIdx_x()] =
4✔
25
            symbolic::Assumption::create(symbolic::blockIdx_x(), *NVPTX_SYMBOL_TYPE);
4✔
26
        this->assumptions_[symbolic::blockIdx_y()] =
4✔
27
            symbolic::Assumption::create(symbolic::blockIdx_y(), *NVPTX_SYMBOL_TYPE);
4✔
28
        this->assumptions_[symbolic::blockIdx_z()] =
4✔
29
            symbolic::Assumption::create(symbolic::blockIdx_z(), *NVPTX_SYMBOL_TYPE);
4✔
30
        this->assumptions_[symbolic::blockDim_x()] =
4✔
31
            symbolic::Assumption::create(symbolic::blockDim_x(), *NVPTX_SYMBOL_TYPE);
4✔
32
        this->assumptions_[symbolic::blockDim_y()] =
4✔
33
            symbolic::Assumption::create(symbolic::blockDim_y(), *NVPTX_SYMBOL_TYPE);
4✔
34
        this->assumptions_[symbolic::blockDim_z()] =
4✔
35
            symbolic::Assumption::create(symbolic::blockDim_z(), *NVPTX_SYMBOL_TYPE);
4✔
36
        this->assumptions_[symbolic::gridDim_x()] =
4✔
37
            symbolic::Assumption::create(symbolic::gridDim_x(), *NVPTX_SYMBOL_TYPE);
4✔
38
        this->assumptions_[symbolic::gridDim_y()] =
4✔
39
            symbolic::Assumption::create(symbolic::gridDim_y(), *NVPTX_SYMBOL_TYPE);
4✔
40
        this->assumptions_[symbolic::gridDim_z()] =
4✔
41
            symbolic::Assumption::create(symbolic::gridDim_z(), *NVPTX_SYMBOL_TYPE);
4✔
42
    }
4✔
43
};
487✔
44

45
Function::Function(const std::string& name, FunctionType type)
×
46
    : Function(name, type, types::Scalar(types::PrimitiveType::Void)) {}
×
47

48
const std::string& Function::name() const { return this->name_; };
125✔
49

50
void Function::name(const std::string& name) { this->name_ = name; };
×
51

52
FunctionType Function::type() const { return this->type_; };
34✔
53

54
const types::IType& Function::return_type() const { return *this->return_type_; };
13✔
55

56
size_t Function::element_counter() const { return this->element_counter_; };
7✔
57

58
void Function::validate() const {
389✔
59
    // Function type
60
    if (this->type_ != FunctionType_CPU && this->type_ != FunctionType_NV_GLOBAL) {
389✔
61
        throw InvalidSDFGException("Function type must be CPU or NV_GLOBAL");
×
62
    }
63
};
389✔
64

65
bool Function::exists(const std::string& name) const {
940✔
66
    return this->containers_.find(name) != this->containers_.end();
940✔
67
};
68

69
const types::IType& Function::type(const std::string& name) const {
2,812✔
70
    auto entry = this->containers_.find(name);
2,812✔
71
    if (entry == this->containers_.end()) {
2,812✔
72
        throw InvalidSDFGException("Type: Container " + name + " not found");
×
73
    }
74
    return *entry->second;
2,812✔
75
};
×
76

77
const types::StructureDefinition& Function::structure(const std::string& name) const {
26✔
78
    auto entry = this->structures_.find(name);
26✔
79
    if (entry == this->structures_.end()) {
26✔
80
        throw InvalidSDFGException("Structure: " + name + " not found");
×
81
    }
82
    return *entry->second;
26✔
83
};
×
84

85
const std::vector<std::string>& Function::arguments() const { return this->arguments_; };
176✔
86

87
const std::vector<std::string>& Function::externals() const { return this->externals_; };
62✔
88

89
LinkageType Function::linkage_type(const std::string& name) const {
13✔
90
    auto entry = this->externals_linkage_types_.find(name);
13✔
91
    if (entry == this->externals_linkage_types_.end()) {
13✔
92
        throw InvalidSDFGException("Linkage type: " + name + " not found");
×
93
    }
94
    return entry->second;
13✔
95
};
×
96

97
bool Function::is_argument(const std::string& name) const {
295✔
98
    return std::find(this->arguments_.begin(), this->arguments_.end(), name) != this->arguments_.end();
295✔
99
};
100

101
bool Function::is_external(const std::string& name) const {
224✔
102
    return std::find(this->externals_.begin(), this->externals_.end(), name) != this->externals_.end();
224✔
103
};
104

105
bool Function::is_transient(const std::string& name) const {
228✔
106
    return !this->is_argument(name) && !this->is_external(name);
228✔
107
};
108

109
symbolic::SymbolSet Function::parameters() const {
17✔
110
    symbolic::SymbolSet params;
17✔
111
    for (auto& arg : this->arguments_) {
50✔
112
        auto& arg_type = this->type(arg);
33✔
113
        if (auto scalar_type = dynamic_cast<const types::Scalar*>(&arg_type)) {
33✔
114
            if (scalar_type->is_symbol()) {
12✔
115
                params.insert(symbolic::symbol(arg));
12✔
116
            }
12✔
117
        }
12✔
118
    }
119
    for (auto& ext : this->externals_) {
17✔
UNCOV
120
        auto& ext_type = this->type(ext);
×
UNCOV
121
        if (auto scalar_type = dynamic_cast<const types::Scalar*>(&ext_type)) {
×
122
            if (scalar_type->is_symbol()) {
×
123
                params.insert(symbolic::symbol(ext));
×
124
            }
×
125
        }
×
126
    }
127
    return params;
17✔
128
};
17✔
129

130
bool Function::has_assumption(const symbolic::Symbol symbol) const {
1✔
131
    return this->assumptions_.find(symbol) != this->assumptions_.end();
1✔
132
};
133

134
const symbolic::Assumption& Function::assumption(const symbolic::Symbol symbol) const {
×
135
    auto entry = this->assumptions_.find(symbol);
×
136
    if (entry == this->assumptions_.end()) {
×
137
        throw InvalidSDFGException("Assumption does not exist in SDFG");
×
138
    }
139
    return entry->second;
×
140
};
×
141

142
symbolic::Assumption& Function::assumption(const symbolic::Symbol symbol) {
3✔
143
    auto entry = this->assumptions_.find(symbol);
3✔
144
    if (entry == this->assumptions_.end()) {
3✔
145
        throw InvalidSDFGException("Assumption does not exist in SDFG");
×
146
    }
147
    return entry->second;
3✔
148
};
×
149

150
const symbolic::Assumptions& Function::assumptions() const { return this->assumptions_; };
605✔
151

152
void Function::add_metadata(const std::string& key, const std::string& value) { this->metadata_[key] = value; };
6✔
153

154
void Function::remove_metadata(const std::string& key) { this->metadata_.erase(key); };
2✔
155

156
const std::string& Function::metadata(const std::string& key) const { return this->metadata_.at(key); };
7✔
157

158
const std::unordered_map<std::string, std::string>& Function::metadata() const { return this->metadata_; };
7✔
159

160
} // 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