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

daisytuner / docc / 24845644334

23 Apr 2026 04:05PM UTC coverage: 64.104% (-0.06%) from 64.167%
24845644334

push

github

web-flow
Modular Compile process (#690)

 + DoccTarget to allow modularly adding support for snippets that need to be compiled differently (standalone, cross-compiled kernels or just with special compilers)
 + Builder infrastructure to define C/C++ build options with inheritance, overrides and ability to modify by plugins, extensions and targets as needed
 + The redirected handling of snippets based on the extension can contribute link-options when they have been used (the generic solution to highway support)
 + Model to handle any parallism for compile in its own class without having to touch the definitions and compile options
 + DoccPaths extended to resolve default plugin dirs (as used by et-plugin)
 + PrettyPrinter can write directly to another (file) stream instead of a local buffer
 * extended CodeGenerator to allow generating the header first and direct-to-file (its needed for all snippet & main compile, which could be parallel otherwise)
 + Defaults to parallel builds with as many cores as present
 + DOCC_DEBUG is more defined. A list of key-value pairs separated by ; or : Supported options: "dump" dump sdfgs, "build" add debug symbols, "build_threads=x" override thread count. less then 1 is the default auto-selection.
 + CodegenStats is integrated into the new Compiler concept. To reduce the impact of the asynchronicity, times are always measured, but only recored with the CodegenStats if enabled and later, in sequential places. The items recorded now include the sdfg & snippet names to identify slow parts
 + Switched MacOS tests over to inplace-python with only 1 build

224 of 347 new or added lines in 13 files covered. (64.55%)

2 existing lines in 2 files now uncovered.

30800 of 48047 relevant lines covered (64.1%)

573.39 hits per line

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

58.33
/sdfg/include/sdfg/codegen/code_generator.h
1
#pragma once
2

3
#include <filesystem>
4
#include <string>
5
#include <utility>
6

7
#include "code_snippet_factory.h"
8
#include "sdfg/analysis/mem_access_range_analysis.h"
9
#include "sdfg/codegen/instrumentation/arg_capture_plan.h"
10
#include "sdfg/codegen/instrumentation/instrumentation_plan.h"
11
#include "sdfg/codegen/utils.h"
12
#include "sdfg/structured_sdfg.h"
13
#include "sdfg/types/type.h"
14

15
namespace sdfg {
16
namespace codegen {
17

18
/**
19
 * @brief Base class for code generators
20
 *
21
 * This class provides the basic structure for code generators.
22
 * It contains the streams for the includes, classes, globals, library functions and main code.
23
 */
24
class CodeGenerator {
25
protected:
26
    /// @brief Reference to the schedule
27
    StructuredSDFG& sdfg_;
28

29
    /// @brief Analysis manager for the SDFG
30
    analysis::AnalysisManager& analysis_manager_;
31

32
    /// @brief Instrumentation strategy
33
    InstrumentationPlan& instrumentation_plan_;
34
    ArgCapturePlan& arg_capture_plan_;
35

36
    /// @brief Stream for includes
37
    PrettyPrinter includes_stream_;
38

39
    /// @brief Stream for classes
40
    PrettyPrinter classes_stream_;
41

42
    /// @brief Stream for global variables and functions
43
    PrettyPrinter globals_stream_;
44

45
    /// @brief Stream for library functions
46
    std::shared_ptr<CodeSnippetFactory> library_snippet_factory_;
47

48
    /// @brief Main stream
49
    PrettyPrinter main_stream_;
50

51
    /// @brief Prefix to use for external functions
52
    std::string externals_prefix_;
53

54
public:
55
    CodeGenerator(
56
        StructuredSDFG& sdfg,
57
        analysis::AnalysisManager& analysis_manager,
58
        InstrumentationPlan& instrumentation_plan,
59
        ArgCapturePlan& arg_capture_plan,
60
        std::shared_ptr<CodeSnippetFactory> library_snippet_factory = std::make_shared<CodeSnippetFactory>(),
61
        const std::string& externals_prefix = ""
62
    )
63
        : sdfg_(sdfg), analysis_manager_(analysis_manager), instrumentation_plan_(instrumentation_plan),
23✔
64
          arg_capture_plan_(arg_capture_plan), library_snippet_factory_(std::move(library_snippet_factory)),
23✔
65
          externals_prefix_(externals_prefix) {};
23✔
66

67

68
    virtual ~CodeGenerator() = default;
23✔
69

NEW
70
    [[nodiscard]] const StructuredSDFG& sdfg() const { return this->sdfg_; };
×
71

72
    /**
73
     * @brief Generate the code
74
     *
75
     * @return true if the code was generated successfully
76
     */
77
    virtual bool generate() = 0;
78

79
    /// @brief Generate a function definition for the SDFG
80
    virtual std::string function_definition() = 0;
81

82
    /// @brief write the contents of the main header into out
83
    virtual bool emit_header(PrettyPrinter& out) = 0;
84

85
    /// @brief write the contents of the main source file into out. Can also generate additional source files (snippets)
86
    /// that also depend on the header
87
    virtual bool emit_main_source(std::ostream& out, const std::filesystem::path& header_path) = 0;
88

89
    /// @brief Generate the SDFG's code into source files
90
    virtual bool as_source(const std::filesystem::path& header_path, const std::filesystem::path& source_path) = 0;
91

92
    /// @brief Generate only the function source code and append it to the source file. @ref as_source generates this
93
    /// into `source_path` after includes, globals and structs
94
    virtual void append_function_source(std::ostream& ofs_source) = 0;
95

96
    /// @brief Get the includes
97
    const PrettyPrinter& includes() const { return this->includes_stream_; };
×
98

99
    /// @brief Get the classes
100
    const PrettyPrinter& classes() const { return this->classes_stream_; };
7✔
101

102
    /// @brief Get the globals
103
    const PrettyPrinter& globals() const { return this->globals_stream_; };
4✔
104

105
    /// @brief all created library snippets
106
    const std::unordered_map<std::string, CodeSnippet>& library_snippets() const {
×
107
        return this->library_snippet_factory_->snippets();
×
108
    };
×
109

110
    /// @brief Get the main stream
111
    const PrettyPrinter& main() const { return this->main_stream_; };
8✔
112
};
113

114
} // namespace codegen
115
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc