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

daisytuner / docc / 24080621107

07 Apr 2026 12:11PM UTC coverage: 64.746%. First build
24080621107

push

github

web-flow
add code gen statistics (#633)

1 of 52 new or added lines in 3 files covered. (1.92%)

28704 of 44333 relevant lines covered (64.75%)

621.01 hits per line

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

73.81
/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 _is_debug_dump() -> bool:
4✔
21
    return bool(os.environ.get("DOCC_DEBUG"))
4✔
22

23

24
class DoccProgram(ABC):
4✔
25

26
    def __init__(
4✔
27
        self,
28
        name: str,
29
        target: str = "none",
30
        category: str = "server",
31
        instrumentation_mode: Optional[str] = None,
32
        capture_args: Optional[bool] = None,
33
        remote_tuning: bool = False,
34
    ):
35
        self.name = name
4✔
36
        self.target = target
4✔
37
        self.category = category
4✔
38
        self.remote_tuning = remote_tuning
4✔
39
        self.last_sdfg: Optional[StructuredSDFG] = None
4✔
40
        self.cache: dict = {}
4✔
41
        self.debug_dump: bool = _is_debug_dump()
4✔
42

43
        # Check environment variable DOCC_CI
44
        docc_ci = os.environ.get("DOCC_CI", "")
4✔
45
        if docc_ci:
4✔
46
            if docc_ci == "regions":
×
47
                if instrumentation_mode is None:
×
48
                    instrumentation_mode = "ols"
×
49
            elif docc_ci == "arg-capture":
×
50
                if capture_args is None:
×
51
                    capture_args = True
×
52
            else:
53
                # Full mode (or unknown value treated as full)
54
                if instrumentation_mode is None:
×
55
                    instrumentation_mode = "ols"
×
56
                if capture_args is None:
×
57
                    capture_args = True
×
58

59
        self.instrumentation_mode = instrumentation_mode
4✔
60
        self.capture_args = capture_args
4✔
61

62
    @abstractmethod
4✔
63
    def __call__(self, *args: Any) -> Any:
4✔
64
        pass
×
65

66
    @abstractmethod
4✔
67
    def compile(self, *args: Any, output_folder: Optional[str] = None) -> CompiledSDFG:
4✔
68
        pass
×
69

70
    def sdfg_pipe(
4✔
71
        self,
72
        sdfg: StructuredSDFG,
73
        output_folder: Optional[str],
74
        instrumentation_mode: str,
75
        capture_args: bool,
76
    ) -> str:
77

78
        if self.debug_dump:
4✔
79
            sdfg.dump(output_folder, "py0.parsed", dump_dot=True)
×
80

81
        # Enable statistics if envvar is set
82
        if _statistics_enabled_by_env():
4✔
83
            _enable_statistics()
×
84

85
        sdfg.validate()
4✔
86

87
        # Tensor targets keep tensor nodes
88
        custom_expand_fn = get_target_expand_fn(self.target)
4✔
89
        if custom_expand_fn is not None:
4✔
90
            custom_expand_fn(sdfg, self.category, {})
4✔
91
        else:
92
            sdfg.expand()
4✔
93
        if self.debug_dump:
4✔
94
            sdfg.dump(output_folder, "py1.expanded", dump_dot=True)
×
95

96
        # Simplify pipelines
97
        sdfg.simplify()
4✔
98
        if self.debug_dump:
4✔
99
            sdfg.dump(output_folder, "py2.opt", dump_dot=True)
×
100

101
        # Normalization for scheduling
102
        if self.target != "none":
4✔
103
            sdfg.normalize()
4✔
104

105
        if self.debug_dump or instrumentation_mode or capture_args:
4✔
106
            sdfg.dump(
4✔
107
                output_folder,
108
                "py3.norm",
109
                dump_dot=self.debug_dump,
110
                dump_json=True,
111
                record_for_instrumentation=True,
112
            )
113

114
        # Schedule if target is specified
115

116
        if self.target != "none":
4✔
117
            # Check for custom registered target first
118
            custom_schedule_fn = get_target_schedule_fn(self.target)
4✔
119
            if custom_schedule_fn is not None:
4✔
120
                custom_schedule_fn(
4✔
121
                    sdfg, self.category, {"remote_tuning": self.remote_tuning}
122
                )
123
            else:
124
                sdfg.schedule(self.target, self.category, self.remote_tuning)
4✔
125

126
            if self.debug_dump:
4✔
127
                sdfg.dump(output_folder, "py4.post_sched", dump_dot=True)
×
128

129
        self.last_sdfg = sdfg
4✔
130

131
        custom_compile_fn = get_target_compile_fn(self.target)
4✔
132
        if custom_compile_fn is not None:
4✔
133
            lib_path = custom_compile_fn(
4✔
134
                sdfg, output_folder, instrumentation_mode, capture_args, {}
135
            )
136
        else:
137
            lib_path = sdfg._compile(
4✔
138
                output_folder=output_folder,
139
                target=self.target,
140
                instrumentation_mode=instrumentation_mode,
141
                capture_args=capture_args,
142
            )
143

144
        # Dump statistics after compile
145
        if _statistics_enabled_by_env():
4✔
NEW
146
            print(_statistics_summary(), file=sys.stderr)
×
147

148
        return lib_path
4✔
149

150
    @abstractmethod
4✔
151
    def to_sdfg(self, *args: Any) -> StructuredSDFG:
4✔
152
        pass
×
153

154
    @abstractmethod
4✔
155
    def _convert_inputs(self, args: tuple) -> tuple:
4✔
156
        pass
×
157

158
    @abstractmethod
4✔
159
    def _convert_outputs(self, result: Any, original_args: tuple) -> Any:
4✔
160
        pass
×
161

162
    def _get_cache_key(self, *args: Any) -> str:
4✔
163
        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