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

daisytuner / sdfglib / 15911673517

26 Jun 2025 08:20PM UTC coverage: 65.102% (+0.003%) from 65.099%
15911673517

push

github

web-flow
Merge pull request #112 from daisytuner/raw-memory-address

removes reinterpret_cast workaround for memory addresses

6 of 13 new or added lines in 4 files covered. (46.15%)

3 existing lines in 3 files now uncovered.

8542 of 13121 relevant lines covered (65.1%)

144.95 hits per line

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

85.45
/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)
552✔
15
    : element_counter_(0), name_(name), type_(type) {
552✔
16
    if (this->type_ == FunctionType_NV_GLOBAL) {
552✔
17
        this->assumptions_[symbolic::threadIdx_x()] =
8✔
18
            symbolic::Assumption::create(symbolic::threadIdx_x(), *NVPTX_SYMBOL_TYPE);
8✔
19
        this->assumptions_[symbolic::threadIdx_y()] =
8✔
20
            symbolic::Assumption::create(symbolic::threadIdx_y(), *NVPTX_SYMBOL_TYPE);
8✔
21
        this->assumptions_[symbolic::threadIdx_z()] =
8✔
22
            symbolic::Assumption::create(symbolic::threadIdx_z(), *NVPTX_SYMBOL_TYPE);
8✔
23
        this->assumptions_[symbolic::blockIdx_x()] =
8✔
24
            symbolic::Assumption::create(symbolic::blockIdx_x(), *NVPTX_SYMBOL_TYPE);
8✔
25
        this->assumptions_[symbolic::blockIdx_y()] =
8✔
26
            symbolic::Assumption::create(symbolic::blockIdx_y(), *NVPTX_SYMBOL_TYPE);
8✔
27
        this->assumptions_[symbolic::blockIdx_z()] =
8✔
28
            symbolic::Assumption::create(symbolic::blockIdx_z(), *NVPTX_SYMBOL_TYPE);
8✔
29
        this->assumptions_[symbolic::blockDim_x()] =
8✔
30
            symbolic::Assumption::create(symbolic::blockDim_x(), *NVPTX_SYMBOL_TYPE);
8✔
31
        this->assumptions_[symbolic::blockDim_y()] =
8✔
32
            symbolic::Assumption::create(symbolic::blockDim_y(), *NVPTX_SYMBOL_TYPE);
8✔
33
        this->assumptions_[symbolic::blockDim_z()] =
8✔
34
            symbolic::Assumption::create(symbolic::blockDim_z(), *NVPTX_SYMBOL_TYPE);
8✔
35
        this->assumptions_[symbolic::gridDim_x()] =
8✔
36
            symbolic::Assumption::create(symbolic::gridDim_x(), *NVPTX_SYMBOL_TYPE);
8✔
37
        this->assumptions_[symbolic::gridDim_y()] =
8✔
38
            symbolic::Assumption::create(symbolic::gridDim_y(), *NVPTX_SYMBOL_TYPE);
8✔
39
        this->assumptions_[symbolic::gridDim_z()] =
8✔
40
            symbolic::Assumption::create(symbolic::gridDim_z(), *NVPTX_SYMBOL_TYPE);
8✔
41
    }
8✔
42
};
552✔
43

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

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

48
bool Function::exists(const std::string& name) const {
799✔
49
    return this->containers_.find(name) != this->containers_.end() ||
813✔
50
           symbolic::is_pointer(symbolic::symbol(name)) || helpers::is_number(name) ||
28✔
51
           symbolic::is_nv(symbolic::symbol(name));
14✔
UNCOV
52
};
×
53

54
const types::IType& Function::type(const std::string& name) const {
1,494✔
55
    if (symbolic::is_nv(symbolic::symbol(name))) {
1,494✔
56
        return *NVPTX_SYMBOL_TYPE;
×
57
    }
58
    if (symbolic::is_pointer(symbolic::symbol(name)) || helpers::is_number(name)) {
1,494✔
59
        return *CONST_POINTER_TYPE;
×
60
    }
61

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

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

77
const std::vector<std::string>& Function::arguments() const { return this->arguments_; };
23✔
78

79
const std::vector<std::string>& Function::externals() const { return this->externals_; };
32✔
80

81
bool Function::is_argument(const std::string& name) const {
885✔
82
    return std::find(this->arguments_.begin(), this->arguments_.end(), name) !=
1,770✔
83
           this->arguments_.end();
885✔
84
};
85

86
bool Function::is_external(const std::string& name) const {
633✔
87
    return std::find(this->externals_.begin(), this->externals_.end(), name) !=
1,266✔
88
           this->externals_.end();
633✔
89
};
90

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

96
bool Function::is_transient(const std::string& name) const {
877✔
97
    return !this->is_argument(name) && !this->is_external(name) && !this->is_internal(name);
877✔
98
};
99

100
symbolic::SymbolSet Function::parameters() const {
8✔
101
    symbolic::SymbolSet params;
8✔
102
    for (auto& arg : this->arguments_) {
27✔
103
        auto& arg_type = this->type(arg);
19✔
104
        if (auto scalar_type = dynamic_cast<const types::Scalar*>(&arg_type)) {
19✔
105
            if (scalar_type->is_symbol()) {
5✔
106
                params.insert(symbolic::symbol(arg));
5✔
107
            }
5✔
108
        }
5✔
109
    }
110
    for (auto& ext : this->externals_) {
14✔
111
        auto& ext_type = this->type(ext);
6✔
112
        if (auto scalar_type = dynamic_cast<const types::Scalar*>(&ext_type)) {
6✔
113
            if (scalar_type->is_symbol()) {
3✔
114
                params.insert(symbolic::symbol(ext));
3✔
115
            }
3✔
116
        }
3✔
117
    }
118
    return params;
8✔
119
};
8✔
120

121
bool Function::has_assumption(const symbolic::Symbol& symbol) const {
1✔
122
    return this->assumptions_.find(symbol) != this->assumptions_.end();
1✔
123
};
124

125
const symbolic::Assumption& Function::assumption(const symbolic::Symbol& symbol) const {
×
126
    auto entry = this->assumptions_.find(symbol);
×
127
    if (entry == this->assumptions_.end()) {
×
128
        throw InvalidSDFGException("Assumption does not exist in SDFG");
×
129
    }
130
    return entry->second;
×
131
};
×
132

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

141
const symbolic::Assumptions& Function::assumptions() const { return this->assumptions_; };
444✔
142

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

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

149
const std::string& Function::metadata(const std::string& key) const {
7✔
150
    return this->metadata_.at(key);
7✔
151
};
152

153
const std::unordered_map<std::string, std::string>& Function::metadata() const {
3✔
154
    return this->metadata_;
3✔
155
};
156

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