Improve both ease of programming and generated CUDA code readability with local scalar variables
- Dominant language
- Python
- Stars
- 7.4k
- Forks
- 742
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 104
Description
Allow user to assign to intermediate scalar variables and lower into C local variable, so that index computation can be simplified as is in user program. Redundant index computation may increase the burden of underlying compiler optimizing them away, or even result in redundant integer operations at runtime.
Expected example:
```python
with T.Kernel(N // blk) as bx:
for i0 in T.Parallel(blk):
i = T.var(bx * blk + i0)
x[i] = ... y[i] ... z[i] ...
```
Yet multiple dimension indexing still cannot be simplified on user side; maybe also *should* not? Common Subexpression Elimination is still required.
Contributor guide
Research direction
Start with the issue's Python T.Kernel and T.var example, then trace how intermediate scalar assignments are lowered into generated C/CUDA code. Done means user-side index computation is represented by a local scalar variable, while multidimensional indexing and the need for Common Subexpression Elimination are explicitly accounted for.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100