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

daisytuner / sdfglib / 15494289007

06 Jun 2025 03:36PM UTC coverage: 57.304% (-0.4%) from 57.704%
15494289007

push

github

web-flow
Merge pull request #60 from daisytuner/kernels

removes kernel node in favor of function types

78 of 99 new or added lines in 11 files covered. (78.79%)

91 existing lines in 14 files now uncovered.

7583 of 13233 relevant lines covered (57.3%)

116.04 hits per line

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

82.22
/src/function.cpp
1
#include "sdfg/function.h"
2

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

5
using json = nlohmann::json;
6

7
namespace sdfg {
8

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

14
Function::Function(const std::string& name, FunctionType type) : name_(name), type_(type) {
496✔
15
    if (this->type_ == FunctionType::NV_GLOBAL) {
496✔
16
        this->assumptions_[symbolic::threadIdx_x()] =
13✔
17
            symbolic::Assumption::create(symbolic::threadIdx_x(), *NVPTX_SYMBOL_TYPE);
13✔
18
        this->assumptions_[symbolic::threadIdx_y()] =
13✔
19
            symbolic::Assumption::create(symbolic::threadIdx_y(), *NVPTX_SYMBOL_TYPE);
13✔
20
        this->assumptions_[symbolic::threadIdx_z()] =
13✔
21
            symbolic::Assumption::create(symbolic::threadIdx_z(), *NVPTX_SYMBOL_TYPE);
13✔
22
        this->assumptions_[symbolic::blockIdx_x()] =
13✔
23
            symbolic::Assumption::create(symbolic::blockIdx_x(), *NVPTX_SYMBOL_TYPE);
13✔
24
        this->assumptions_[symbolic::blockIdx_y()] =
13✔
25
            symbolic::Assumption::create(symbolic::blockIdx_y(), *NVPTX_SYMBOL_TYPE);
13✔
26
        this->assumptions_[symbolic::blockIdx_z()] =
13✔
27
            symbolic::Assumption::create(symbolic::blockIdx_z(), *NVPTX_SYMBOL_TYPE);
13✔
28
        this->assumptions_[symbolic::blockDim_x()] =
13✔
29
            symbolic::Assumption::create(symbolic::blockDim_x(), *NVPTX_SYMBOL_TYPE);
13✔
30
        this->assumptions_[symbolic::blockDim_y()] =
13✔
31
            symbolic::Assumption::create(symbolic::blockDim_y(), *NVPTX_SYMBOL_TYPE);
13✔
32
        this->assumptions_[symbolic::blockDim_z()] =
13✔
33
            symbolic::Assumption::create(symbolic::blockDim_z(), *NVPTX_SYMBOL_TYPE);
13✔
34
        this->assumptions_[symbolic::gridDim_x()] =
13✔
35
            symbolic::Assumption::create(symbolic::gridDim_x(), *NVPTX_SYMBOL_TYPE);
13✔
36
        this->assumptions_[symbolic::gridDim_y()] =
13✔
37
            symbolic::Assumption::create(symbolic::gridDim_y(), *NVPTX_SYMBOL_TYPE);
13✔
38
        this->assumptions_[symbolic::gridDim_z()] =
13✔
39
            symbolic::Assumption::create(symbolic::gridDim_z(), *NVPTX_SYMBOL_TYPE);
13✔
40
    }
13✔
41
};
496✔
42

43
std::string Function::name() const { return this->name_; };
742✔
44

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

47
bool Function::exists(const std::string& name) const {
556✔
48
    return this->containers_.find(name) != this->containers_.end() ||
561✔
49
           symbolic::is_pointer(symbolic::symbol(name)) || symbolic::is_nv(symbolic::symbol(name));
5✔
UNCOV
50
};
×
51

52
const types::IType& Function::type(const std::string& name) const {
1,171✔
53
    if (symbolic::is_nv(symbolic::symbol(name))) {
1,171✔
54
        return *NVPTX_SYMBOL_TYPE;
×
55
    }
56
    if (symbolic::is_pointer(symbolic::symbol(name))) {
1,171✔
57
        return *CONST_POINTER_TYPE;
×
58
    }
59

60
    auto entry = this->containers_.find(name);
1,171✔
61
    if (entry == this->containers_.end()) {
1,171✔
62
        throw InvalidSDFGException("Type: Container " + name + " not found");
×
63
    }
64
    return *entry->second;
1,171✔
65
};
1,171✔
66

67
const types::StructureDefinition& Function::structure(const std::string& name) const {
25✔
68
    auto entry = this->structures_.find(name);
25✔
69
    if (entry == this->structures_.end()) {
25✔
70
        throw InvalidSDFGException("Structure: " + name + " not found");
×
71
    }
72
    return *entry->second;
25✔
73
};
×
74

75
const std::vector<std::string>& Function::arguments() const { return this->arguments_; };
16✔
76

77
const std::vector<std::string>& Function::externals() const { return this->externals_; };
25✔
78

79
bool Function::is_argument(const std::string& name) const {
1,378✔
80
    return std::find(this->arguments_.begin(), this->arguments_.end(), name) !=
2,756✔
81
           this->arguments_.end();
1,378✔
82
};
83

84
bool Function::is_external(const std::string& name) const {
1,026✔
85
    return std::find(this->externals_.begin(), this->externals_.end(), name) !=
2,052✔
86
           this->externals_.end();
1,026✔
87
};
88

89
bool Function::is_internal(const std::string& name) const {
1,197✔
90
    return helpers::endswith(name, external_suffix) &&
1,197✔
91
           is_external(name.substr(0, name.length() - external_suffix.length()));
×
92
};
×
93

94
bool Function::is_transient(const std::string& name) const {
1,370✔
95
    return !this->is_argument(name) && !this->is_external(name) && !this->is_internal(name);
1,370✔
96
};
97

98
bool Function::has_assumption(const symbolic::Symbol& symbol) const {
1✔
99
    return this->assumptions_.find(symbol) != this->assumptions_.end();
1✔
100
};
101

102
const symbolic::Assumption& Function::assumption(const symbolic::Symbol& symbol) const {
×
103
    auto entry = this->assumptions_.find(symbol);
×
104
    if (entry == this->assumptions_.end()) {
×
105
        throw InvalidSDFGException("Assumption does not exist in SDFG");
×
106
    }
107
    return entry->second;
×
108
};
×
109

110
symbolic::Assumption& Function::assumption(const symbolic::Symbol& symbol) {
13✔
111
    auto entry = this->assumptions_.find(symbol);
13✔
112
    if (entry == this->assumptions_.end()) {
13✔
113
        throw InvalidSDFGException("Assumption does not exist in SDFG");
×
114
    }
115
    return entry->second;
13✔
116
};
×
117

118
const symbolic::Assumptions& Function::assumptions() const { return this->assumptions_; };
55✔
119

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

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

126
const std::string& Function::metadata(const std::string& key) const {
7✔
127
    return this->metadata_.at(key);
7✔
128
};
129

130
const std::unordered_map<std::string, std::string>& Function::metadata() const {
3✔
131
    return this->metadata_;
3✔
132
};
133

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