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

daisytuner / docc / 24836919684

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

Pull #690

github

web-flow
Merge 7af6c3c2d into 3762dada8
Pull Request #690: Modular Compile process

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

56.32
/sdfg/src/codegen/code_generators/c_style_base_code_generator.cpp
1

2
#include "sdfg/codegen/code_generators/c_style_base_code_generator.h"
3

4
#include "sdfg/helpers/helpers.h"
5

6
namespace sdfg::codegen {
7

8
CStyleBaseCodeGenerator::CStyleBaseCodeGenerator(
9
    StructuredSDFG& sdfg,
10
    analysis::AnalysisManager& analysis_manager,
11
    InstrumentationPlan& instrumentation_plan,
12
    ArgCapturePlan& arg_capture_plan,
13
    std::shared_ptr<CodeSnippetFactory> library_snippet_factory,
14
    const std::string& externals_prefix
15
)
16
    : CodeGenerator(
19✔
17
          sdfg,
19✔
18
          analysis_manager,
19✔
19
          instrumentation_plan,
19✔
20
          arg_capture_plan,
19✔
21
          std::move(library_snippet_factory),
19✔
22
          externals_prefix
19✔
23
      ) {
19✔
24
    if (sdfg.type() != FunctionType_CPU) {
19✔
25
        throw std::runtime_error("CStyleBaseCodeGenerator can only be used for CPU SDFGs");
×
26
    }
×
27
};
19✔
28

29
bool CStyleBaseCodeGenerator::generate() {
17✔
30
    this->dispatch_includes();
17✔
31
    this->dispatch_structures();
17✔
32
    this->dispatch_globals();
17✔
33
    this->dispatch_schedule();
17✔
34
    return true;
17✔
35
}
17✔
36

NEW
37
bool CStyleBaseCodeGenerator::emit_header(PrettyPrinter& out) {
×
NEW
38
    out << "#pragma once" << std::endl;
×
39

NEW
40
    dispatch_header(out);
×
NEW
41
    return true;
×
NEW
42
}
×
43

NEW
44
void CStyleBaseCodeGenerator::dispatch_header(PrettyPrinter& out) {
×
NEW
45
    dispatch_header_includes(out);
×
NEW
46
    dispatch_header_structures(out);
×
NEW
47
}
×
48

49
void CStyleBaseCodeGenerator::dispatch_includes() { dispatch_header_includes(this->includes_stream_); }
17✔
50

51
void CStyleBaseCodeGenerator::dispatch_structures() { dispatch_header_structures(this->classes_stream_); }
17✔
52

NEW
53
bool CStyleBaseCodeGenerator::emit_main_source(std::ostream& out, const std::filesystem::path& header_path) {
×
NEW
54
    out << "#include \"" << header_path.filename().string() << "\"" << std::endl;
×
NEW
55
    dispatch_globals();
×
NEW
56
    dispatch_schedule();
×
57

NEW
58
    for (auto& snippet : library_snippet_factory_->globals_snippets()) {
×
NEW
59
        out << snippet << std::endl;
×
NEW
60
    }
×
61

NEW
62
    out << this->globals_stream_.str() << std::endl;
×
63

NEW
64
    append_function_source(out);
×
NEW
65
    return true;
×
NEW
66
}
×
67

68
bool CStyleBaseCodeGenerator::as_source(const std::filesystem::path& header_path, const std::filesystem::path& source_path) {
1✔
69
    std::ofstream ofs_header(header_path, std::ofstream::out | std::ofstream::trunc);
1✔
70
    if (!ofs_header.is_open()) {
1✔
71
        return false;
×
72
    }
×
73

74
    std::ofstream ofs_source(source_path, std::ofstream::out | std::ofstream::trunc);
1✔
75
    if (!ofs_source.is_open()) {
1✔
76
        return false;
×
77
    }
×
78

79
    ofs_header << "#pragma once" << std::endl;
1✔
80
    ofs_header << this->includes_stream_.str() << std::endl;
1✔
81
    ofs_header << this->classes_stream_.str() << std::endl;
1✔
82
    ofs_header.close();
1✔
83

84
    ofs_source << "#include \"" << header_path.filename().string() << "\"" << std::endl;
1✔
85
    for (auto& snippet : library_snippet_factory_->globals_snippets()) {
1✔
86
        ofs_source << snippet << std::endl;
×
87
    }
×
88
    ofs_source << this->globals_stream_.str() << std::endl;
1✔
89

90
    append_function_source(ofs_source);
1✔
91

92
    ofs_source.close();
1✔
93

94
    return true;
1✔
95
}
1✔
96

97
void CStyleBaseCodeGenerator::append_function_source(std::ostream& ofs_source) {
1✔
98
    std::unique_ptr<std::vector<CaptureVarPlan>> capturePlan;
1✔
99
    if (!arg_capture_plan_.is_empty()) {
1✔
100
        this->emit_capture_context_init(ofs_source);
×
101
    }
×
102

103
    ofs_source << this->function_definition() << std::endl;
1✔
104
    ofs_source << "{" << std::endl;
1✔
105

106
    auto init_once = library_snippet_factory_->find(CODE_SNIPPET_INIT_ONCE);
1✔
107
    if (init_once != library_snippet_factory_->snippets().end()) {
1✔
108
        ofs_source << init_once->second.stream().str() << std::endl;
×
109
    }
×
110

111
    for (auto& snippet : library_snippet_factory_->setup_snippets()) {
1✔
112
        ofs_source << snippet << std::endl;
×
113
    }
×
114

115
    ofs_source << this->main_stream_.str() << std::endl;
1✔
116

117
    for (auto& snippet : library_snippet_factory_->teardown_snippets()) {
1✔
118
        ofs_source << snippet << std::endl;
×
119
    }
×
120

121
    auto deinit_once = library_snippet_factory_->find(CODE_SNIPPET_DEINIT_ONCE);
1✔
122
    if (deinit_once != library_snippet_factory_->snippets().end()) {
1✔
123
        ofs_source << deinit_once->second.stream().str() << std::endl;
×
124
    }
×
125

126
    ofs_source << "}" << std::endl;
1✔
127
}
1✔
128

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