Let a program choose the stack or the heap for a tensor
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with promoteOwnedBuffers in src/dialect/VxLowering.cpp and read docs/language_rules_for_a_parallel_compiler.md for the function signature contract. Review the stack promotion rules and the linked context in #3542 to understand the current size limit and escape checks. The issue is done when the language and compiler support a defined way to choose stack or heap storage, including the listed size, return, call, and task cases.
Written by the indexing model from the issue text.
Description
Vx has no syntax to choose where a tensor's buffer goes. The compiler chooses:
- A local tensor starts on the heap.
promoteOwnedBuffersinsrc/dialect/VxLowering.cppmoves it to the stack when its shape is fixed, it is at most 4096 bytes, and no call, return or branch takes it. - After #3542, the caller of a function that returns a tensor uses the same 4096-byte limit for the result.
So a program cannot ask for the stack for a larger buffer. An example is a 64 KB scratch tile in a hot loop, where a malloc in each iteration costs too much. A program also cannot ask for the heap for a small buffer. Rust gives this choice through the type ([f32; N] or Box/Vec). Vx has one Tensor type for both.
To decide:
- The syntax, for example an annotation on the
let. - What happens when a buffer is too large for the stack. Each task has its own stack, and the compiler does not know its size.
- Whether a function can ask for the stack for its result. The caller makes that buffer, so the choice must be in the signature ("A signature is the whole contract" in
docs/language_rules_for_a_parallel_compiler.md). - Whether a stack tensor can leave its function: a return, a call that takes it by value, or a task that takes it. Stack promotion refuses all of these now.
Found while reviewing #3542, which fixes #3496.
- Dominant language
- Rust
- Stars
- 35
- Forks
- 5
- Avg merge
- 12h 26m
- Merged PRs (30d)
- 799
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
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 vx-lang/Vx
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug testing
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
`pub struct` gives "Expected 'fn' after 'pub'": the error should say that a struct needs no `pub`Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
bug devex
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
longbridge/gpui-kit#4031 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
neuralmagic/crucible#465 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
compiler P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
HerringtonDarkholme/hd-lang#2162 ·
Maintainers usually reply within 1 day
-
embedded SQL: pin correlated-guard behaviour when a closed variable is reassigned inside a branchOpenpriority: low
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
jonathanong/no-mistakes#3627 ·
Maintainers usually reply within 1 day