chapel icon indicating copy to clipboard operation
chapel copied to clipboard

Fix an ALA bug related to unaligned followers

Open e-kayrakli opened this issue 6 months ago • 0 comments

Resolves https://github.com/chapel-lang/chapel/issues/25727

The following code would fail because of an ALA bug:

use BlockDist;

var A: [blockDist.createDomain({1..100})] int = 5;

var db = {1..50};
var B: [blockDist.createDomain(db)] int = 1;

forall (b, i) in zip(B, db) {
  b = A[i];
}

writeln(B);

The root cause was that when checking for A[i]s alignment, we would check against db instead of B. What's tricky here is that db is actually "aligned" with A as it happens to be its local subdomain. However, that only matters if db was actually the leader of the loop.

This PR fixes the logic in the ALA implementation. This fix revealed another problem with the module-code checks where an array can now be passed to loopDomain formals. This was fixed by adding an array overload for the appropriate functions to pick up the domain of the passed array and call the existing helper with it.

While there this PR:

  • does a very mild refactor to move the common (problematic) logic between static and dynamic checks into a helper function.
  • renames module helpers to have chpl__ala_ prefix for consistency internally within the module and with other optimizations.

Test

  • [ ] linux64
  • [ ] gasnet

e-kayrakli avatar Aug 13 '24 23:08 e-kayrakli