Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions docs/spec/analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,31 +166,26 @@ target hardware facts. What an occurrence moves is the memory family's answer

```python
class ComputeCostMetadata(IRMetadata):
"""One Call's logical work, as the authored program states it.

Attributes:
topologies: attribute; The declared levels, in the order per_unit states them.
flops: attribute; Flop counts per compute DType name.
service: attribute; Result counts per service kind.
"""
"""Typed work in logical, expanded, and topology-unit domains."""

topologies: tuple[str, ...] = ()
flops: Breakdown[int] = Breakdown()
service: Breakdown[int] = Breakdown()
other_ops: Breakdown[int] = Breakdown()
```


| Field | How it is computed | Reads the target |
|---|---|---|
| `topologies` | The effective Module topology levels, coarsest first. | No |
| `flops` | For a primitive Call, run its registered cost evaluator over operand and result Types as written; the total then multiplies by the enclosing recomputation factor and the number of positions in its execution scope, and each level's share is the same evaluator over Types projected through authored `Split`s at or coarser than that level. For a Function Call, take the callee's summed record and multiply by the call site's factor. | No; projection reads resolved Mesh and effective Module topology extents. |
| `service` | The same evaluator's service counts -- the results it asks a machine for that are not floating point -- totalled and shared the same way. | No; projection reads resolved Mesh and effective Module topology extents. |
| `other_ops` | The evaluator's non-floating-point operation counts (`integer`, `predicate`, `select`, `special`), totalled and shared the same way. These keys map directly to target one-unit operation-throughput keys; target-side service naming is unchanged. | No; projection reads resolved Mesh and effective Module topology extents. |

Requesting this family adds one summary line, prefixed by `# `: the Function's own
record, stated exactly as a Call's is. The whole program's work is not a second
record.

```text
compute-cost flops=<dtype>:<int>@<int>[,...] service=<kind>:<int>@<int>[,...]
compute-cost flops=<dtype>:<int>@logical,<int>@total,<int>@<level>[,...][;<dtype>:...] other-ops=<kind>:<int>@logical,<int>@total,<int>@<level>[,...][;<kind>:...]
```

Every measured Call receives this annotation. Each key pairs the whole quantity
Expand All @@ -200,8 +195,10 @@ Each reported Call's JSON projection is under its `compute-cost` key:

```text
{"topologies": [<level>, ...],
"flops": {<dtype>: {"total": <int>, "per_unit": [<int>, ...]}},
"service": {<kind>: {"total": <int>, "per_unit": [<int>, ...]}}}
"flops": {<dtype>: {"logical": <int>, "total": <int>,
"per_unit": [<int>, ...]}},
"other_ops": {<kind>: {"logical": <int>, "total": <int>,
"per_unit": [<int>, ...]}}}
```

- constraints:
Expand Down Expand Up @@ -234,10 +231,12 @@ class Spread[V]:
and a reader who knew to ask.

Attributes:
total: attribute; What the whole program asks for.
per_unit: attribute; What one unit of each level holds, in the record's topologies order.
logical: attribute; What the authored operation asks for before replication.
total: attribute; What the whole execution asks for.
per_unit: attribute; What one unit of each level holds, in topology order.
"""

logical: V
total: V
per_unit: tuple[V, ...] = ()

Expand Down Expand Up @@ -541,7 +540,7 @@ Requesting memory adds the Function's own movement, one footprint line, and one
line per advisory:

```text
traffic traffic=<level>:r<int>/w<int>@r<int>/w<int>[,...]
traffic traffic=<memory-level>:r<int>/w<int>@total,r<int>/w<int>@<topology>[,...][;<memory-level>:...]
peak-footprint=<level>:<int>[,<level>:<int>...]
advisory="<text>"
```
Expand All @@ -560,7 +559,7 @@ is emitted only when asked for ([cli Analyze](./cli.md#analyze)) and is absent
from a Function, which has no split:

```text
traffic traffic=<level>:r<int>/w<int>@r<int>/w<int>[,...][ operands=<position>:r<int>/w<int>[,...]]
traffic traffic=<memory-level>:r<int>/w<int>@total,r<int>/w<int>@<topology>[,...][;<memory-level>:...] [operands=<position>:r<int>/w<int>[;<position>:...]]
```

Its JSON projection is under the reported value's `traffic` key, with `whole`,
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/optimize.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
{
"name": "stdout",
"output_type": "stream",
"text": "# traffic traffic=gmem:r71680/w43456@cta:r71680/w43456,thread:r336/w224,rmem:r603496/w488344@cta:r603496/w488344,thread:r2604/w2084\n# roofline ideal-ns=24 bound-by=memory\n"
"text": "# traffic traffic=gmem:r71680/w43456@total,r71680/w43456@cta,r336/w224@thread;rmem:r603496/w488344@total,r603496/w488344@cta,r2604/w2084@thread\n# roofline ideal-ns=24 bound-by=memory\n"
}
],
"source": [
Expand Down Expand Up @@ -94,7 +94,7 @@
{
"name": "stdout",
"output_type": "stream",
"text": "# traffic traffic=gmem:r43008/w14784@cta:r43008/w14784,thread:r224/w112,rmem:r574824/w459672@cta:r574824/w459672,thread:r2492/w1972\n# roofline ideal-ns=13 bound-by=memory\n"
"text": "# traffic traffic=gmem:r43008/w14784@total,r43008/w14784@cta,r224/w112@thread;rmem:r574824/w459672@total,r574824/w459672@cta,r2492/w1972@thread\n# roofline ideal-ns=13 bound-by=memory\n"
}
],
"source": [
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/optimize.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ grep -E '^# (traffic|roofline) ' Naive.txt
```

```text
# traffic traffic=gmem:r71680/w43456@cta:r71680/w43456,thread:r336/w224,rmem:r603496/w488344@cta:r603496/w488344,thread:r2604/w2084
# traffic traffic=gmem:r71680/w43456@total,r71680/w43456@cta,r336/w224@thread;rmem:r603496/w488344@total,r603496/w488344@cta,r2604/w2084@thread
# roofline ideal-ns=24 bound-by=memory
```

Expand Down Expand Up @@ -132,7 +132,7 @@ grep -E '^# (traffic|roofline) ' Fused.txt
```

```text
# traffic traffic=gmem:r43008/w14784@cta:r43008/w14784,thread:r224/w112,rmem:r574824/w459672@cta:r574824/w459672,thread:r2492/w1972
# traffic traffic=gmem:r43008/w14784@total,r43008/w14784@cta,r224/w112@thread;rmem:r574824/w459672@total,r574824/w459672@cta,r2492/w1972@thread
# roofline ideal-ns=13 bound-by=memory
```

Expand Down
Loading
Loading