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

Add support for mdspan #111

Merged
merged 8 commits into from
Mar 19, 2024
Merged

Add support for mdspan #111

merged 8 commits into from
Mar 19, 2024

Conversation

czgdp1807
Copy link
Collaborator

@czgdp1807 czgdp1807 commented Mar 13, 2024

So as can be seen in the test we need to add support for the following things in the ASR,

ListToArray cast - This will simply represent, std::vector::data call. Inside LLVM backend it will be implemented simply as taking the data pointer from list struct to data pointer of array (shallow copy as those are the semantics followed by mdspan as well). In C backend it will be simply transformed to a pointer assignment from list struct to array's data pointer (if the user doesn't want to use any array library) or if someone chooses to use mdspan then will be transformed to original source code.

Rest everything can be managed with the existing ASR features.

#14

cc: @certik

@czgdp1807
Copy link
Collaborator Author

I will continue this work on Monday.

@certik
Copy link
Contributor

certik commented Mar 13, 2024

Yes, one way to solve this is to introduce a list to array cast, which we need for LPython as well. By assigning to mdspan, we copy the data. The C++ code above does not copy data, but does a "view". We would need to ensure that the original data is not use elsewhere, similarly like we (will) do for LPython.

@czgdp1807 czgdp1807 marked this pull request as ready for review March 19, 2024 18:27
@czgdp1807 czgdp1807 enabled auto-merge March 19, 2024 18:27
@czgdp1807 czgdp1807 merged commit ac76a2a into lcompilers:main Mar 19, 2024
2 checks passed
@czgdp1807 czgdp1807 deleted the mdspan_01 branch March 19, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants