-
Notifications
You must be signed in to change notification settings - Fork 0
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
Request: design description #1
Comments
Thanks for the suggestion and comments! I have added design notes in the latest commit as a start. The layout types are omitted for now since I'm looking into if they can be improved. |
Very useful, many thanks. Here's one thing that is still unclear to me: Would it be possible to modify the example program such that If this is not possible, how would one write a (generic?) function that accepts input created with either |
I think I found a solution myself. The following generic function accepts references to arrays as well:
Here is my understanding why the original non-generic Still, is there a way to make an |
Yes, right. One way is to do |
One piece of information that I feel should be added somewhere is while there are both layouts and mappings. The way I understand it is that while types that implement the So, if my understanding is correct, an |
Thanks, this solution was not obvious to me. But it requires redundantly restating the shape, and panics if it doesn't match. The following seems to be more robust: Perhaps this should be a method, how about Or perhaps there should be even an equivalent impl of |
I added more conversions for Array to be consistent with normal arrays. It should work now with |
Here is an improved generic version of
Is this use of mdarray "idiomatic"? The above function has also the advantage of allowing the compiler to optimize the inner loop for a fixed number of iterations. For example, the following non-generic function
is compiled to assembly that uses the fact that the inner loop has exactly four iterations. (I verified looking at the assembly generated by |
Thanks for sharing this very interesting library! I've been trying to understand its inner workings, but this is difficult since some central aspect seem both very clever (in a positive sense), and are not documented at all. I think that adding a "DESIGN.md" file (even a small one) may greatly increase the usefulness of this project to other people (be it possible contributors or members of the wider numeric Rust community).
For example, would you mind to describe how
Span
works? I note that it is a zero-sized struct, and only&Span
are passed around. But what do these actually point to? And what is the role ofRawSpan
?Or let's take
Expr
/Expression
. I first thought that it's a view with a somewhat badly chosen name, but it seems to be much more than that. Are types that implement the traitExpression
"expression templates" in C++ speak?What is the relation of
Expr
andSpan
and why are both needed? You write that spans are like Rust slices, but slices are fat pointers, while spans seem to be just pointers that point to... something (that is owned by whom?).It would be also interesting to have a brief discussion of the design aspects of C++'s mdspan/mdarray that you took over, and those that you didn't/couldn't and the reasons for that.
The text was updated successfully, but these errors were encountered: