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

daisytuner / sdfglib / 15710378262

17 Jun 2025 02:40PM UTC coverage: 63.835% (-0.7%) from 64.576%
15710378262

Pull #86

github

web-flow
Merge 33788b6e3 into 37980e90f
Pull Request #86: Add optimizer functionality

37 of 215 new or added lines in 9 files covered. (17.21%)

12 existing lines in 5 files now uncovered.

8063 of 12631 relevant lines covered (63.84%)

115.87 hits per line

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

0.0
/include/sdfg/optimizations/optimizer.h
1
#pragma once
2

3
#include <sdfg/analysis/analysis.h>
4
#include <sdfg/structured_sdfg.h>
5
#include <sdfg/transformations/transformation.h>
6

7
#include <concepts>
8
#include <nlohmann/json.hpp>
9

10
namespace sdfg {
11
namespace optimizations {
12

13
template <typename T>
14
concept transformation_concept = std::derived_from<T, sdfg::transformations::Transformation>;
15

16
class Optimizer {
17
   private:
18
    nlohmann::json history_;
19

20
   public:
21
    Optimizer();
22

23
    template <typename T, typename... Args>
24
        requires transformation_concept<T>
25
    void apply(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager,
26
               Args&&... args) {
27
        T transformation(std::forward<Args>(args)...);
28

29
        if (!transformation.can_be_applied(builder, analysis_manager)) {
30
            throw transformations::InvalidTransformationException(
31
                "Transformation " + transformation.name() + " cannot be applied.");
32
        }
33

34
        nlohmann::json desc;
35
        transformation.to_json(desc);
36
        std::cout << "Serializing transformation: " << transformation.name() << std::endl;
37
        std::cout << desc.dump(4) << std::endl;
38
        history_.push_back(desc);
39

40
        std::cout << "Transformation " << transformation.name() << " serialized to JSON"
41
                  << std::endl;
42

43
        transformation.apply(builder, analysis_manager);
44
        std::cout << "Applied" << transformation.name() << std::endl;
45
    };
46

47
    void replay(builder::StructuredSDFGBuilder& builder,
48
                analysis::AnalysisManager& analysis_manager, const nlohmann::json& desc);
49

50
    template <typename T>
51
        requires transformation_concept<T>
NEW
52
    void apply(builder::StructuredSDFGBuilder& builder, analysis::AnalysisManager& analysis_manager,
×
53
               const nlohmann::json& desc) {
NEW
54
        auto transformation = std::make_unique<T>(T::from_json(builder, desc));
×
NEW
55
        if (!transformation->can_be_applied(builder, analysis_manager)) {
×
NEW
56
            throw transformations::InvalidTransformationException(
×
NEW
57
                "Transformation " + transformation->name() + " cannot be applied.");
×
58
        }
NEW
59
        transformation->apply(builder, analysis_manager);
×
NEW
60
    };
×
61

62
    void save(std::filesystem::path path) const;
63
};
64

65
}  // namespace optimizations
66
}  // 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