Simplify interferes with dynamic map ranges
- Dominant language
- Python
- Stars
- 593
- Forks
- 163
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 60
Description
I use dynamic map ranges, to add a offset to a Memlet, which is only known at runtime.
However, I have to perform some operations on this value, before I use it.
For this I use a Tasklet, which is then connected to the Map entry, see picture below.

Before the SDFG is simplified it validates and works as expected.
After simplification it fails to compile.
I found out that simplify will transform the Tasklets into a symbol assignment on an interstate edge.
The problem is that the name used for the dynamic map range symbol, i.e. the connector name on the Map entry, is a mangle version of the data container that actually stores the value.
To make an example, assume that the value of the dynamic offset is stored inside the data container with name `dyn_offset_variable` and is connected, by a Memlet, to the Map entry and there has the connector name `__dyn_offset_symbol`.
However, when simplify removes the Tasklet, it will also remove the data container `dyn_offset_variable`.
Instead it will create a symbol with the name `dyn_offset_variable` and initialize it with the content (string used as code) of the Tasklet.
The actual problem is that it does not change `__dyn_offset_symbol`, which is used inside the Map scope, to `dyn_offset_variable`.
This essentially turns `__dyn_offset_symbol` into a free symbol which has to be supplied at runtime, never mind that the value was already passed.
Furthermore, DaCe will also complain that the symbol is not inside ` sdfg.symbols` but in `sdfg.free_symbols`.

My current solution is to simply not mangle the name and always use `dyn_offset_variable`.
For my current application, JaCe, I think that the Tasklets should remain, to ensure that the Map can be fused with others, which the interstate edge blocks.
The current state is undesirable, since simplify breaks the SDFG.
Thus it should at least change the name inside the scope or what I think is the better solution, to actually keep Tasklets.
[slicing_optimized.json](https://github.com/spcl/dace/files/15481807/slicing_optimized.json)
[slicing_unoptimized.json](https://github.com/spcl/dace/files/15481808/slicing_unoptimized.json)
Contributor guide
Assessment
This issue has not been assessed yet.