Comments (8)
Posting a cut-down version of a reproducer
config const n = 48020;
config const Y = 1;
proc vmax(const ref x : [] real(?w), const ref y : [] real(w))
{
var t = 0:real(w);
foreach (tx, ty) in zip(x, y) do t = max(t, abs(tx * ty));
return t;
}
proc maxOverColumnsTailAtEnd(a : [?D] real(?w), r : [] real(w))
{
const (R, C) = D.dims();
const B = 0 ..< min(R.size, Y*here.maxTaskPar);
var _c : [B, C] real(w);
return [j in C] max reduce _c[.., j];
}
config param w = 64;
proc check(mask : int)
{
const W = 0..<n;
var a : [0..<n, 0..<n] real(w);
var r : [0..<n] real(w);
const alg = 1;
var c = if alg == 0 then
for j in 0..<n do max reduce abs(a[.., j] * r[..])
else if alg == 1 then
[ j in 0..<n ] vmax(a[.., j], r[..])
else
maxOverColumnsTailAtEnd(a, r);
}
config const mask = 1 | 2 | 4 | 8 | 16;
proc main
{
check(mask);
return(0);
}
Compiling this gives the following output
bug.chpl:35: internal error: not handled [resolution/resolveFunction.cpp:2906]
Note: This source location is a guess.
from chapel.
Even smaller reproducer, just need an array type and iterator type on each side of the ternary:
proc test1() {
var arr1: [0..0] int;
var n = 0;
var arr2 = if n == 0
then for i in 0..0 do i
else arr1;
}
proc main {
test1();
}
from chapel.
Looks like there may be some unhandled cases for iterator
-> array
, and iterator
-> iterator
in insertInitConversion
. My plan is to issue an _array.init=
call for the first case, and promote both iterators to arrays in the second case. Both cases should probably also issue a subsequent call to insertInitConversion
in order to consider array runtime types.
But first I need to determine if it's appropriate for us to be in insertInitConversion()
in the first place.
from chapel.
Fixed the bug from the OP. Now I just need to get the extra case from @cassella working.
proc test1() {
var n = 0;
var arr = if n then for i in 0..3 do i else for i in 4..7 do i;
writeln(arr);
}
proc main() {
test1();
}
from chapel.
I'm going to file Paul's bug (previous post, above) as a separate issue. Initially, I was going to opt to promote the "then" branch of the if-expr to an array if both branches were iterator records, and let insertInitConversion()
take care of the rest.
However, @vasslitvinov indicated to me that there might be cases where we want to preserve the "iterator'y'ness" of both sides of the if-expr. E.g., for:
foo(if n then [i in 0..3] i else [i in 4..7] i);
We could do this by creating a third iterator type which unifies both sides of the branch (forwarding to either).
Edit: Actually not sure what to do, here.
I've opened: #24402
from chapel.
@damianmoz - did you mean to include some source code to demonstrate the problem? I'm not seeing such a thing here.
from chapel.
Sorry. See:
bug.txt
from chapel.
Slightly simpler reproducer,
config const n = 48020;
proc maxOverColumnsTailAtEnd(a : [?D] real, r : [] real)
{
return for j in 0..<n do max reduce abs(a[.., j] * r[..]);
}
proc check()
{
var a : [0..<n, 0..<n] real;
var r : [0..<n] real;
const alg = 1;
var c = if alg == 0 then
for j in 0..<n do max reduce abs(a[.., j] * r[..])
else
maxOverColumnsTailAtEnd(a, r);
}
proc main
{
check();
return(0);
}
(Note I replaced the body of maxOverColumnsTailAtEnd()
with the same for expression as in the alg==0 case.)
The error is in insertInitConversion()
which seems to have concluded it's operating on a sync or single. There are no syncs or singles in the reproducer.
if (!typesDiffer && !useRttCopy) {
// types are the same and no runtime types.
...
return;
}
if (useRttCopy) {
...
} else {
...
if (toType->type->symbol->hasFlag(FLAG_TUPLE)) {
} else if (toType->type == getCopyTypeDuringResolution(fromValType)) {
// today, this code should only apply to sync/single
// (since arrays are handled above with useRttCopy)
// for sync/single, getCopyTypeDuringResolution returns the valType.
...
if (isSyncType(fromValType)) { ...
} else if (isSingleType(fromValType)) { ...
} else {
INT_FATAL("not handled");
I wondered if this could be worked around with a split init, but it runs into #24108:
var c;
if alg == 0 then
c = for j in 0..<n do max reduce abs(a[.., j] * r[..]);
else if alg == 1 then
c = [ j in 0..<n ] vmax(a[.., j], r[..]);
else
c = maxOverColumnsTailAtEnd(a, r);
Here's a bonus,
var c = if alg == 0 then
for j in 0..<n do max reduce abs(a[.., j] * r[..])
else
for j in 0..<n do max reduce abs(a[.., j] * r[..]);
foo.chpl:10: In function 'check':
foo.chpl:19: error: Unable to resolve type of if-expression
note: 'then' branch returns type "_ir_chpl__loopexpr_iter12"
note: 'else' branch returns type "_ir_chpl__loopexpr_iter13"
Here's a workaround for Jade's cut-down example, pulling out the expressions in the ternary into their own functions:
config const n = 48020;
config const Y = 1;
proc vmax(const ref x : [] real(?w), const ref y : [] real(w))
{
var t = 0:real(w);
foreach (tx, ty) in zip(x, y) do t = max(t, abs(tx * ty));
return t;
}
proc maxOverColumnsTailAtEnd(a : [?D] real(?w), r : [] real(w))
{
const (R, C) = D.dims();
const B = 0 ..< min(R.size, Y*here.maxTaskPar);
var _c : [B, C] real(w);
return [j in C] max reduce _c[.., j];
}
proc init1(a, r) {
return for j in 0..<n do max reduce abs(a[.., j] * r[..]);
}
proc init2(a, r) {
return [ j in 0..<n ] vmax(a[.., j], r[..]);
}
config param w = 64;
proc check(mask : int)
{
const W = 0..<n;
var a : [0..<n, 0..<n] real(w);
var r : [0..<n] real(w);
const alg = 1;
var c = if alg == 0 then
init1(a, r)
else if alg == 1 then
init2(a, r)
else
maxOverColumnsTailAtEnd(a, r);
}
config const mask = 1 | 2 | 4 | 8 | 16;
proc main
{
check(mask);
return(0);
}
from chapel.
Related Issues (20)
- [Bug]: problems using a sibling module with module include
- [Bug]: Chapel/Fortran interoperability, internal compiler error HOT 1
- until <condition> do <statement> OR do <statement> until <condition> - Low Priority
- `--report-gpu` can report false positives
- Better error message for RectangularDomain.sorted()
- Ensure all CLS inlays respect
- How should 'require something.chpl' interact with finding the main module? HOT 6
- [Bug]: Type inlay hints are printed incorrectly for several types
- CLS: Enum values print as dyno ids instead of their name
- [Bug]: CLS does not treat complex numbers as literals HOT 4
- [Bug]: CLS should not crash when resolving `string`
- [Feature Request]: CLS - mark unused functions/records/modules/variables as unused
- [Feature Request]: CLS - don't show generic code lenses when a function has a single instantiation
- [Feature Request]: Integrate CLS better with Mason
- [Documentation]: Extend the Standard Module Style guide for other decisions we've made HOT 1
- [Bug]: Subprocesses interact strangely with `valgrind`
- Type Promotion Issue with Complex Types HOT 3
- Should forall loops over default arrays of locales result in coforall + on implementation by default?
- Simplify/specialize error message for calling a method on a nilable class variable
- Dyno asserts when casting a string to bytes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chapel.