Work-depth drops the add of a loop-nest accumulation; MatMul counts it
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Read work_depth.py, especially scope_work_depth and its MapEntry and NestedSDFG branches, alongside the existing WCR handling in the tasklet branch. Check the reported work formulas against the proposed accumulation count of volume / subset.num_elements(). Done means loop and MatMul forms count the accumulation adds consistently without double-counting tasklet WCRs.
Written by the indexing model from the issue text.
Description
Summary
A multiply-add written as a loop is cheaper, in the work formula, than the same multiply-add written as a MatMul. The missing piece is the add of the accumulation.
How it was found
On DaCe 8a4d824, after canonicalization, three ways of writing the same products:
| Form | Work formula | Ops per multiply-add |
|---|---|---|
upd += kDivM * I * star |
2*NB*NBF*NQ*(NBF*ND*NQ + 1) |
2, and the step has two multiplies and one add |
tmp += I * star, then upd += kDivM * tmp |
NB*NBF*NQ*(NBF*ND + ND*NQ + 2) |
1 |
the same products as MatMul nodes |
2*M*N*K per product |
2, which is what count_work_matmul documents |
count_work_matmul is explicit: the 2 is one multiply and one add. The loop forms drop the add.
Work-depth adds a write-conflict resolution (the lambda a, b: a + b DaCe uses for +=) to work in one place only, the tasklet branch of scope_work_depth:
elif isinstance(node, nd.Tasklet):
t_work, t_depth = analyze_tasklet(node, state)
for e in state.out_edges(node):
if e.data.wcr is not None:
t_work += count_arithmetic_ops_code(e.data.wcr)
A += inside a map is usually a WCR on the edge that leaves the map exit, not on the tasklet. That edge is never visited here. The depth walk does see it, and uses volume / subset.num_elements() as the number of contributions, then deliberately does not charge that into a MapExit. The same work_depth.py is unchanged on extended at 6106f3257.
The formulas above were measured. The exact edge on those SDFGs was not opened again, so this is the counting site that matches the missing add.
Proposed fix
When a map's interior has been counted, add the exit WCRs. One application of lambda a, b: a + b is one operation, and volume / num_elements is how many times it runs. The depth walk already uses that ratio.
if isinstance(node, nd.MapEntry):
exit_node = state.exit_node(node)
for edge in state.out_edges(exit_node):
if edge.data.wcr is None or not edge.data.volume:
continue
locations = pystr_to_symbolic(edge.data.subset.num_elements())
if locations == 0:
continue
times = pystr_to_symbolic(edge.data.volume) / locations
s_work += count_arithmetic_ops_code(edge.data.wcr) * times
Put this next to the recursive call that produces s_work, before work += s_work. A WCR that already sits on the tasklet is still counted in the tasklet branch, and this loop does not see that edge, so the add is not counted twice.
A WCR on an edge leaving a nested SDFG has the same hole. The same three lines, on state.out_edges(node) for a NestedSDFG, cover it.
- Dominant language
- Python
- Stars
- 602
- Forks
- 171
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 43
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spcl/dace
-
Difficulty 3/5 Half a day Newbie friendliness 55/100
Maintainers usually reply within 2 days
-
Operational intensity raises TypeError on any library nodePossibly taken @abhinav-phi claimed this 4 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 2 days
-
ScalarToSymbolPromotion: replace the `0`-assignment fallback with guard-aware read/write analysisOpen
Difficulty 5/5 Over a week Newbie friendliness 42/100
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 2 days
-
Difficulty 4/5 1-2 days Newbie friendliness 48/100
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
software-mansion-labs/Diplomat#20 ·
Maintainers usually reply within 1 day
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client areaPossibly taken @lijy91 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
libnativeapi/nativeapi#53 · 1 reaction ·
Maintainers usually reply within 1 day
-
View Counts discarded due to field name mismatchPossibly taken @rsiva0400 claimed this today. Opensite-bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Model version publishes the new UK firm entity as a personPossibly taken @vahid-ahmadi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PolicyEngine/policyengine.py#764 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
spcl/HPCAgent-Bench#264 ·
Maintainers usually reply within 1 day