chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.77k stars 417 forks source link

[Bug]: Reductions over distributed arrays in default arguments cause compiler segfaults #25045

Open jabraham17 opened 3 months ago

jabraham17 commented 3 months ago

Summary of Problem

Description: Using a distributed array in a reduce expression that is the default argument for a function causes the compiler to segfault

Is this a blocking issue with no known work-arounds? I don't have a good workaround that keeps the code looking clean

Steps to Reproduce

Source Code:

use BlockDist;

const D = blockDist.createDomain({1..10, 1..10}); // I also observed this with Stencil, it is not specific to the distribution
// using a non-distributed array works perfectly fine
// const D = {1..10, 1..10};
var A: [D] int = 2;

proc foo(a: [], m = (min reduce a)) { // it does not matter the reduction
  writeln("arr ", a);
  writeln("min ", m);
}
foo(A);
// explicitly specifying the default also works
foo(A, min reduce A);

Compile command: chpl foo.chpl

Associated Future Test(s): test/functions/default-arguments/default-arg-reduce-distributed.chpl

Configuration Information

jabraham17 commented 3 months ago

Noting that I hit this while working on https://github.com/chapel-lang/chapel/pull/24924. One workaround is to extract the default argument out as a separate helper function.

proc helper(a: []) do return min reduce a;
proc foo(a: [], m = helper(a)) { 
   ...
}