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

daisytuner / docc / 26024270535

18 May 2026 09:11AM UTC coverage: 60.837%. First build
26024270535

push

github

web-flow
Add support for tenstorrent backend to python front end (#709)

 + moved lib-node mapping into DoccTarget / discoverable support instead of needing to hardcode the targets
 ~ avoid throwing & suppressing exception on metadata miss in python front-end
 - remove default cblas.h inclusion from codegen.
 + CodeSnippetFactory.LibDependency support that is smarter, can check for conflicts and supports querying available libs and headers as successor to the emit_once hacks of old and more targeted then the "globals"
 + TT and Blas use the new libDependencies to include each as needed and report potential conflicts
 + Support to handle file-snippets as src-only outputs, without compiling or linking
 + Tenstorrent DoccTarget that handles kernel sources correctly (src-only)
 * et & tenstorrent target libs now can simply depend on c-compile lib
 + TT_TESTS and presence of a tt accelerator unlocks the tenstorrent numpy matmul test
 * Improved use of DoccTarget
 + now using DoccTarget also for expand step (instead of python-based overrides)
 + all known targets are now DoccTargets (including sequential, openmp)
 + using TargetOptions from python to make the code more extensible

12 of 121 new or added lines in 9 files covered. (9.92%)

34996 of 57524 relevant lines covered (60.84%)

11107.98 hits per line

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

17.95
/sdfg/src/codegen/code_snippet_factory.cpp
1
#include "sdfg/codegen/code_snippet_factory.h"
2
#include <algorithm>
3
#include <unordered_set>
4

5
namespace sdfg::codegen {
6

7
CodeSnippetFactory::CodeSnippetFactory(const std::pair<std::filesystem::path, std::filesystem::path>* config)
8
    : output_path_(config ? config->first : "."), header_path_(config ? config->second : "") {}
57✔
9

10

11
CodeSnippet& CodeSnippetFactory::require(const std::string& name, const std::string& extension, bool as_file) {
4✔
12
    auto [snippet, newly_created] = snippets_.try_emplace(name, name, extension, as_file);
4✔
13

14
    if (!newly_created && extension != snippet->second.extension()) {
4✔
15
        throw std::runtime_error(
×
16
            "Code snippet " + name + " already exists with '." + snippet->second.extension() +
×
17
            "', but was required with '." + extension + "'"
×
18
        );
×
19
    }
×
20

21
    return snippet->second;
4✔
22
}
4✔
23

24
std::unordered_map<std::string, CodeSnippet>::iterator CodeSnippetFactory::find(const std::string& name) {
2✔
25
    return snippets_.find(name);
2✔
26
}
2✔
27
const std::unordered_map<std::string, CodeSnippet>& CodeSnippetFactory::snippets() const { return snippets_; }
26✔
28

29
void CodeSnippetFactory::add_setup(const std::string& snippet) { setup_snippets_.insert(snippet); }
×
30

31
void CodeSnippetFactory::add_teardown(const std::string& snippet) { teardown_snippets_.insert(snippet); }
×
32

33
void CodeSnippetFactory::add_global(const std::string& snippet) { globals_snippets_.insert(snippet); }
4✔
34

35
const std::unordered_set<std::string>& CodeSnippetFactory::setup_snippets() const { return setup_snippets_; }
1✔
36

37
const std::unordered_set<std::string>& CodeSnippetFactory::teardown_snippets() const { return teardown_snippets_; }
3✔
38

NEW
39
std::vector<const LibDependency*> CodeSnippetFactory::get_used_lib_dependencies() const {
×
NEW
40
    std::vector<const LibDependency*> dependencies;
×
NEW
41
    dependencies.reserve(dependencies_.size());
×
42

NEW
43
    for (const auto& [dependency, state] : dependencies_) {
×
NEW
44
        dependencies.push_back(dependency);
×
NEW
45
    }
×
46

NEW
47
    std::sort(dependencies.begin(), dependencies.end(), [](const LibDependency* lhs, const LibDependency* rhs) {
×
NEW
48
        return lhs->name() < rhs->name();
×
NEW
49
    });
×
50

NEW
51
    return dependencies;
×
NEW
52
}
×
53

54
const std::unordered_set<std::string>& CodeSnippetFactory::globals_snippets() const { return globals_snippets_; }
5✔
55

NEW
56
void CodeSnippetFactory::add_available_dependency(const LibDependency* dependency) {
×
NEW
57
    dependencies_.emplace(dependency, DependencyState{.used = false, .runtime_available = true});
×
NEW
58
}
×
59

NEW
60
bool CodeSnippetFactory::is_available(const LibDependency* dependency) const {
×
NEW
61
    auto it = dependencies_.find(dependency);
×
NEW
62
    return it != dependencies_.end();
×
NEW
63
}
×
64

65
std::optional<std::pair<const std::string&, const LibDependency*>> CodeSnippetFactory::
NEW
66
    check_for_conflicts(const LibDependency* dependency) const {
×
NEW
67
    auto& ids = dependency->globally_unique_ids();
×
NEW
68
    for (auto& id : ids) {
×
NEW
69
        std::string s(id);
×
NEW
70
        auto it = conflicting_ids_.find(s);
×
NEW
71
        if (it != conflicting_ids_.end()) {
×
NEW
72
            return {{s, it->second}};
×
NEW
73
        }
×
NEW
74
    }
×
NEW
75
    return std::nullopt;
×
NEW
76
}
×
77

NEW
78
void CodeSnippetFactory::require_no_conflicts(const LibDependency* dependency) {
×
NEW
79
    auto& ids = dependency->globally_unique_ids();
×
NEW
80
    for (auto& id : ids) {
×
NEW
81
        auto [it, newly_created] = conflicting_ids_.emplace(id, dependency);
×
NEW
82
        if (!newly_created) {
×
NEW
83
            throw std::runtime_error(
×
NEW
84
                "Cannot add '" + std::string(dependency->name()) + "', conflicting globally unique id '" +
×
NEW
85
                std::string(id) + "' with '" + std::string(it->second->name()) + "'"
×
NEW
86
            );
×
NEW
87
        }
×
NEW
88
    }
×
NEW
89
}
×
90

NEW
91
bool CodeSnippetFactory::require_dependency(const LibDependency* dependency) {
×
NEW
92
    auto [it, newly_created] = dependencies_.emplace(dependency, DependencyState{.used = true});
×
NEW
93
    if (newly_created) {
×
NEW
94
        require_no_conflicts(dependency);
×
NEW
95
        return true;
×
NEW
96
    } else {
×
NEW
97
        auto& state = it->second;
×
NEW
98
        if (!state.used) {
×
NEW
99
            require_no_conflicts(dependency);
×
NEW
100
            state.used = true;
×
101

NEW
102
            return true;
×
NEW
103
        } else {
×
NEW
104
            return false;
×
NEW
105
        }
×
NEW
106
    }
×
NEW
107
}
×
108

109
} // namespace sdfg::codegen
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