On Sun, Oct 15, 2023 at 06:39:35PM -0700, Emil Vatai wrote:
> Dear Sven,
>
> I want to parallelize loops: let's say I have a schedule (tree), and after
> some analysis I determine which band nodes can be parallelized, and when
> generating code I want to have `#pragma omp parallel for` before the
> generated for loops.
>
> The way I was trying to do this (which seems to be incorrect) was
> 1. to mark the band nodes in the schedule tree (with a mark node) [no
> problem here, for now I do this by manually adding a mark node into a yaml
> file which contains the schedule]
> 2. then (I was hoping) to use `isl_ast_print_options_set_print_for()` to
> generate a custom loop which either has the omp pragma or doesn't depending
> whether the loop is marked or not.
Sounds reasonable.
PPCG does something similar, although it performs the analysis
during the AST generation, so it's not directly applicable
for your needs.
> This doesn't work because the mark is in the schedule tree while the
> printing (and set_print_for() function) is in the AST. I also considered
> using `isl_ast_build_set_{before|after}_each_{for|mark}` to make the
> connection between the schedule tree and AST using
> `isl_ast_node_set_annotation()`. However I failed: in the each_mark()
> function I could only get a copy of the child (i.e. the for loop) and
> setting the annotation did not appear in the original for `isl_ast_node`,
> and for the each_for() function I couldn't access the parent of the
> `isl_ast_node` (AFAIK there is nothing similar to `is_ast_node_parent()`).
What node did you return from the isl_ast_build_set_after_each_mark?
The annotated for-node or something else?
Is the problem that you want to preserve the mark-node even
after adding the annotation to the for-node?
skimo