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

daisytuner / docc / 24408034210

14 Apr 2026 03:32PM UTC coverage: 64.413% (-0.06%) from 64.469%
24408034210

Pull #679

github

web-flow
Merge 7f86463c3 into 505b640ce
Pull Request #679: Single GPU BLAS Handle Instantiation

9 of 92 new or added lines in 15 files covered. (9.78%)

14 existing lines in 7 files now uncovered.

30559 of 47442 relevant lines covered (64.41%)

583.53 hits per line

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

72.31
/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

37
bool CStyleBaseCodeGenerator::as_source(const std::filesystem::path& header_path, const std::filesystem::path& source_path) {
1✔
38
    std::ofstream ofs_header(header_path, std::ofstream::out | std::ofstream::trunc);
1✔
39
    if (!ofs_header.is_open()) {
1✔
40
        return false;
×
41
    }
×
42

43
    std::ofstream ofs_source(source_path, std::ofstream::out | std::ofstream::trunc);
1✔
44
    if (!ofs_source.is_open()) {
1✔
45
        return false;
×
46
    }
×
47

48
    ofs_header << "#pragma once" << std::endl;
1✔
49
    ofs_header << this->includes_stream_.str() << std::endl;
1✔
50
    ofs_header << this->classes_stream_.str() << std::endl;
1✔
51
    ofs_header.close();
1✔
52

53
    ofs_source << "#include \"" << header_path.filename().string() << "\"" << std::endl;
1✔
54
    for (auto& snippet : library_snippet_factory_->globals_snippets()) {
1✔
NEW
55
        ofs_source << snippet << std::endl;
×
NEW
56
    }
×
57
    ofs_source << this->globals_stream_.str() << std::endl;
1✔
58

59
    append_function_source(ofs_source);
1✔
60

61
    ofs_source.close();
1✔
62

63
    return true;
1✔
64
}
1✔
65

66
void CStyleBaseCodeGenerator::append_function_source(std::ofstream& ofs_source) {
1✔
67
    std::unique_ptr<std::vector<CaptureVarPlan>> capturePlan;
1✔
68
    if (!arg_capture_plan_.is_empty()) {
1✔
69
        this->emit_capture_context_init(ofs_source);
×
70
    }
×
71

72
    ofs_source << this->function_definition() << std::endl;
1✔
73
    ofs_source << "{" << std::endl;
1✔
74

75
    auto init_once = library_snippet_factory_->find(CODE_SNIPPET_INIT_ONCE);
1✔
76
    if (init_once != library_snippet_factory_->snippets().end()) {
1✔
77
        ofs_source << init_once->second.stream().str() << std::endl;
×
78
    }
×
79

80
    for (auto& snippet : library_snippet_factory_->setup_snippets()) {
1✔
NEW
81
        ofs_source << snippet << std::endl;
×
NEW
82
    }
×
83

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

86
    for (auto& snippet : library_snippet_factory_->teardown_snippets()) {
1✔
NEW
87
        ofs_source << snippet << std::endl;
×
NEW
88
    }
×
89

90
    auto deinit_once = library_snippet_factory_->find(CODE_SNIPPET_DEINIT_ONCE);
1✔
91
    if (deinit_once != library_snippet_factory_->snippets().end()) {
1✔
92
        ofs_source << deinit_once->second.stream().str() << std::endl;
×
93
    }
×
94

95
    ofs_source << "}" << std::endl;
1✔
96
}
1✔
97

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