thomasrolinger / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
0 stars 1 forks source link

(4) Task: Check all nested loops within forall for validness #8

Closed thomasrolinger closed 2 years ago

thomasrolinger commented 2 years ago

Right now, we detect during normalization if A[B[i]] is within a loop that is within the forall. We do some correctness checks regarding that loop's domain. But we don't check to see if there is yet another outer loop within the forall, something like:

forall i in B.domain {
   for j in A.domain {
      for k in B.domain {
         ... A[B[i]] ...
      }
   }
}

So we need to apply our checks recursively to each nested loop. We can use the same requirements for each loop, which is that it must iterate over B's domain. But we can relax the other conditions, which is that i must be yielded by its iterator. That only applies to the "closest" loop to the A[B[i]] access.

thomasrolinger commented 2 years ago

Addressed this. The tricky part was handling the checks for i in B[i] to be yielded by the loop iterator. That only matters for the closest for-loop in the nest. We had to add a flag argument to isLoopDomainValidIE to indicate whether we are processing the "first" loop or not. When we process the first loop, we do the checks as usual. Any other loop after that in the nest will skip the check.

New tests added and appear to be working: ie_test_nestedForLoops.chpl and ie_test_nestedForLoops_invalid.chpl.