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

daisytuner / sdfglib / 19496232534

19 Nov 2025 09:22AM UTC coverage: 62.105% (-0.08%) from 62.184%
19496232534

push

github

web-flow
Merge pull request #354 from daisytuner/tenstorrent-transform

Tenstorrent transform

52 of 95 new or added lines in 15 files covered. (54.74%)

28 existing lines in 8 files now uncovered.

11141 of 17939 relevant lines covered (62.1%)

112.04 hits per line

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

32.08
/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(
16✔
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(
16✔
17
          sdfg,
16✔
18
          analysis_manager,
16✔
19
          instrumentation_plan,
16✔
20
          arg_capture_plan,
16✔
21
          std::move(library_snippet_factory),
16✔
22
          externals_prefix
16✔
23
      ) {
16✔
24
    if (sdfg.type() != FunctionType_CPU) {
16✔
25
        throw std::runtime_error("CStyleBaseCodeGenerator can only be used for CPU SDFGs");
×
26
    }
27
};
16✔
28

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

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

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

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

53
    ofs_source << "#include \"" << header_path.filename().string() << "\"" << std::endl;
×
54
    ofs_source << this->globals_stream_.str() << std::endl;
×
55

56
    append_function_source(ofs_source);
×
57

58
    ofs_source.close();
×
59

60
    return true;
×
61
}
×
62

63
void CStyleBaseCodeGenerator::append_function_source(std::ofstream& ofs_source) {
×
64
    std::unique_ptr<std::vector<CaptureVarPlan>> capturePlan;
×
65
    if (!arg_capture_plan_.is_empty()) {
×
66
        this->emit_capture_context_init(ofs_source);
×
67
    }
×
68

69
    ofs_source << this->function_definition() << std::endl;
×
70
    ofs_source << "{" << std::endl;
×
71

NEW
72
    auto init_once = library_snippet_factory_->find(CODE_SNIPPET_INIT_ONCE);
×
NEW
73
    if (init_once != library_snippet_factory_->snippets().end()) {
×
74
        ofs_source << init_once->second.stream().str() << std::endl;
×
75
    }
×
76

77
    ofs_source << this->main_stream_.str() << std::endl;
×
78

NEW
79
    auto deinit_once = library_snippet_factory_->find(CODE_SNIPPET_DEINIT_ONCE);
×
NEW
80
    if (deinit_once != library_snippet_factory_->snippets().end()) {
×
81
        ofs_source << deinit_once->second.stream().str() << std::endl;
×
82
    }
×
83

84
    ofs_source << "}" << std::endl;
×
85
}
×
86

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