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

daisytuner / sdfglib / 20764569418

06 Jan 2026 10:50PM UTC coverage: 62.168% (+21.4%) from 40.764%
20764569418

push

github

web-flow
Merge pull request #433 from daisytuner/clang-coverage

updates clang coverage flags

14988 of 24109 relevant lines covered (62.17%)

88.57 hits per line

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

66.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);
12
const std::unique_ptr<types::Pointer> Function::CONST_POINTER_TYPE =
13
    std::make_unique<types::Pointer>(types::Scalar(types::PrimitiveType::Void));
14

15
Function::Function(const std::string& name, FunctionType type, const types::IType& return_type)
16
    : element_counter_(0), name_(name), type_(type), return_type_(return_type.clone()) {
996✔
17
    if (this->type_ == FunctionType_NV_GLOBAL) {
996✔
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
};
996✔
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_; };
137✔
49

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

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

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

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

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

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

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

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

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

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

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

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

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

109
symbolic::SymbolSet Function::parameters() const {
×
110
    symbolic::SymbolSet params;
×
111
    for (auto& arg : this->arguments_) {
×
112
        auto& arg_type = this->type(arg);
×
113
        if (auto scalar_type = dynamic_cast<const types::Scalar*>(&arg_type)) {
×
114
            if (scalar_type->is_symbol()) {
×
115
                params.insert(symbolic::symbol(arg));
×
116
            }
×
117
        }
×
118
    }
×
119
    for (auto& ext : this->externals_) {
×
120
        auto& ext_type = this->type(ext);
×
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;
×
128
};
×
129

130
bool Function::has_assumption(const symbolic::Symbol symbol) const {
1✔
131
    return this->assumptions_.find(symbol) != this->assumptions_.end();
1✔
132
};
1✔
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) {
1✔
143
    auto entry = this->assumptions_.find(symbol);
1✔
144
    if (entry == this->assumptions_.end()) {
1✔
145
        throw InvalidSDFGException("Assumption does not exist in SDFG");
×
146
    }
×
147
    return entry->second;
1✔
148
};
1✔
149

150
const symbolic::Assumptions& Function::assumptions() const { return this->assumptions_; };
166✔
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

© 2026 Coveralls, Inc