Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrongly generating multi-dimensional indexing into pointer types #16

Open
bastian-koepcke opened this issue Apr 23, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@bastian-koepcke
Copy link
Member

When a Descend array is multi-dimensional, indexing into it will be generated as multiple index operations (multi-dimensional indexing), although the array is only represented as a pointer.

Descend:

array: [ [ i32; n]; m]
array[i][j]

CUDA:

int *array;
array[i][j]

The above example shows wrong indexing.

This may sometimes be correct, because a multi-dimensional array is initially generated as a multi-dimensional C-array

array: descend::array<descend::array<int, n>, m>

But this is changed when creating a reference to the array:

&array : * int

Therefore, find a consistent way to represent arrays and generate correct indexing accordingly.

The solution of how we represent arrays and indexing, influences issue #15.

@bastian-koepcke bastian-koepcke added the bug Something isn't working label Apr 23, 2023
@bastian-koepcke
Copy link
Member Author

bastian-koepcke commented Apr 24, 2023

This problem arises when multidimensional arrays are declared and indexed.

During codegen we see two indices and put them on the indexing path/stack. There are two cases that arise now:

  1. In case the indices used for an array whose multi-dimensionality stems from views, such as group, the indices are correctly adjusted to reflect the length of the inner dimension.
  2. If the multi-dimensionality stems from a multi-dimensional declaration, the indices are not adjusted and we would have to look at the type of the array to determine the width of the inner dimension (which possibly contains even more dimensions).

When generating indices, it is not immediately clear which of the two above cases is relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant