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

Reintroduce and update Dart SIMD guide #3679

Open
Tracked by #5475
maks opened this issue Nov 16, 2021 · 17 comments
Open
Tracked by #5475

Reintroduce and update Dart SIMD guide #3679

maks opened this issue Nov 16, 2021 · 17 comments
Labels
act.question Relates to issues that writers need SME help act.wait-for-customer Needs response from customer co.request Community ask for documentation dev.interop Relates to use of native code as part of your Dart app e1-hours Can complete in < 8 hours of normal, not dedicated, work p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.triage.ltw Indicates Lead Tech Writer has triaged

Comments

@maks
Copy link

maks commented Nov 16, 2021

What information is missing?

There is not really any information at all regarding Dart supporting SIMD, in fact you would need to be fairly determined in searching dart.dev to even discover that such support exists.

Yet there used to be what I would consider a pretty good documentation page for it: https://web.archive.org/web/20190402213240/https://www.dartlang.org/articles/server/simd

and reading through it, I am unclear as to why it was considered obsolete and hence removed from the website? Apart from its use of the new keyword, is any of the code or the prose text actually inaccurate for the current versions of Dart lang?

How would you like us to fix this problem?

Please re-instate the previously removed page documenting SIMD usage in Dart.

@maks maks added the co.request Community ask for documentation label Nov 16, 2021
@maks
Copy link
Author

maks commented Nov 16, 2021

I would also be happy to contribute a PR updating the previous documentation page if someone could give some guidance on what specifically was lacking in it that caused it to be classified as "obsolete".

@parlough parlough added docs e1-hours Can complete in < 8 hours of normal, not dedicated, work act.wait-for-customer Needs response from customer p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. labels Nov 16, 2021
@parlough
Copy link
Member

Thanks for sharing your interest in this page @maks. It would be nice to further SIMD documentation, perhaps by starting with this and making some updates. I'll ping @kwalrath and @mit-mit to see their thoughts on reviving an updated version of this page as it was originally removed in #1572

@kwalrath
Copy link
Contributor

@mit-mit what would you like us to do about SIMD? It seems like we could update the article, put it under https://dart.dev/guides/libraries, and add mentions of SIMD to https://dart.dev/guides/language/numbers & maybe the language/library tour (at least).

What do you think? Who knows the most about SIMD now?

@kwalrath
Copy link
Contributor

@maks I think the code examples would need to pass analysis using the current set of recommended lints. We'd ensure this by adding all code in the article to /examples, as documented in https://github.com/dart-lang/site-shared/blob/master/doc/code-excerpts.md & https://github.com/dart-lang/site-shared/blob/master/doc/examples.md.

@maks
Copy link
Author

maks commented Nov 19, 2021

@kwalrath thanks for looking into this so quickly! I'll have a read of those docs to see how it's done - or should I wait for @mit-mit to say on if the SIMD docs can come back before I start working on it?
My 2c about why I raised this is that I think the fact that Dart supports SIMD is really a hidden gem of Dart that very few devs I spoken with in the community know about and would be a great selling point for Dart usage for some applications.

@kwalrath
Copy link
Contributor

I suspect we'd be very happy to accept any help you can offer... but I can't guarantee that without talking to @mit-mit. Or maybe to @kevmoo.

So if you feel like looking at the text or playing with the code, that'd be awesome, but I can't make any promises about using the results... yet.

@kevmoo
Copy link
Member

kevmoo commented Nov 19, 2021

Most of our SIMD support IIRC is just methods in https://api.dart.dev/stable/2.14.4/dart-typed_data/dart-typed_data-library.html

Things like https://api.dart.dev/stable/2.14.4/dart-typed_data/Int32x4/operator_plus.html

Where you can operate on "chunks" of numeric values together.

@maks
Copy link
Author

maks commented Nov 19, 2021

@kevmoo thats true, but the dartdoc documentation is somewhat terse. Really I just found that the previous documentation page did a really nice job of clearly explaining SIMD and how to make use of SIMD in the context of Dart.

Having something like this article that brings it all together with some diagrams and small code examples (at least for me) I find is super helpful if being able to dive in and start using it quickly. For example the explanation and diagrams in the branching section I found helpful as a newcomer to using SIMD (not just SIMD in Dart).

@kwalrath
Copy link
Contributor

Most of our SIMD support IIRC is just methods in https://api.dart.dev/stable/2.14.4/dart-typed_data/dart-typed_data-library.html

Things like https://api.dart.dev/stable/2.14.4/dart-typed_data/Int32x4/operator_plus.html

Where you can operate on "chunks" of numeric values together.

There was a really good article on SIMD that I suspect we jettisoned because its code was untested and rotting. The figures alone are very helpful!

@atsansone
Copy link
Contributor

@mit-mit , @kevmoo : Is this something you would like to see documented in the current public docs? If so, it would need updates for Dart 2 if not Dart 3. Thoughts?

@atsansone atsansone added act.question Relates to issues that writers need SME help st.triage.ltw Indicates Lead Tech Writer has triaged labels Apr 17, 2023
@kevmoo
Copy link
Member

kevmoo commented Apr 17, 2023

@atsansone – I don't there have been any changes w/ Dart 3.

@maks
Copy link
Author

maks commented Apr 17, 2023

My main reason for opening this issue originally was just that I found https://web.archive.org/web/20190402213240/https://www.dartlang.org/articles/server/simd really helpful and useful and thought others would too. Would the Dart team be open to republishing on dart.dev again if I submitted a PR which updated the code examples in it to modern Dart usage (eg removing new's)?

@mit-mit
Copy link
Member

mit-mit commented Apr 18, 2023

@mraleph can you take a quick look at https://web.archive.org/web/20190402213240/https://www.dartlang.org/articles/server/simd and determine if that content is still relevant for the current-day VM?

@mraleph
Copy link
Member

mraleph commented Apr 18, 2023

The content is okay if it is updated. It's not just about updating the code - e.g. it should reflect that SIMD.js is abandoned, etc.

That being said, dart:typed_data API has some issues and I am not sure we want to evangelise it. If anything we should explore the way to pull it out of dart:typed_data and instead provide a number of platform specific intrinsic libraries. There are two core issues with the current API:

  • It was designed in an Intel centric manner - however ARM and Intel instruction sets have different capabilities where it comes to SIMD e.g. classical example would be signMask which is a single instruction on Intel but requires multiple instructions on Arm. Consquently some SIMD operations have really bad implementations on ARM platforms.
  • It does not have and will never have a performant JS implementation, despite residing in a platform independent library.

@maks
Copy link
Author

maks commented Apr 18, 2023

Thanks for looking into it @mraleph
Good to know about this limitations of the API, I'm still a beginner in SIMD (hence why I liked having the old article available) so I didn't realise about it being Intel centric.

I understand not wanting to promote something that you would like to replace, but I guess the current API is going to be here for quite sometime or are there plans for this to change this soon? sorry I couldn't seem to find if there is a roadmap for DartVM features vs the one that exists for upcoming language features/changes.

On the web front, would the upcoming support in Dart for WASM also help with not needing to worry as much about the JS implementation? Funny thing is that the V8 doc on WASM SIMD actually references as being influenced by both SIMD.js and the Dart SIMD 🙂 .

@kevmoo
Copy link
Member

kevmoo commented Apr 18, 2023

If my memory serves, we decided to drop the SIMD documentation as it was poorly maintained and outdated.

@isoos
Copy link
Contributor

isoos commented Jun 6, 2023

I think any non-perfect documentation is better than no documentation (or one that will change in the future), otherwise googling for "dart simd" will yield a parody-site as the first result (like as of now).

@atsansone atsansone changed the title Documentation for Dart SIMD missing Reintroduce and update Dart SIMD guide Jun 28, 2023
@atsansone atsansone removed the docs label Jun 28, 2023
@atsansone atsansone added the dev.interop Relates to use of native code as part of your Dart app label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
act.question Relates to issues that writers need SME help act.wait-for-customer Needs response from customer co.request Community ask for documentation dev.interop Relates to use of native code as part of your Dart app e1-hours Can complete in < 8 hours of normal, not dedicated, work p3-low Valid but not urgent concern. Resolve when possible. Encourage upvote to surface. st.triage.ltw Indicates Lead Tech Writer has triaged
Projects
None yet
Development

No branches or pull requests

8 participants