Skip to content

Should arrays-of-arrays support promotion across nestings? #26848

Open
@bradcray

Description

@bradcray

While working on some array-of-array code recently, I found myself wondering which sorts of promotions we think ought to work in Chapel for arrays-of-arrays:

// Given:
var A: [1..3] [1..3] [1..3] real;

// This works because A and D have the same type/shape
var D: [1..3] [1..3] [1..3] real;
A = D;

// this works because C.type == A.eltType, so it's a normal promotion
var C: [1..3] [1..3] real;
A = C;


// this seems like perhaps it should work, but it doesn't.  We get "cannot iterate over values of type real(64)
A = 1.2;                        // error: cannot iterate over values of type real(64)

// this also seems like it could arguably work as a promotion over the second level of A, but it similarly doesn't
var B: [1..3] real;
A = B;                          // error: cannot iterate over values of type real(64)

Similarly, should one be able to call sin(A) or A + D and get an array-of-array-of-array-of-real result?

In essence, this issue asks "Should promotion be recursively considered in array-of-array situations, or restricted only to the outermost array, as it currently seems to be?"

Activity

damianmoz

damianmoz commented on Mar 6, 2025

@damianmoz

I am assuming that the third case of A = C is just

A[1] = C, A[2] = C, A[3] = C

I am still trying to understand the precise difference between a multi-dimensional array and an array of arrays [of arrays]. Too much historical baggage in my head and a lack of understanding of what must work for the case of distributed memory.

bradcray

bradcray commented on Mar 6, 2025

@bradcray
MemberAuthor

I am assuming that the third case of A = C is just…

That's right. And if the A = B; case was supported, you could imagine it being:

A[1][1] = B;  A[1][2] = B;  A[1][3] = B;
A[2][1] = B;  A[2][2] = B;  A[2][3] = B;
A[3][1] = B;  A[3][2] = B;  A[3][3] = B;

I am still trying to understand the precise difference between a multi-dimensional array and an array of arrays [of arrays].

Let us know if we can help clarify anything here (though ideally in a forum other than this issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bradcray@damianmoz

        Issue actions

          Should arrays-of-arrays support promotion across nestings? · Issue #26848 · chapel-lang/chapel