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

daisytuner / docc / 23741135955

30 Mar 2026 10:54AM UTC coverage: 64.123% (-0.4%) from 64.511%
23741135955

push

github

web-flow
Merge pull request #503 from daisytuner/statistics

Added pass and pipeline statistics

28 of 300 new or added lines in 20 files covered. (9.33%)

1 existing line in 1 file now uncovered.

27213 of 42439 relevant lines covered (64.12%)

401.54 hits per line

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

74.12
/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✔
NEW
83
            _enable_statistics()
×
84

85
        sdfg.validate()
4✔
86

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

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

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

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

115
        # Schedule if target is specified
116

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

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

130
        self.last_sdfg = sdfg
4✔
131

132
        # Dump statistics before compile
133
        if _statistics_enabled_by_env():
4✔
NEW
134
            print(_statistics_summary(), file=sys.stderr)
×
135

136
        custom_compile_fn = get_target_compile_fn(self.target)
4✔
137
        if custom_compile_fn is not None:
4✔
138
            lib_path = custom_compile_fn(
4✔
139
                sdfg, output_folder, instrumentation_mode, capture_args, {}
140
            )
141
        else:
142
            lib_path = sdfg._compile(
4✔
143
                output_folder=output_folder,
144
                target=self.target,
145
                instrumentation_mode=instrumentation_mode,
146
                capture_args=capture_args,
147
            )
148

149
        return lib_path
4✔
150

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

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

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

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