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

daisytuner / docc / 24783200705

22 Apr 2026 02:12PM UTC coverage: 63.895%. First build
24783200705

Pull #690

github

web-flow
Merge 37a7ecd94 into 8dc5e5aa7
Pull Request #690: Modular Compile process

220 of 341 new or added lines in 12 files covered. (64.52%)

30670 of 48001 relevant lines covered (63.89%)

572.96 hits per line

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

71.0
/python/docc/compiler/docc_program.py
1
from abc import ABC, abstractmethod
4✔
2
import sys
4✔
3
from typing import Any, Optional
4✔
4
import os
4✔
5

6
from docc.sdfg import StructuredSDFG
4✔
7
from docc.sdfg._sdfg import (
4✔
8
    _enable_statistics,
9
    _statistics_enabled_by_env,
10
    _statistics_summary,
11
)
12
from docc.compiler.compiled_sdfg import CompiledSDFG
4✔
13
from docc.compiler.target_registry import (
4✔
14
    get_target_schedule_fn,
15
    get_target_compile_fn,
16
    get_target_expand_fn,
17
)
18

19

20
def _parse_docc_debug() -> dict[str, str]:
4✔
21
    debug_env = os.environ.get("DOCC_DEBUG", "")
4✔
22
    debug_dict = {}
4✔
23
    if debug_env:
4✔
NEW
24
        for entry in debug_env.split(";"):
×
NEW
25
            if not entry:
×
NEW
26
                continue
×
NEW
27
            parts = entry.split("=", 1)
×
NEW
28
            key = parts[0].strip()
×
NEW
29
            value = parts[1].strip() if len(parts) > 1 else ""
×
NEW
30
            debug_dict[key] = value
×
31
    return debug_dict
4✔
32

33

34
def _is_debug_dump(flags: dict[str, str]) -> bool:
4✔
35
    return "dump" in flags
4✔
36

37

38
def _is_debug_compile(flags: dict[str, str]) -> bool:
4✔
39
    return "build" in flags
4✔
40

41

42
class DoccProgram(ABC):
4✔
43

44
    def __init__(
4✔
45
        self,
46
        name: str,
47
        target: str = "none",
48
        category: str = "server",
49
        instrumentation_mode: Optional[str] = None,
50
        capture_args: Optional[bool] = None,
51
        remote_tuning: bool = False,
52
    ):
53
        self.name = name
4✔
54
        self.target = target
4✔
55
        self.category = category
4✔
56
        self.remote_tuning = remote_tuning
4✔
57
        self.last_sdfg: Optional[StructuredSDFG] = None
4✔
58
        self.cache: dict = {}
4✔
59
        debug_flags = _parse_docc_debug()
4✔
60
        self.debug_dump: bool = _is_debug_dump(debug_flags)
4✔
61
        self.debug_build: bool = _is_debug_compile(debug_flags)
4✔
62

63
        # Check environment variable DOCC_CI
64
        docc_ci = os.environ.get("DOCC_CI", "")
4✔
65
        if docc_ci:
4✔
66
            if docc_ci == "regions":
×
67
                if instrumentation_mode is None:
×
68
                    instrumentation_mode = "ols"
×
69
            elif docc_ci == "arg-capture":
×
70
                if capture_args is None:
×
71
                    capture_args = True
×
72
            else:
73
                # Full mode (or unknown value treated as full)
74
                if instrumentation_mode is None:
×
75
                    instrumentation_mode = "ols"
×
76
                if capture_args is None:
×
77
                    capture_args = True
×
78

79
        self.instrumentation_mode = instrumentation_mode
4✔
80
        self.capture_args = capture_args
4✔
81

82
    @abstractmethod
4✔
83
    def __call__(self, *args: Any) -> Any:
4✔
84
        pass
×
85

86
    @abstractmethod
4✔
87
    def compile(self, *args: Any, output_folder: Optional[str] = None) -> CompiledSDFG:
4✔
88
        pass
×
89

90
    def sdfg_pipe(
4✔
91
        self,
92
        sdfg: StructuredSDFG,
93
        output_folder: Optional[str],
94
        instrumentation_mode: str,
95
        capture_args: bool,
96
    ) -> str:
97

98
        if self.debug_dump:
4✔
99
            sdfg.dump(output_folder, "py0.parsed", dump_dot=True)
×
100

101
        # Enable statistics if envvar is set
102
        if _statistics_enabled_by_env():
4✔
103
            _enable_statistics()
×
104

105
        sdfg.validate()
4✔
106

107
        # Tensor targets keep tensor nodes
108
        custom_expand_fn = get_target_expand_fn(self.target)
4✔
109
        if custom_expand_fn is not None:
4✔
110
            custom_expand_fn(sdfg, self.category, {})
4✔
111
        else:
112
            sdfg.expand()
4✔
113
        if self.debug_dump:
4✔
114
            sdfg.dump(output_folder, "py1.expanded", dump_dot=True)
×
115

116
        # Simplify pipelines
117
        sdfg.simplify()
4✔
118
        if self.debug_dump:
4✔
119
            sdfg.dump(output_folder, "py2.opt", dump_dot=True)
×
120

121
        # Normalization for scheduling
122
        if self.target != "none":
4✔
123
            sdfg.normalize()
4✔
124

125
        if self.debug_dump or instrumentation_mode or capture_args:
4✔
126
            sdfg.dump(
4✔
127
                output_folder,
128
                "py3.norm",
129
                dump_dot=self.debug_dump,
130
                dump_json=True,
131
                record_for_instrumentation=True,
132
            )
133

134
        # Schedule if target is specified
135

136
        if self.target != "none":
4✔
137
            # Check for custom registered target first
138
            custom_schedule_fn = get_target_schedule_fn(self.target)
4✔
139
            if custom_schedule_fn is not None:
4✔
140
                custom_schedule_fn(
4✔
141
                    sdfg, self.category, {"remote_tuning": self.remote_tuning}
142
                )
143
            else:
144
                sdfg.schedule(self.target, self.category, self.remote_tuning)
4✔
145

146
            if self.debug_dump:
4✔
147
                sdfg.dump(output_folder, "py4.post_sched", dump_dot=True)
×
148

149
        self.last_sdfg = sdfg
4✔
150

151
        custom_compile_fn = get_target_compile_fn(self.target)
4✔
152
        if custom_compile_fn is not None:
4✔
153
            lib_path = custom_compile_fn(
4✔
154
                sdfg,
155
                output_folder,
156
                instrumentation_mode,
157
                capture_args,
158
                {"debug_build": self.debug_build},
159
            )
160
        else:
161
            lib_path = sdfg._compile(
4✔
162
                output_folder=output_folder,
163
                target=self.target,
164
                instrumentation_mode=instrumentation_mode,
165
                capture_args=capture_args,
166
                debug_build=self.debug_build,
167
            )
168

169
        # Dump statistics after compile
170
        if _statistics_enabled_by_env():
4✔
171
            print(_statistics_summary(), file=sys.stderr)
×
172

173
        return lib_path
4✔
174

175
    @abstractmethod
4✔
176
    def to_sdfg(self, *args: Any) -> StructuredSDFG:
4✔
177
        pass
×
178

179
    @abstractmethod
4✔
180
    def _convert_inputs(self, args: tuple) -> tuple:
4✔
181
        pass
×
182

183
    @abstractmethod
4✔
184
    def _convert_outputs(self, result: Any, original_args: tuple) -> Any:
4✔
185
        pass
×
186

187
    def _get_cache_key(self, *args: Any) -> str:
4✔
188
        return ""
×
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