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

daisytuner / sdfglib / 17979947011

24 Sep 2025 02:28PM UTC coverage: 61.235% (-0.03%) from 61.26%
17979947011

Pull #245

github

web-flow
Merge 1406be24f into 96cc2db74
Pull Request #245: Lib node offloading

2 of 8 new or added lines in 3 files covered. (25.0%)

1 existing line in 1 file now uncovered.

9560 of 15612 relevant lines covered (61.23%)

111.42 hits per line

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

78.38
/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)
1,186✔
16
    : element_counter_(0), name_(name), type_(type), return_type_(return_type.clone()) {
593✔
17
    if (this->type_ == FunctionType_NV_GLOBAL) {
593✔
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
};
593✔
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_; };
370✔
49

50
std::string& Function::name() { return this->name_; };
397✔
51

52
FunctionType Function::type() const { return this->type_; };
31✔
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 {
366✔
59
    // Function type
60
    if (this->type_ != FunctionType_CPU && this->type_ != FunctionType_NV_GLOBAL) {
366✔
61
        throw InvalidSDFGException("Function type must be CPU or NV_GLOBAL");
×
62
    }
63
};
366✔
64

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

69
const types::IType& Function::type(const std::string& name) const {
1,818✔
70
    auto entry = this->containers_.find(name);
1,818✔
71
    if (entry == this->containers_.end()) {
1,818✔
72
        throw InvalidSDFGException("Type: Container " + name + " not found");
×
73
    }
74
    return *entry->second;
1,818✔
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_; };
31✔
86

87
const std::vector<std::string>& Function::externals() const { return this->externals_; };
54✔
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

NEW
97
const std::unordered_set<std::string>& Function::offloaded_functions() const { return this->offloaded_functions_; };
×
98

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

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

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

NEW
111
bool Function::is_offloaded_function(const std::string& name) const {
×
NEW
112
    return this->offloaded_functions_.find(name) != this->offloaded_functions_.end();
×
113
};
114

115
symbolic::SymbolSet Function::parameters() const {
14✔
116
    symbolic::SymbolSet params;
14✔
117
    for (auto& arg : this->arguments_) {
49✔
118
        auto& arg_type = this->type(arg);
35✔
119
        if (auto scalar_type = dynamic_cast<const types::Scalar*>(&arg_type)) {
35✔
120
            if (scalar_type->is_symbol()) {
11✔
121
                params.insert(symbolic::symbol(arg));
11✔
122
            }
11✔
123
        }
11✔
124
    }
125
    for (auto& ext : this->externals_) {
17✔
126
        auto& ext_type = this->type(ext);
3✔
127
        if (auto scalar_type = dynamic_cast<const types::Scalar*>(&ext_type)) {
3✔
128
            if (scalar_type->is_symbol()) {
×
129
                params.insert(symbolic::symbol(ext));
×
130
            }
×
131
        }
×
132
    }
133
    return params;
14✔
134
};
14✔
135

136
bool Function::has_assumption(const symbolic::Symbol symbol) const {
1✔
137
    return this->assumptions_.find(symbol) != this->assumptions_.end();
1✔
138
};
139

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

148
symbolic::Assumption& Function::assumption(const symbolic::Symbol symbol) {
3✔
149
    auto entry = this->assumptions_.find(symbol);
3✔
150
    if (entry == this->assumptions_.end()) {
3✔
151
        throw InvalidSDFGException("Assumption does not exist in SDFG");
×
152
    }
153
    return entry->second;
3✔
154
};
×
155

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

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

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

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

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

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

© 2026 Coveralls, Inc