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

daisytuner / docc / 26021330863

18 May 2026 08:07AM UTC coverage: 60.837%. First build
26021330863

Pull #709

github

web-flow
Merge 8ea66ea08 into df89083a8
Pull Request #709: Add support for tenstorrent backend to python front end

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

50.0
/sdfg/include/sdfg/codegen/code_snippet_factory.h
1
#pragma once
2
#include <string>
3
#include <unordered_set>
4

5
#include "utils.h"
6

7
namespace sdfg {
8
namespace codegen {
9

10
inline std::string CODE_SNIPPET_INIT_ONCE = "init_once";
11
inline std::string CODE_SNIPPET_DEINIT_ONCE = "deinit_once";
12

13
class CodeSnippet {
14
protected:
15
    PrettyPrinter stream_;
16
    std::string extension_;
17
    bool as_file_;
18
    std::string name_;
19

20
public:
21
    CodeSnippet(const std::string& name, const std::string& extension, bool as_file)
22
        : extension_(extension), as_file_(as_file), name_(name) {};
4✔
23

24
    PrettyPrinter& stream() { return stream_; }
4✔
25

26
    const PrettyPrinter& stream() const { return stream_; }
4✔
27

28
    const std::string& extension() const { return extension_; }
×
29

30
    bool is_as_file() const { return as_file_; }
×
31

32
    const std::string& name() const { return name_; }
×
33
};
34

35
class LibDependency {
36
public:
NEW
37
    virtual ~LibDependency() = default;
×
38
    virtual std::string_view name() const = 0;
39
    virtual void enumerate_includes(std::vector<std::string>& out_list) const = 0;
40
    virtual std::vector<std::string_view>& globally_unique_ids() const = 0;
41
};
42

43
struct DependencyState {
44
    bool used = false;
45
    bool runtime_available = false;
46
};
47

48
class CodeSnippetFactory {
49
protected:
50
    std::unordered_map<std::string, CodeSnippet> snippets_;
51
    const std::filesystem::path output_path_;
52
    const std::filesystem::path header_path_;
53

54
    std::unordered_set<std::string> setup_snippets_;
55
    std::unordered_set<std::string> teardown_snippets_;
56
    std::unordered_set<std::string> globals_snippets_;
57

58
    std::unordered_map<std::string, const LibDependency*> conflicting_ids_;
59
    std::unordered_map<const LibDependency*, DependencyState> dependencies_;
60

61
public:
62
    CodeSnippetFactory(const std::pair<std::filesystem::path, std::filesystem::path>* config = nullptr);
63

64
    virtual ~CodeSnippetFactory() = default;
57✔
65

66
    CodeSnippet& require(const std::string& name, const std::string& extension, bool as_file = true);
67

68
    std::unordered_map<std::string, CodeSnippet>::iterator find(const std::string& name);
69

70
    const std::unordered_map<std::string, CodeSnippet>& snippets() const;
71

72
    const std::filesystem::path& output_path() const { return output_path_; }
×
73
    const std::filesystem::path& header_path() const { return header_path_; }
4✔
74

75
    void add_setup(const std::string& snippet);
76
    void add_teardown(const std::string& snippet);
77
    void add_global(const std::string& snippet);
78
    const std::unordered_set<std::string>& setup_snippets() const;
79
    const std::unordered_set<std::string>& teardown_snippets() const;
80

81
    std::vector<const LibDependency*> get_used_lib_dependencies() const;
82

83
    const std::unordered_set<std::string>& globals_snippets() const;
84

85
    /**
86
     * For the generation process to declare discovered runtime dependencies before the codegen starts.
87
     * Reasons could be: user code requires that it exists, it has been found in the filesystem or the config says it is
88
     * always available For example tenstorrent debug support, only available if compiled this way locally, then the
89
     * headers of it may be relied upon. Otherwise it would crash
90
     */
91
    void add_available_dependency(const LibDependency* dependency);
92

93
    /**
94
     * The dependency is either already required or the system knows it is available
95
     */
96
    bool is_available(const LibDependency* dependency) const;
97

98
    /**
99
     * Checks if this dependency would conflict with existing ones.
100
     * @return conflict if any: {conflicting ID, source of that ID}
101
     */
102
    std::optional<std::pair<const std::string&, const LibDependency*>> check_for_conflicts(const LibDependency*
103
                                                                                               dependency) const;
104

105
    /**
106
     * Adds conflicts of this dependency to the list, throws if conflicts exist
107
     * Warning: not transactional for now!
108
     */
109
    void require_no_conflicts(const LibDependency* dependency);
110

111
    /**
112
     * Ensure that the given dependency is available or throw
113
     * @return true if the dependency is now newly used
114
     */
115
    bool require_dependency(const LibDependency* dependency);
116
};
117

118

119
} // namespace codegen
120
} // 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