New Issue: Have isArray (and isArrayValue and isArrayType) handled by compiler directly

19949, "stonea", "Have isArray (and isArrayValue and isArrayType) handled by compiler directly", "2022-06-06T19:19:38Z"

In this PR: Add fn exempt instantiation limit pragma and apply it to isArrayValue by stonea · Pull Request #19899 · chapel-lang/chapel · GitHub I add an 'exempt from instantiation limit' pragma and apply it to the isArrayValue procedure.

This was necessary as I moved the proc from a module where things were implicitly exempted to a place where they're not and Arkouda (and I imagine other large Chapel programs) ends up calling isArrayValue many, many times on many different types of values.

More details can be found here:
And here:

See also: Exempt non-recursive functions from instantiation limit · Issue #19948 · chapel-lang/chapel · GitHub

Given how fundamental a query this is and how many instantiations we're creating this might lead to slower compilation time and bloated IR (though I haven't measured it to verify if this is really a concern or not). As such it might be a good idea to handle this like we handle isSubtype and have the compiler itself process the function.

If you want a short program that demonstrates the original problem that occurs if you don't exempt isArray from an instantiation limit you can use the following; first uncomment the uses of pragma "fn exempt instantiation limit" in Types.chpl:

writeln(isArray([1 : uint(8)]));
writeln(isArray([1 : uint(16)]));
writeln(isArray([1 : uint(32)]));
writeln(isArray([1 : int(8)]));
writeln(isArray([1 : int(16)]));
writeln(isArray([1 : int(32)]));
writeln(isArray([1 : real(32)]));
writeln(isArray([(1, 2)]));
writeln(isArray([(1, 1.1)]));
writeln(isArray([(1, 1.0i)]))

Then compile with chpl --instantiate-max 8 foo.chpl. You should get an error:

$CHPL_HOME/modules/standard/Types.chpl:390: error: Function 'isArrayValue' has been instantiated too many times
note:   If this is intentional, try increasing the instantiation limit from 8

You may also find it helpful to use --explain-instantiation isArrayValue to get more debugging information.